@hearsay-tools/squawk 0.19.0-dev.9210 → 0.19.0-dev.9220

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 (137) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/features/hosts/routes.d.ts +64 -64
  3. package/dist/features/webhooks/routes.d.ts +38 -38
  4. package/dist/server/activity-routes.d.ts +23 -23
  5. package/dist/server/projects-routes.d.ts +41 -41
  6. package/dist/server/runs-routes.d.ts +311 -311
  7. package/package.json +4 -4
  8. package/web/dist/assets/accounts-section-s6sAdUT8.js +1 -0
  9. package/web/dist/assets/activity-motion-CXlbNrMI.js +1 -0
  10. package/web/dist/assets/{activity-route-BNDRi4k-.js → activity-route-BL-QWLNp.js} +1 -1
  11. package/web/dist/assets/agent-accounts-Du8CHfFX.js +1 -0
  12. package/web/dist/assets/agent-config-section-BzMSlPK0.js +7 -0
  13. package/web/dist/assets/agent-defaults-section-CqEVmRK0.js +1 -0
  14. package/web/dist/assets/appearance-vI6ae_So.js +1 -0
  15. package/web/dist/assets/archive-on-merge-field-C4hrO55O.js +1 -0
  16. package/web/dist/assets/ask-card-hEb8IHjL.js +9 -0
  17. package/web/dist/assets/automations-route-Bd6crv15.js +2 -0
  18. package/web/dist/assets/commit-list-Jr1_04RS.js +1 -0
  19. package/web/dist/assets/diff-BOF9OXhn.js +3 -0
  20. package/web/dist/assets/{diff-controls-C_ysCTVK.js → diff-controls-CkxtRrbB.js} +1 -1
  21. package/web/dist/assets/{diff-view-f2Zb3Tuc.js → diff-view-Chu6rn_i.js} +1 -1
  22. package/web/dist/assets/{discard-changes-dialog-Db5fnRbe.js → discard-changes-dialog-BB47RqdX.js} +1 -1
  23. package/web/dist/assets/file-preview-DNM-krBZ.js +2 -0
  24. package/web/dist/assets/folder-browser-TNWat5kt.js +1 -0
  25. package/web/dist/assets/{git-toolbar-DasGkLg-.js → git-toolbar-CoKBTzNV.js} +1 -1
  26. package/web/dist/assets/github-t611QkCi.js +1 -0
  27. package/web/dist/assets/{global-activity-route-DZtIc9Y6.js → global-activity-route-B9DMoviv.js} +1 -1
  28. package/web/dist/assets/{host-context-DDbYAKpm.js → host-context-iTMFRMT5.js} +1 -1
  29. package/web/dist/assets/host-storage-Cr_NKfWy.js +1 -0
  30. package/web/dist/assets/hosts-rdWe_OBc.js +1 -0
  31. package/web/dist/assets/{image-preview-CdL9a1Zj.js → image-preview-C_xACQXI.js} +1 -1
  32. package/web/dist/assets/index-C3kap2_j.js +21 -0
  33. package/web/dist/assets/index-CWmMYQdT.css +1 -0
  34. package/web/dist/assets/label-B_s8eiYA.js +1 -0
  35. package/web/dist/assets/{markdown-B4JilOS6.js → markdown-Bmdr6MIa.js} +1 -1
  36. package/web/dist/assets/{open-in-menu-Bf8JA2DJ.js → open-in-menu-DkFneOWr.js} +1 -1
  37. package/web/dist/assets/{option-select-C7kknSij.js → option-select-BxTmKg8G.js} +1 -1
  38. package/web/dist/assets/preferences-section-B_yl_o-g.js +1 -0
  39. package/web/dist/assets/preview-D3zYSmIA.js +1 -0
  40. package/web/dist/assets/{preview-pane-connected-BdBFebn0.js → preview-pane-connected-s9LvCVbp.js} +2 -2
  41. package/web/dist/assets/project-location-BczZtNyO.js +1 -0
  42. package/web/dist/assets/project-router-CfEuKuz1.js +1 -0
  43. package/web/dist/assets/project-scope-context-DNrHbqd2.js +4 -0
  44. package/web/dist/assets/projects-section-C6DnyUa2.js +1 -0
  45. package/web/dist/assets/{prompt-templates-section-Br5uL5GK.js → prompt-templates-section-BQvKWcaX.js} +2 -2
  46. package/web/dist/assets/queries-DD_9iITj.js +1 -0
  47. package/web/dist/assets/reference-chip-e-fG4-yW.js +1 -0
  48. package/web/dist/assets/remote-settings-notice-CUqI2DdF.js +1 -0
  49. package/web/dist/assets/repo-git-NG_TxE7N.js +1 -0
  50. package/web/dist/assets/report-reader-LYNHrAe-.js +1 -0
  51. package/web/dist/assets/{report-selection-Y2F9NTAs.js → report-selection-nUbQVjJu.js} +1 -1
  52. package/web/dist/assets/reports-DuT4m7i5.js +1 -0
  53. package/web/dist/assets/{resources-section-DEvZicO3.js → resources-section-CT48TCXY.js} +1 -1
  54. package/web/dist/assets/{review-notes-drafts-dS7OB8et.js → review-notes-drafts-C7HCRebB.js} +1 -1
  55. package/web/dist/assets/{review-panel-BRdqkYjE.js → review-panel-BffLSkRo.js} +1 -1
  56. package/web/dist/assets/review-strip-COa0ir6V.js +1 -0
  57. package/web/dist/assets/{run-detail-refresh-SYZM94ch.js → run-detail-refresh-Db5HOGMX.js} +1 -1
  58. package/web/dist/assets/{run-diff-D26PXp6r.js → run-diff-DldSY8BJ.js} +1 -1
  59. package/web/dist/assets/run-header-DxpN6yVQ.js +2 -0
  60. package/web/dist/assets/{select-DGNeDPgB.js → select-Cd8wvwvm.js} +1 -1
  61. package/web/dist/assets/{session-context-section-5kleIwBF.js → session-context-section-CW8DS0dW.js} +1 -1
  62. package/web/dist/assets/settings-agent-picker-an3ysM1B.js +1 -0
  63. package/web/dist/assets/{settings-save-bar-BBRySnQz.js → settings-save-bar-BiHFQ4c0.js} +1 -1
  64. package/web/dist/assets/settings-shell-KZ801oLH.js +1 -0
  65. package/web/dist/assets/sidebar-section-BRMO7aY4.js +1 -0
  66. package/web/dist/assets/skills-DHkLoxXb.js +1 -0
  67. package/web/dist/assets/status-dot-Da1M54kK.js +1 -0
  68. package/web/dist/assets/{tab-link-BJDe5cT4.js → tab-link-DL1UtKVR.js} +1 -1
  69. package/web/dist/assets/task-changes-CQhwyj0L.js +5 -0
  70. package/web/dist/assets/task-commits-CTP8izpc.js +1 -0
  71. package/web/dist/assets/{task-file-scope-DIKRE_b-.js → task-file-scope-CDIfOvl-.js} +1 -1
  72. package/web/dist/assets/task-files-CGlRH86B.js +1 -0
  73. package/web/dist/assets/task-github-item-ChgjULzj.js +1 -0
  74. package/web/dist/assets/task-thread-Cj9B2ISO.js +2 -0
  75. package/web/dist/assets/thread-state-D2KJrZ1o.js +4 -0
  76. package/web/dist/assets/use-finish-run-DifixlCM.js +1 -0
  77. package/web/dist/assets/use-hand-to-agent-state-Bjh1EnB3.js +1 -0
  78. package/web/dist/assets/use-path-bases-AV9YYh2B.js +1 -0
  79. package/web/dist/assets/use-workspace-config-save-02qlUK8v.js +1 -0
  80. package/web/dist/assets/{workflows-tS2KFiN5.js → workflows-BDc-MpiC.js} +2 -2
  81. package/web/dist/assets/workspace-tools-D7kUSb-0.js +1 -0
  82. package/web/dist/assets/{worktrees-section-Be49G15q.js → worktrees-section-Cv65NBgq.js} +5 -5
  83. package/web/dist/assets/{zoomable-image-CULOtYYp.js → zoomable-image-DJ1lJEMc.js} +1 -1
  84. package/web/dist/index.html +17 -20
  85. package/web/dist/live-worker.js +1 -1
  86. package/web/dist/assets/accounts-section-rl1VZO3h.js +0 -1
  87. package/web/dist/assets/activity-motion-z61Fgew-.js +0 -1
  88. package/web/dist/assets/agent-accounts-C2ILQhZy.js +0 -1
  89. package/web/dist/assets/agent-config-section-n-pEsz22.js +0 -7
  90. package/web/dist/assets/agent-defaults-section-D-HJwVes.js +0 -1
  91. package/web/dist/assets/appearance-BtRmAcNb.js +0 -1
  92. package/web/dist/assets/archive-on-merge-field-CvMwaqSO.js +0 -1
  93. package/web/dist/assets/ask-card-BwUCf0aZ.js +0 -9
  94. package/web/dist/assets/attention-C7BUdd2s.js +0 -1
  95. package/web/dist/assets/automations-route-DTiAXiUI.js +0 -2
  96. package/web/dist/assets/commit-list-C9Hv9ml6.js +0 -1
  97. package/web/dist/assets/diff-Cj-x8nqJ.js +0 -3
  98. package/web/dist/assets/file-preview-Cyj25xiD.js +0 -2
  99. package/web/dist/assets/folder-browser-3cBLlnE9.js +0 -1
  100. package/web/dist/assets/github-DCg3ksYv.js +0 -1
  101. package/web/dist/assets/host-storage-B72yoDU1.js +0 -1
  102. package/web/dist/assets/hosts-iUyg8S3j.js +0 -1
  103. package/web/dist/assets/index-DDSPQb52.css +0 -1
  104. package/web/dist/assets/index-DKnr4QWH.js +0 -21
  105. package/web/dist/assets/label-CWlxyeC-.js +0 -1
  106. package/web/dist/assets/preferences-section-fRAjnH9V.js +0 -1
  107. package/web/dist/assets/preview-BSFJfN4s.js +0 -1
  108. package/web/dist/assets/project-location-J285aq6e.js +0 -1
  109. package/web/dist/assets/project-router-CwD1firw.js +0 -1
  110. package/web/dist/assets/projects-section-CTJAcTFT.js +0 -1
  111. package/web/dist/assets/queries-D9mg7sFY.js +0 -1
  112. package/web/dist/assets/read-state-BsTfJki5.js +0 -1
  113. package/web/dist/assets/reference-chip-CZKBU_Ud.js +0 -1
  114. package/web/dist/assets/remote-settings-notice-oiFixJ1Q.js +0 -1
  115. package/web/dist/assets/repo-git-BnF9zc0t.js +0 -1
  116. package/web/dist/assets/report-reader-CAKZUxHi.js +0 -1
  117. package/web/dist/assets/reports-DLzhtnVJ.js +0 -1
  118. package/web/dist/assets/review-strip-BCrYmUm6.js +0 -1
  119. package/web/dist/assets/run-header-sCyLqpuL.js +0 -2
  120. package/web/dist/assets/settings-agent-picker-BHaCHv3L.js +0 -1
  121. package/web/dist/assets/settings-shell-NnVky05a.js +0 -1
  122. package/web/dist/assets/sidebar-section-CJttxkBb.js +0 -1
  123. package/web/dist/assets/skills-BWhCi78k.js +0 -1
  124. package/web/dist/assets/status-dot-DTU7afRv.js +0 -1
  125. package/web/dist/assets/task-changes-DxraCwDD.js +0 -5
  126. package/web/dist/assets/task-commits-BT54zRvY.js +0 -1
  127. package/web/dist/assets/task-files-BzhShCDY.js +0 -1
  128. package/web/dist/assets/task-github-item-NuNVjHSM.js +0 -1
  129. package/web/dist/assets/task-groups-BvVfsQKd.js +0 -1
  130. package/web/dist/assets/task-thread-Kb7rfaii.js +0 -2
  131. package/web/dist/assets/thread-state-BLwCv9hp.js +0 -4
  132. package/web/dist/assets/toaster-2ud_VdfV.js +0 -4
  133. package/web/dist/assets/use-finish-run-CfvaMV-b.js +0 -1
  134. package/web/dist/assets/use-hand-to-agent-state-DykS8SPU.js +0 -1
  135. package/web/dist/assets/use-path-bases-B7D8PPso.js +0 -1
  136. package/web/dist/assets/use-workspace-config-save-DDI7_WtK.js +0 -1
  137. package/web/dist/assets/workspace-tools-B5wyKj6g.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{$t as i,B as a,Ct as o,Gn as s,H as c,Ht as l,M as u,Mn as d,Mt as f,Pn as p,Pt as m,Rt as h,Un as g,Vt as _,Wn as v,Xn as y,Xt as b,Yn as x,Yt as S,Zn as C,_r as w,bt as T,g as E,gr as D,hr as O,in as k,jt as A,mr as j,nn as M,pt as N,qn as P}from"./queries-DD_9iITj.js";import{Ai as F,Bi as I,Cn as L,Di as R,Ei as z,Fi as B,Ii as ee,Jr as V,Mi as H,Nt as te,Oi as U,Si as ne,Ti as W,Zi as G,a as re,at as ie,br as ae,ct as oe,dt as se,ji as ce,mr as le,ot as ue,pr as de,qr as fe,yr as pe}from"./project-scope-context-DNrHbqd2.js";import{g as me,n as he,p as ge}from"./chunk-KS7C4IRE-BdLLx37K.js";import{O as _e,_ as ve,d as ye,i as be,o as xe,t as Se,w as Ce,x as we}from"./reference-chip-e-fG4-yW.js";import{o as K,s as Te}from"./dist-CCX8mhHc.js";import{A as Ee,B as De,V as Oe,_ as ke,b as Ae,c as je,ct as Me,d as Ne,ft as Pe,g as Fe,h as Ie,j as Le,m as Re,n as ze,o as Be,ot as Ve,p as He,u as Ue}from"./design-icons-QbNMZniQ.js";import{t as We}from"./createLucideIcon-BHp8sXmF.js";import{A as Ge,C as Ke,D as qe,E as Je,F as Ye,I as Xe,L as Ze,M as Qe,N as $e,O as et,P as tt,R as nt,S as rt,T as it,_ as at,a as ot,b as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,j as mt,k as ht,l as gt,m as _t,n as vt,o as yt,p as bt,r as xt,s as St,t as Ct,u as wt,v as Tt,w as Et,x as Dt,y as Ot,z as kt}from"./ask-card-hEb8IHjL.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,s as Ft,t as It}from"./run-header-DxpN6yVQ.js";import{t as Lt}from"./eye-B8okNWXU.js";import{t as Rt}from"./loader-circle-CPBhhDbB.js";import{a as zt}from"./tool-display-CTbToGmi.js";import{t as Bt}from"./search-x-I9Q8pgUa.js";import{t as Vt}from"./preview-D3zYSmIA.js";import{t as q}from"./button-BV_AiLj2.js";import{n as Ht,r as Ut,t as Wt}from"./collapsible-D5i3hm2L.js";import{a as Gt,i as Kt,o as qt,r as Jt,t as Yt}from"./popover-BQolmvDR.js";import{s as Xt,t as Zt}from"./project-router-CfEuKuz1.js";import{t as J}from"./status-dot-Da1M54kK.js";import{c as Qt,i as $t,l as en,o as tn,r as nn,s as rn,t as an}from"./report-selection-nUbQVjJu.js";import{l as on,m as sn}from"./page-shell-BdjH5hyc.js";import{i as cn,t as ln}from"./agent-accounts-Du8CHfFX.js";import{t as un}from"./centered-state-N8vWM_Hw.js";import{An as dn,B as fn,Fn as pn,I as mn,L as hn,Nn as gn,Q as _n,R as vn,Sn as yn,Tn as bn,Un as xn,Vn as Sn,Wn as Cn,X as wn,Z as Tn,_n as En,b as Dn,bn as On,c as kn,ir as An,l as jn,m as Mn,mn as Nn,n as Pn,nt as Fn,o as In,pn as Ln,r as Rn,tt as zn,un as Bn,v as Vn,vn as Hn,w as Un,yn as Wn,z as Gn}from"./index-C3kap2_j.js";import{t as Kn}from"./markdown-Bmdr6MIa.js";import{t as qn}from"./task-file-scope-CDIfOvl-.js";import{t as Jn}from"./run-diff-DldSY8BJ.js";import{n as Yn,t as Xn}from"./use-finish-run-DifixlCM.js";import{i as Zn}from"./automation-format-jKMOXcHS.js";import{a as Qn,i as $n,n as er,o as tr,r as nr,t as rr}from"./thread-state-D2KJrZ1o.js";var ir=We(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Y=e(t(),1),X=r();function ar(e,t,n,r,i,a,o,s,c){let l=C(e,Nn(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=vn(t,o,a,[p,f?.[t]]),h=fn(p,t,o,f,a),g=hn(h,a),_=r?``:c??d??``,v=Gn(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function or(e,t,n,r){let i=x(e.steps),a=C(e,Nn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function sr(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function cr(e,t,n,r){return!!t&&(r!==y(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function lr({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`Runner default`,effortLabel:n.find(e=>e.value===r)?.label??`Runner default`}}function ur(e){let t=M(),n=On(e).continueRun,r=E(),[i,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),f=`${e.id}:${C(e,Nn(e))?.id??``}`,[p,m]=(0,Y.useState)(f);p!==f&&(m(f),s(null),l(null),d(null));let h=Yn(e,i),{runners:g,canContinue:_,currentRunner:v,runner:y}=h,{sessionStep:b,workerStep:x,account:S}=or(e,y,y!==v,cn().repoAccount),O=a(),k=O.data?.capabilities?.localHandoff!==!1,A=T(),j=o(y,n&&!O.isPending&&!A.isPending,k?S:null),P=r.data?.modelsLocked===!0,F=y!==v,I=ar(e,y,F,P,r.data,j.data,A.data,c,u),{models:R,model:z,effortOptions:B,effort:ee}=I,{modelLabel:V,effortLabel:H}=lr(I),te=w({mutationFn:({text:t,images:n})=>_?oe(D(e.id),sr(t,n,h.runnerOverride,P,F,c,u,I)):Promise.reject(Error(h.reason??`Connect an agent provider to continue.`)),onMutate:()=>D(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof L&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),U=e.delegation?.role===`worker`,ne=sn();return{skillRunner:y,skillAccount:S,available:n,canContinue:_,startsNewConversation:cr(e,b,x,y),reason:h.reason,providerPending:h.providerPending,pills:(0,X.jsx)(dr,{compact:!ne||e.status===`review`,summary:`${N(A.data,y)} · ${V} · ${H}`,children:(0,X.jsxs)(Tn,{children:[!U&&(g.length>1||h.signedOut.length>0)?(0,X.jsx)(_n,{icon:(0,X.jsx)(Ve,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:g,signedOut:h.signedOut,value:y,onPick:e=>{e!==y&&(s(e),l(null))}}):(0,X.jsx)(wn,{icon:(0,X.jsx)(Ve,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:U?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:y,value:y,onPick:()=>{},options:[{value:y,label:y}]}),(0,X.jsx)(wn,{icon:(0,X.jsx)(Ae,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:V,value:z,readOnly:P,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{l(e);let t=hn(e,j.data);ee!==``&&Gn(ee,t)===``&&d(``)},options:R.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:mn(y,A.data,j)}),(0,X.jsx)(wn,{icon:(0,X.jsx)(Ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:H,value:ee,readOnly:P,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>d(e),options:B.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},f),continueWith:(e,t)=>te.mutateAsync({text:e,images:t})}}function dr({compact:e,summary:t,children:n}){let[r,i]=(0,Y.useState)(!1),a=Fn(),[o,s]=(0,Y.useState)(a);a!==o&&(s(a),a&&i(!1));let c=(0,Y.useRef)(null),l=e&&!r;return(0,Y.useEffect)(()=>{r&&(c.current?.querySelector(`button:not([disabled])`)??c.current)?.focus()},[r]),(0,X.jsx)(`div`,{ref:c,"data-slot":`follow-up-engine`,"data-folded":l||void 0,tabIndex:l?void 0:-1,className:l?`min-w-0`:`session-engine-controls outline-hidden`,children:l?(0,X.jsxs)(`button`,{type:`button`,"data-slot":`follow-up-engine-summary`,"aria-expanded":!1,"aria-label":`Agent settings: ${t}`,title:`Change the runner, model or effort`,onClick:()=>i(!0),className:`inline-flex min-h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground transition-colors outline-hidden hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,X.jsx)(Ve,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var fr=120,pr=e=>e!==`pending`&&e!==`running`,mr=e=>e.kind===`tool`&&e.toolKind===`task`,hr=e=>mr(e)&&e.parentItemId===void 0,gr=e=>$e(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function _r(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function vr(e){if(e.kind===`tool`)return yr(e.title);if(e.kind===`hook`)return yr(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
2
+ `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return yr(n)}}}function yr(e){return e.length>fr?`${e.slice(0,fr-1).trimEnd()}…`:e}function br(e,t=!1,n=e){let r=wr(e,e=>e.items.some(hr));if(r===-1)return[];let i=e=>!t&&!pr(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(hr);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(hr)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>xr(r,Or(n,e,r.id),t))}function xr(e,t,n){let r={id:e.id,title:Qe(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=_r(e);i!==void 0&&(r.agentType=i),n&&!pr(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=vr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Sr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Cr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function wr(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Tr(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&hr(e));if(a!==void 0)return xr(a,Or(r,e,t),n)}}function Er(e,t){return wr(e,e=>e.items.some(e=>e.id===t&&hr(e)))}function Dr(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)gr(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function Or(e,t,n){let r=Er(t,n);if(r===-1)return[];let i=Dr(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of Dr(e,n,Math.max(Er(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:kr(t,e))}return[...s.values()].sort(Ar).map(({entry:e})=>e)}function kr(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function Ar(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function jr(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?mt(e.children).flatMap(n=>jr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>jr(e,t)):[]}function Mr(e){return e.flatMap((e,t)=>e.content.kind===`block`?jr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Nr(e,t,n,r){let i=(0,Y.useContext)(an),{projectId:a}=me(),o=(0,Y.useMemo)(()=>Mr(t),[t]);(0,Y.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=Ze(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=Xe(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function Pr(e){let t=G();return w({mutationFn:t=>se(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:k.runs.all})}})}var Fr=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Ir=()=>navigator.onLine;function Lr({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,X.jsx)(zr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,X.jsx)(Rr,{permission:e,runId:t},e.requestId)}function Rr({permission:e,runId:t}){let n=Pr(t),r=(0,Y.useSyncExternalStore)(Fr,Ir,()=>!1),i=(0,Y.useRef)(!1),[a,o]=(0,Y.useState)(`pending`),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(void 0),d=l?.message;ae(()=>{u(e=>e?.clearOnHostRecovery?void 0:e)});let f=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof L&&e.status===409&&!le(e)?o(`expired`):(u({message:e instanceof Error?e.message:String(e),clearOnHostRecovery:de(e)}),o(`pending`))}finally{i.current=!1}}};return(0,X.jsx)(zr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:d,onSelect:e=>{f(e)}})}function zr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Y.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,X.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-card-edge bg-card shadow-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,X.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,X.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,X.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,X.jsx)(q,{type:`button`,variant:`outline`,size:`block`,disabled:s,"aria-pressed":e.optionId===t.id,className:`min-w-0 py-2 [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,X.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}var Br=(0,Y.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Vr(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function Hr(e,t,n=[]){let r={};for(let e of n)r[e.id]=p(e);for(let e of t??[])r[e.id]=p(e);return r[e.id]=p(e),r}function Ur(e,t){return t?.[e]??`Task`}function Wr(e,t,n){return t?n?.[e]??`peer task`:Ur(e,n)}function Gr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Kr(e){return e?.relationship===`peer`}function qr(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Jr(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function Yr(e){if(e.outcome)return Jr(e.outcome.status);if(e.delivery===`not-delivered`)return Xr(`not-delivered`)}function Xr(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Zr(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Kr(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${bn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Qr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Ur(e,n),linkable:!0}):(0,X.jsx)($r,{id:e,children:r})}function $r({id:e,children:t}){let n=l(e);return n.data?t({title:p(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof L&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var ei={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},ti=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function ni({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,X.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,X.jsx)(ri,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function ri({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Gr(e.messages[0]??{senderRunId:e.senderRunId},t),a=Kr(e.messages[0]),o=ei[a?`peer`:i],s=fi(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),c=i===`outbound`?`SENT to`:`RECEIVED from`,l=`${c} ${s.map(e=>Wr(e,a,n)).join(`, `)}`,u=e.messages[0],d=u?.createdAt??u?.recordedAt;return(0,X.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:K(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes),children:[(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:K(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,X.jsx)(`span`,{children:c}),s.map((e,t)=>(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,X.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,X.jsx)(Qr,{id:e,peer:a,taskTitles:n,children:t=>(0,X.jsx)(ci,{view:t,to:`/tasks/${e}`,label:`${c} ${t.title}`})})]},e))]}),a?(0,X.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,X.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:qr(e.kind)}),e.messages.length===1&&u?(0,X.jsx)(ai,{message:u}):null]}),(0,X.jsx)(ii,{at:d,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-xs text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,X.jsx)(si,{batch:e},`${t}:${u?.messageId??e.id}`),[...new Set(e.messages.map(e=>Zr(e,r?.[e.recipientRunId])))].map(e=>e?(0,X.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,X.jsx)(oi,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&u?(0,X.jsx)(li,{message:u,runId:t,taskTitles:n}):null,(0,X.jsx)(ui,{batch:e,heading:l})]})}function ii({at:e,className:t,children:n}){return e===void 0||at(e)===void 0?null:(0,X.jsxs)(`span`,{className:t,children:[n,(0,X.jsx)(ft,{ts:e})]})}function ai({message:e}){let t=Yr(e),n=Xr(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,X.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function oi({messages:e,peer:t,runId:n,taskTitles:r}){return(0,X.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Yr(e),a=e.createdAt??e.recordedAt;return(0,X.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(Qr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,X.jsx)(ci,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Xr(e.delivery)===i?null:(0,X.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Xr(e.delivery)}),(0,X.jsx)(li,{message:e,runId:n,taskTitles:r}),(0,X.jsx)(ii,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function si({batch:e}){let t=Ge(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Y.useState)(()=>t?.get(n)??!1),a=(0,X.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,X.jsx)(Kn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,X.jsxs)(Wt,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,X.jsxs)(Ut,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,X.jsx)(Ne,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,X.jsx)(Ht,{children:a})]})}function ci({view:e,to:t,label:n}){return e.linkable?(0,X.jsx)(Zt,{className:ti,to:t,"aria-label":n,children:e.title}):(0,X.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function li({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Y.useContext)(Br),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,X.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Gr(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:K(ti,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,X.jsx)(Qr,{id:i,peer:Kr(e.message),taskTitles:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[`View `,c,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function ui({batch:e,heading:t}){return(0,X.jsxs)(Wt,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,X.jsxs)(Ut,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,X.jsx)(Ne,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,X.jsx)(Ht,{children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-xs text-muted-foreground`,children:[(0,X.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>di(e)).map((e,t)=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,X.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function di(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Kr(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Xr(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function fi(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var pi=e(n(),1),mi=`pending-ask`;function hi(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function gi(e,t){if(e.dataset.askMode===`reply`){let n=(t??e.closest(`[data-slot="thread-dock"]`)??document).querySelector(`[data-slot="thread-composer-slot"]:not([hidden]) textarea:not(:disabled)`);if(n)return n}return hi(e)}function _i(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?gi(t,e):null}function vi(e,t){let n=`${mi}:${e}`;return r=>{if(!t())return!1;let i=[...r.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);if(i)return _i(i);let a=[...r.querySelectorAll(`[data-slot="ask-card"][data-pinned="true"]`)].find(t=>t.dataset.askId===e);return a?gi(a,r):null}}function yi(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function bi({onGoToQuestion:e}){return(0,X.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,X.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}function xi(){let e=(0,Y.useRef)(null);return(0,Y.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.closest(`[data-slot="main"]`),r=t.querySelector(`[data-slot="run-header"]`),i=t.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),a=r.getBoundingClientRect(),o=getComputedStyle(document.documentElement),s=document.documentElement.style.getPropertyValue(`--kb`)||(typeof o.getPropertyValue==`function`?o.getPropertyValue(`--kb`):``),c=Number.parseFloat(s)||0;n.clientHeight>0&&n.clientHeight<420?t.dataset.compactViewport=`true`:delete t.dataset.compactViewport,c>0||Gt(window)?t.dataset.keyboardOpen=`true`:delete t.dataset.keyboardOpen,r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-a.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${Si(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),delete t.dataset.compactViewport,delete t.dataset.keyboardOpen,r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function Si(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var Z={viewKey:void 0,generation:0},Ci=600,wi=24;function Ti(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Y.useRef)(a);o.current=a;let s=(0,Y.useRef)(e);s.current=e;let c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),p=(0,Y.useRef)(!0),m=(0,Y.useRef)(!0),h=(0,Y.useRef)(0),g=(0,Y.useRef)(0),_=(0,Y.useRef)(new Set),v=(0,Y.useCallback)(e=>{for(let t of[..._.current])t(e)},[]),y=(0,Y.useCallback)(e=>(_.current.add(e),()=>{_.current.delete(e)}),[]),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useCallback)(e=>{let t=c.current;if(!t)return;let n=C.current;n?n.scrollTo(e):t.scrollTop=e},[]),T=(0,Y.useCallback)(()=>{let e=c.current;if(!e)return;let t=m.current?o.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=m.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?Si(r):0;n?w(e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top-i-12):t>=0&&C.current?C.current.scrollToIndex(t,{align:`start`,offset:-i-12}):w(e.scrollHeight-e.clientHeight)},[w]),E=(0,Y.useCallback)(()=>{if(c.current){if(S.current!==e){S.current=e,m.current=!0;let t=Et(e);t&&!t.atBottom?(p.current=!1,b.current=t.top,x.current=rt(e)?.rowKeys?{viewKey:e,top:t.top}:null):(p.current=!0,b.current=null,x.current=null)}b.current===null?p.current&&T():w(b.current)}},[e,w,T]),D=(0,Y.useCallback)(e=>x.current?.viewKey===e,[]),O=(0,Y.useCallback)(e=>{let t=x.current;return!t||!D(e)||e!==s.current?!1:(b.current=t.top,p.current=!1,x.current=null,!0)},[D]),k=(0,Y.useCallback)(e=>{u(e),e&&(c.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="thread-transcript"], [data-slot="main"]`),E())},[n,E]),A=(0,Y.useCallback)(()=>{p.current&&T()},[T]),M=(0,Y.useRef)(!1),N=(0,Y.useRef)(0),P=(0,Y.useRef)(!1),F=(0,Y.useRef)(void 0),I=(0,Y.useRef)(!1),L=(0,Y.useRef)(!1),R=(0,Y.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),z=(0,Y.useRef)(null),B=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!j())return;let e=e=>{b.current=null,x.current=null,B.current+=1,z.current=null,p.current=!1,m.current=!1,w(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[w]);let ee=(0,Y.useCallback)(()=>{let e=z.current,t=c.current;if(!e||!t)return;z.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:o.current.indexOf(e.anchor.key),a=C.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):w(qe(t.scrollTop,r,e.anchor,R(t),n))},[R,w]),V=(0,Y.useCallback)(()=>{let e=c.current;if(!e||!r||M.current)return;b.current=null,x.current=null,p.current=!1,M.current=!0;let t=N.current+1;N.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,l=Ot(a,R(e)),u=l===void 0?-1:o.current.indexOf(l.key),d=s.current,f=B.current;r().then(()=>{s.current===d&&B.current===f&&(z.current={beforeHeight:n,beforeTop:i,anchor:l,anchorIndex:u})},()=>{}).finally(()=>{N.current===t&&(M.current=!1)})},[R,r]);(0,Y.useEffect)(()=>()=>clearTimeout(F.current),[]);let H=(0,Y.useRef)(null),te=(0,Y.useRef)(0),U=(0,Y.useCallback)(()=>n===`document`?++Z.generation:++te.current,[n]),ne=(0,Y.useCallback)((e,t)=>n===`document`?Z.viewKey===e&&Z.generation===t:s.current===e&&te.current===t,[n]);(0,Y.useEffect)(()=>()=>H.current?.disconnect(),[e,l]);let W=(0,Y.useCallback)((t,n,r,i)=>{let a=c.current;if(!a||!l)return;b.current=null,x.current=null,B.current+=1,z.current=null,p.current=!1,h.current=0,f(!0),U(),H.current?.disconnect();let o=()=>[...l.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=a.querySelector(`[data-slot="run-header"]`),u=s&&getComputedStyle(s).position===`sticky`?Si(s):0,d=(e,t)=>{let r=a.getBoundingClientRect(),o=t.getBoundingClientRect(),s=C.current;if(s&&i===void 0){let t=o.top-e.getBoundingClientRect().top;u+t+o.height>r.height&&s.scrollToIndex(n,{align:`start`,offset:t-u-12})}else(o.top<r.top+u||o.bottom>r.bottom)&&w(a.scrollTop+o.top-r.top-u-12)},m=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e?e.tabIndex=-1:d(e,t),t.focus({preventScroll:!0}),document.activeElement===t?(H.current?.disconnect(),!0):!1},g=C.current;if(i!==void 0)w(i);else if(g)g.scrollToIndex(n,{align:`start`,...u>0?{offset:-u}:{}});else{let e=o();e&&w(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-u)}m()||(H.current=new MutationObserver(()=>{m()}),H.current.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Je(e,{top:i??a.scrollTop,atBottom:!1})},[l,w,e,U]),G=(0,Y.useCallback)(t=>{let n=U(),r=s.current;H.current?.disconnect();let a=c.current;if(!a)return;b.current=null,x.current=null,B.current+=1,z.current=null,p.current=!0,m.current=!0,g.current=0,v({direction:`tail`}),Je(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{p.current&&T()},l=a.closest(`[data-slot="main"]`)??a.closest(`[data-route="task-thread"]`)??a,u=()=>ne(r,n),d=()=>{let e=t?.(l);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!u()||d())return;H.current?.disconnect();let e=new MutationObserver(()=>{u()?d()&&e.disconnect():e.disconnect()});H.current=e,e.observe(l,{childList:!0,subtree:!0})})})})},[i,e,T,U,ne,v]),re=a.at(-1),ie=a.length;return(0,Y.useLayoutEffect)(()=>{B.current+=1,z.current=null,M.current=!1,n===`document`?Z.viewKey!==e&&(Z.viewKey=e,Z.generation+=1):te.current+=1},[e,n]),(0,Y.useLayoutEffect)(()=>{let e=z.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?ee():z.current=null:p.current&&T()},[re,ie,ee,T]),(0,Y.useLayoutEffect)(()=>{!c.current||!l||E()},[l,E]),(0,Y.useEffect)(()=>{let t=c.current,n=l;if(!t||!n)return;h.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,u,d=()=>{m.current&&!st(t,80)&&(p.current=!1),m.current=!1},_=e=>{g.current=Date.now(),d(),u=e},y=()=>{U(),H.current?.disconnect(),b.current=null,x.current=null,B.current+=1,z.current=null,p.current=!1,h.current=0},S=()=>{b.current=null,x.current=null,B.current+=1,z.current=null,h.current=Date.now()},C=e=>{if(e.deltaY!==0)if(_(e.deltaY<0?`up`:`down`),e.deltaY<0){y();let e=!P.current;P.current=!0,clearTimeout(F.current),F.current=setTimeout(()=>{P.current=!1},180),e&&Dt(t)&&V()}else S()},E=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(_(`up`),y(),!e.repeat&&Dt(t)&&V()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(_(`down`),S())},O=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,L.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(m.current=!1,b.current=null,x.current=null,st(t,80)||(y(),S()))},k=()=>{i=!1},A=e=>{I.current=!1,r=e.touches[0]?.clientY??null},j=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(_(`up`),y(),!I.current&&Dt(t)&&(I.current=!0,V())):r!==null&&n<r-1&&(_(`down`),S()),r=n)},M=e=>{if(e===0||!i&&Date.now()-g.current>=Ci)return;let n=e<0?`up`:`down`;!i&&n!==u||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=wi&&(0,pi.flushSync)(()=>v({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},N=()=>{let n=p.current;M(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?y():S()),i&&!L.current&&t.scrollTop<a&&Dt(t)&&(L.current=!0,V()),a=t.scrollTop;let r=st(t,80);r&&b.current===null&&(p.current||Date.now()-h.current<2e3)&&(p.current=!0),!n&&p.current&&v({direction:`tail`}),f(!r),b.current===null&&!D(e)&&Je(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,N,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,A,{passive:!0}),t.addEventListener(`touchmove`,j,{passive:!0}),t.addEventListener(`pointerdown`,O,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,E);let R;if(typeof ResizeObserver<`u`){R=new ResizeObserver(()=>{let e=b.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;w(Math.min(e,n)),n>=e&&(b.current=null)}else p.current&&T()}),R.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&R.observe(r),i&&R.observe(i)}return()=>{t.removeEventListener(`scroll`,N),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,A),t.removeEventListener(`touchmove`,j),t.removeEventListener(`pointerdown`,O),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,E),R?.disconnect()}},[e,l,V,w,T,D,U,v]),{attachContent:k,scrollElRef:c,virtualizerRef:C,restoreMeasurements:O,ownsMeasurementRestore:D,pillVisible:d,jumpToLatest:G,jumpToRow:W,loadOlder:V,restickIfStuck:A,subscribeReaderScroll:y}}function Ei({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,X.jsx)(Di,{runId:e,rows:t,controls:r}):(0,X.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,X.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function Di({runId:e,rows:t,controls:n}){return(0,X.jsx)(Oi,{runId:e,rows:t,controls:n},e)}function Oi({runId:e,rows:t,controls:n}){let r=(0,Y.useRef)(null),i=(0,Y.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,Y.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Y.useState)(()=>rt(e)),[l,u]=(0,Y.useState)(()=>({cache:Ke(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Y.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Y.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Y.useRef)(t.length);f.current=t.length;let p=(0,Y.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Y.useRef)(null),h=(0,Y.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||it(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Y.useState)(0);return(0,Y.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,X.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,X.jsx)(In,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,X.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function ki({onJump:e,pendingQuestions:t=0}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center justify-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-sm hover:text-foreground max-md:size-11 max-md:p-0`,children:[(0,X.jsx)(ze,{"aria-hidden":!0,className:`size-3.5 max-md:size-4`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:yi(t)})]})}function Ai(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function ji(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ai(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function Mi(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var Ni=new WeakMap;function Pi(e,t){let n=Ni.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(Ni.set(e,t),t)}function Fi(e,t){if(t!=null)return e.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===t&&!e.resolved)}function Ii(e,t,n=t,r,i){let a=Fi(n,r),o=i?.pinPendingAskInTranscript!==!1,s=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),c=new Set,l=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),u=[];e.task&&u.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])u.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let d=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===d?Ri(n.items):n.items;u.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:Pi(n.items,ji(e,t.filter(t=>!e.task||!Qn(t,`opening`)).map(e=>e.kind===`ask`&&l.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Mi(e,r,a):e.kind===`permission`?(c.add(e.requestId),s.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let f=[...s.values()].filter(e=>e.status===`pending`&&!c.has(e.requestId));return f.length>0&&u.push({id:`pending-permissions`,entries:f,inDaySequence:!1}),a!==void 0&&o&&u.push({id:mi,entries:[{...a,placement:`pinned`}],inDaySequence:!1}),u}var Li=`changes ready for review`;function Ri(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(Li)))}function zi(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function Bi(e,t){return[{id:`agent:${e}`,entries:t}]}function Vi(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Hi(e,t){let n=[],r;for(let t of e){let e=Vi(t),i=Tt(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of mt(t.entries))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Ui({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Y.useMemo)(()=>Hi(n,e),[n,e]),p=Ti(`${e}:${t}`,{surface:r}),m=c??p;Nr(e,f,m,r);let h=(0,Y.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Y.useMemo)(()=>f.map(t=>({key:t.key,node:Wi(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??et(``,g.length),v=g.length===0?i??null:(0,X.jsx)(Ei,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,X.jsx)(qn,{runId:e,children:(0,X.jsx)(ht,{runId:e,children:(0,X.jsx)(Br.Provider,{value:h,children:r===`panel`?(0,X.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,X.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,X.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,X.jsx)(ki,{onJump:m.jumpToLatest})}):null]}):v})})})}function Wi(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,X.jsx)(Gi,{message:e.content.message,actions:t});case`day-separator`:return(0,X.jsx)(_t,{ts:e.content.ts});case`turn-time`:return(0,X.jsx)(dt,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,X.jsx)(Ki,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Xi(e.content)}}function Gi({message:e,actions:t}){return(0,X.jsx)(lt,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,X.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,X.jsx)(nt,{ask:e.ask})}):void 0})}function Ki({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,X.jsx)(tt.Provider,{value:`${t}:${e.entry.id}`,children:(0,X.jsx)(Ji,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,X.jsx)(gt,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,X.jsx)(qi,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,X.jsx)(pt,{group:e,scope:t});case`streak`:return(0,X.jsx)(wt,{count:e.count,children:e.blocks.map(e=>(0,X.jsx)(Ki,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,X.jsx)(ni,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Xi(e)}}function qi({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return mt(e).map(e=>(0,X.jsx)(Ki,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Ji({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,X.jsx)(xt,{text:e.text,ts:e.ts}):(0,X.jsx)(lt,{text:e.text,ts:e.ts});case`reasoning`:return(0,X.jsx)(ct,{text:e.text});case`tool`:return(0,X.jsx)(gt,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,X.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,X.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${Xr(e.delivery)}`:``]}),(0,X.jsx)(bt,{note:e})]}):(0,X.jsx)(bt,{note:e});case`conversation`:return(0,X.jsx)(ni,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,X.jsx)(yt,{image:e});case`ask`:return n===void 0?(0,X.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,X.jsx)(Lr,{permission:e,runId:i});case`provider-auth-required`:return(0,X.jsx)(St,{incident:e});case`preview-server`:return(0,X.jsx)(Yi,{entry:e});case`hook`:return(0,X.jsx)(ot,{item:e,cacheKey:`${t}:${e.id}`});default:return Xi(e)}}function Yi({entry:e}){let t=Mn(),n=Cn(a().data);return(0,X.jsx)(tr,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function Xi(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Zi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,onBeforeOpenReport:o,onRestoreAgentFocus:s,taskTitles:c,recipientBackends:l}){let u=(0,Y.useContext)(an),d=(0,Y.useRef)(void 0),f=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>()=>{d.current?.()},[u,e]),(0,X.jsx)($t,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,X.jsx)(tn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{f.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,X.jsx)(Ye.Provider,{value:e=>{let t=r?.id,n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);d.current?.(),d.current=u?.registerOpener(e,()=>{if(t&&s){s(t);return}n?.focus({preventScroll:!0})}),f.current=!0,o?.(),a()},children:(0,X.jsx)(Qi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:c,recipientBackends:l})})})})}function Qi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Qt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,X.jsxs)(en,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,X.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,X.jsxs)(rn,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)($i,{status:r.status}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,X.jsx)(Ui,{runId:e,viewId:`agent:${r.id}`,sections:Bi(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,X.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function $i({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,X.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:K(`rounded-full px-2 py-0.5 text-xs font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function ea(e){let t=G(),[n,r]=(0,Y.useState)(),i=g(e);(0,Y.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=w({mutationFn:async()=>{r(e.id);try{if(!(await ue(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:k.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function ta({agents:e,onSelect:t}){return e.length===0?null:(0,X.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,X.jsx)(na,{agent:e,onSelect:t},e.id))})}function na({agent:e,onSelect:t}){let n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ra,{status:e.status,stalled:e.stalled===!0}),(0,X.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,X.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,X.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Cr(e)}),(0,X.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,X.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,X.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,X.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function ra({status:e,stalled:t=!1}){return t?(0,X.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,X.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,X.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function ia(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function aa({entries:e}){return e.length===0?null:(0,X.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,X.jsx)(oa,{entry:e},`${t}:${e.content}`))})}function oa({entry:e}){return(0,X.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:K(`flex min-h-5 min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 text-[13px] [&>svg]:mt-[3px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-disabled-foreground line-through`),children:[(0,X.jsx)(sa,{status:e.status}),(0,X.jsx)(`span`,{"data-slot":`plan-text`,className:`min-w-0 flex-1 basis-40 break-words`,children:e.content}),e.status===`in_progress`?(0,X.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function sa({status:e}){return e===`cancelled`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-disabled-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,X.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,X.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,X.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,X.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ca(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 la(e,t){let n=ca(e);return n===`active`&&t===`waiting`?`paused`:n}function ua(e){return e===`active`?`running`:e}function da(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 fa({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=da(e)*100;return(0,X.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,X.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":la(n.status,t),className:`flex min-h-[22px] min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5 text-[13px] text-muted-foreground [&>svg]:mt-[3px]`,children:[(0,X.jsx)(pa,{visual:la(n.status,t)}),(0,X.jsx)(`span`,{"data-slot":`step-name`,className:`min-w-0 flex-1 basis-32 break-words font-medium text-foreground`,children:n.name}),n.iterations>1?(0,X.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,X.jsxs)(`span`,{"data-slot":`step-meta`,className:`ml-auto max-w-full min-w-0 pl-2 text-right text-xs leading-5 break-words text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,X.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function pa({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,X.jsx)(He,{"aria-hidden":!0,className:K(t,`text-success`)});case`active`:return(0,X.jsx)(Rt,{role:`status`,"aria-label":`Step running`,className:K(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,X.jsx)(Re,{role:`img`,"aria-label":`Step paused`,className:K(t,ma)});case`failed`:return(0,X.jsx)(ke,{"aria-hidden":!0,className:K(t,`text-danger`)});case`pending`:return(0,X.jsx)(Ie,{"aria-hidden":!0,className:K(t,`text-soft-foreground`)})}}var ma=`stroke-pending [html.light_&]:stroke-pending-strong`,ha={done:`done`,failed:`failed`,cancelled:`cancelled`};function ga(e){let t=ha[e.status];return t?e.steps.map(e=>ca(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):_a(e)}function _a(e){let t=va(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function va(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ca(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function ya(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function ba(e){return typeof e==`object`&&!!e&&!(0,Y.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:o,onToggle:s,className:c,children:l}){let u=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,X.jsx)(`span`,{className:K(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(ba(r)?(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,X.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,X.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),d=s!==void 0;return(0,X.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":d&&o?`open`:`collapsed`,className:K(`min-w-0 border-t border-border first:border-t-0`,c),children:[d?(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:s,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[u,a,(0,X.jsx)(Ue,{"aria-hidden":!0,className:K(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,o&&`rotate-180`)})]}):(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[u,a]}),d&&o?(0,X.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:l}):null]})}function xa(e){return ce(e.delegation)}function Sa(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function Ca(e){let t=e.delegation,n=xa(e),r=S(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=Sa(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 wa(e){let t=S(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>v(e.status))}function Ta({run:e,open:t,onToggle:n}){let r=S(e.id),i=b(),a=sn(),o=e.delegation,s=new Map(r.data?.workers.map(e=>[e.workerId,e])),c=Sa(o,r.data),l=fe(e)??V(e),u=l?Ea(e,l):void 0,d=e=>i.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),f=e=>{let t=d(e);return t?p(t):`worker ${e.slice(0,8)}`};return(0,X.jsx)(Q,{slot:`workers`,icon:(0,X.jsx)(Le,{className:`size-4`}),title:`Workers`,meta:Da({ids:c,workers:s,desktop:a,query:r}),aside:r.data?.capacity?(0,X.jsx)(Pa,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,X.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,l?(0,X.jsx)(ja,{wait:l,dependencyLabel:u}):null,c.length>0?(0,X.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:c.map(t=>{let n=s.get(t),i=d(t),a=n?ka(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,X.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,X.jsxs)(Zt,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,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,X.jsx)(Oa,{status:n?.status}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate`,children:i?p(i):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,X.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,f(n.supervisorRunId)]}):null]}),(0,X.jsx)(`span`,{className:K(`max-w-[45%] shrink-0 truncate text-xs`,Aa(n?.status)),children:a}),(0,X.jsx)(Be,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,X.jsx)(Ia,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,X.jsx)(Ba,{state:n.destroy}):null]},t)})}):xa(e)&&r.isSuccess?(0,X.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,X.jsx)(q,{variant:`outline`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function Ea(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return z(e)??W(n.role,t,`requestIds`in t&&U(n,t.requestIds))}function Da({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function Oa({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,X.jsx)(He,{"aria-hidden":!0,className:K(t,`text-semantic-green`)}):e===`failed`?(0,X.jsx)(ke,{"aria-hidden":!0,className:K(t,`text-semantic-red`)}):e===`cancelled`?(0,X.jsx)(Fe,{"aria-hidden":!0,className:K(t,`text-soft-foreground`)}):e===`review`?(0,X.jsx)(Lt,{"aria-hidden":!0,className:K(t,`text-semantic-info`)}):e===`waiting`?(0,X.jsx)(Re,{"aria-hidden":!0,className:K(t,`text-semantic-amber`)}):e===`running`?(0,X.jsx)(Rt,{role:`status`,"aria-label":`Worker running`,className:K(t,`animate-spin stroke-status-running motion-reduce:animate-none`)}):(0,X.jsx)(Ie,{"aria-hidden":!0,className:K(t,`text-soft-foreground`)})}function ka(e){return gn(e)}function Aa(e){return e===`done`?`text-semantic-green`:e===`failed`?`text-semantic-red`:e===`review`?`text-semantic-info`:e===`waiting`?`text-semantic-amber`:`text-muted-foreground`}function ja({wait:e,dependencyLabel:t}){return(0,X.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?dn(`waiting-on-workers`,t):`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting for 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 for workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,X.jsxs)(X.Fragment,{children:[` `,`Deadline: `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function Ma(e){return e.delegation?.role===`worker`&&V(e)?.phase===`wake-pending`}function Na({run:e}){let t=V(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,X.jsx)(ja,{wait:t,dependencyLabel:W(`worker`,t)}):null}function Pa({capacity:e}){return(0,X.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Fa=new Set([`review`,`done`,`failed`,`cancelled`]);function Ia({parentRunId:e,worker:t}){let n=A(e),[r,i]=(0,Y.useState)(!1);if(!Fa.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof L?n.error.work:void 0;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`break-words text-xs`,children:H(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,X.jsx)(q,{variant:`danger-ghost`,size:`sm`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,X.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>i(!1),children:`Cancel`})]}):(0,X.jsx)(q,{variant:`outline`,size:`sm`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,X.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${Ra(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,X.jsx)(q,{variant:`danger-ghost`,size:`sm`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var La=(e,t,n)=>`${e} ${e===1?t:n}`;function Ra(e){return[...e.uncommittedFiles?[La(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${La(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function za(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Ba({state:e}){if(!za(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,X.jsx)(Va,{at:t.nextAt});return(0,X.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,X.jsxs)(X.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,X.jsxs)(X.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Va({at:e}){let t=nn(3e4);return(0,X.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Zn(t,Date.parse(e))})}function Ha({items:e,lead:t=0,room:n,className:r}){let i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(-1/0);return(0,Y.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let a=n?r.closest(n):null,s=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let i=n+Ua(a),s=getComputedStyle(r),c=Number.parseFloat(s.width),l=c>0?n/c:1,u=(Number.parseFloat(s.columnGap)||0)*l,d=Array.from(r.children,e=>e.getBoundingClientRect().width),f=e.map((e,t)=>({...e,width:d[t]??0})),p=-1/0,m=()=>f.reduce((e,t)=>e+t.width,0)+Math.max(0,f.length-1)*u+(f.length>0?t*l:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(m()<=i)break;p=t,f=f.filter(e=>e.priority>t)}o(e=>e===p?e:p)};if(s(),typeof ResizeObserver>`u`)return;let c=new ResizeObserver(s);c.observe(r);for(let e of r.children)c.observe(e);return a&&c.observe(a),()=>c.disconnect()},[e,t,n]),(0,X.jsx)(`span`,{ref:i,"data-slot":`activity-summary`,className:K(`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,r),children:e.map(n=>{let r=n.priority<=a,i=n===e.find(e=>e.priority>a);return(0,X.jsxs)(`span`,{"data-summary-item":n.id,"data-hidden":r,"aria-hidden":r||void 0,inert:r||void 0,style:i&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:[!i||t>0?(0,X.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ua(e){let t=e?.firstElementChild;return!e||!t?0:Math.max(0,e.getBoundingClientRect().width-t.getBoundingClientRect().width)}function Wa({run:e,references:t}){return(0,X.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,X.jsx)(Se,{reference:t,taskTitle:p(e),inert:!0},ve(t)))})}function Ga(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?ln(e.accounts,e.accountBackend)?`default`:void 0:e.known?ln(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Ka(e){let t=T(),n=E(),r=u(),{accounts:i}=cn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,d=c?.backend??a,f=r.data?.profiles.find(e=>e.id===l&&e.provider===d),p=Ga({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:f,accounts:i,accountBackend:d}),m=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?N(t.data,a):B(e.removedRunner),...p?{account:p}:{},model:o,effort:s,...m?{identity:m}:{}}}var qa=[`running`,`queued`,`waiting`];function Ja(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function $(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function Ya(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function Xa(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Za(e){let t=Ja(e.waits),n=qa.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&Xa(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Ja(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Qa(e){return Za(e)!==void 0}function $a(e){return(Za(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function eo({run:e}){let t=Za(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,X.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,X.jsx)(no,{run:e,wait:t},t.id):t.kind===`worker`?(0,X.jsx)(ro,{wait:t},t.id):t.kind===`process`?(0,X.jsx)(lo,{run:e,wait:t},t.id):t.kind===`peer`?(0,X.jsx)(io,{wait:t},t.id):t.kind===`subagent`?(0,X.jsx)(ao,{wait:t},t.id):t.kind===`plugin`?(0,X.jsx)(oo,{run:e,wait:t},t.id):(0,X.jsx)(so,{run:e,wait:t},t.id)),i?(0,X.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,X.jsx)(no,{run:e,wait:r,settled:!0}):null,a?(0,X.jsx)(lo,{run:e,wait:a,settled:!0}):null]})}function to(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha?Sn(r.headSha):`unknown`} → ${r?.observedHeadSha?Sn(r.observedHeadSha):`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Ya(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function no({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,a=n&&t.phase===`cancelled`,o=to(e,t,n),s=n?a?t.cancelledAt:r?.observedAt:t.deadline,c=$(s),l=`${t.repository}#${t.prNumber}`;return(0,X.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,X.jsx)(`dd`,{children:o}),(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,X.jsx)(`dd`,{className:`min-w-0`,children:Te(t.prUrl)?(0,X.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:l}):(0,X.jsx)(`span`,{children:l})}),c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?a?`Cancelled`:`Observed`:`Deadline`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`time`,{dateTime:s,children:c})})]}):n?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,X.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function ro({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,r,` `,i]}),a?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,X.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function io({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`task`:`tasks`]}),n?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,X.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function ao({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,X.jsxs)(`p`,{children:[`Check by`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,X.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function oo({run:e,wait:t}){let n=t.phase===`open`?$(t.deadline):void 0;return(0,X.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`p`,{children:t.phase===`resolved`?Ya(t.summary,e):t.summary}),n?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function so({run:e,wait:t}){let n=$(t.deadline);return(0,X.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,X.jsx)(`p`,{children:Ya(`Automatic check due`,e)}):n?(0,X.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,X.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,X.jsx)(`p`,{children:t.note}):null]})}function co(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function lo({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?co(t):t.phase===`resolved`?Ya(co(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?$(t.deadline):void 0;return(0,X.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`p`,{children:r}),i?(0,X.jsxs)(`p`,{children:[`Until`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var uo=new Map,fo=new Map;function po(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=Nt(e.run);return(0,X.jsx)(be,{projectId:t,repoBase:n,requests:i,children:(0,X.jsx)(mo,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!Ce(e.run)||!!we(e.run,n)})})}function mo({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,presentation:s=`card`,prNumbers:c,hasReferences:l,references:u}){let d=sn(),f=Ka(e),[p,m]=(0,Y.useState)(()=>i?!1:uo.get(e.id)??!1),h=jo(o,p),g=s===`panel`||h.open,[_,v]=(0,Y.useState)({}),y=go(e,t??n,n,r,c),b=At(e),x=t=>_[t]??fo.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);fo.set(`${e.id}:${t}`,n),v(e=>({...e,[t]:n}))},C=e=>({open:x(e),onToggle:()=>S(e)}),w=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,X.jsx)(wo,{run:e,activity:y,...C(`status`)}),(0,X.jsx)(To,{run:e,desktop:d,automations:y.automations,...C(`workflow`)}),(0,X.jsx)(Eo,{activity:y,desktop:d,onOpenWorker:a,...C(`subagents`)}),(0,X.jsx)(Do,{run:e,...C(`workers`)}),(0,X.jsx)(Oo,{activity:y,desktop:d,...C(`plan`)}),(0,X.jsx)(ko,{run:e,identity:f,activity:y,...C(`usage`)}),(0,X.jsx)(Ao,{run:e,references:u,conflicts:y.conflicts,hasReferences:l,onResume:()=>b.mutate(),...C(`workspace`)})]});return s===`panel`?(0,X.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-presentation":`panel`,"data-state":`open`,"aria-label":`Session activity`,className:`flex min-w-0 flex-col bg-card`,children:[(0,X.jsxs)(`div`,{className:`sticky inset-bs-0 z-10 flex items-center gap-2 bg-card px-3.5 py-2.5 text-[13px]`,children:[(0,X.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Session activity`}),y.cost?(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums`,children:y.cost}):null]}),w]}):(0,X.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:h.ref,"data-state":g?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,X.jsx)(xo,{run:e,identity:f,activity:y,references:u,open:g,onToggle:()=>{uo.set(e.id,!g),m(!g),h.chose(!g)}}),g?w:null]})}function ho(e,t,n,r){let i=a(),o=Pn(i.data),c=b(),l=Ft(e,{queuePosition:e.status===`queued`?d(c.data??[]).get(e.id):void 0}),u=!s(e)&&e.status!==`queued`,f=(0,Y.useMemo)(()=>r?br(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),p=rr(n)??[],m=Ca(e),h=Sr(f),g=ia(p);return{health:i,line:l,..._o(e,l,m,r?h:void 0,g),...vo(e,o),agents:f,agentCounts:h,planEntries:p,planCounts:g}}function go(e,t,n,r,i){let a=ho(e,t,n,r),o=xe(i);return{...a,conflicts:o,waitReferences:$a(e),automations:xn(a.health.data)}}function _o(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`,glyph:o?(0,X.jsx)(He,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,X.jsx)(J,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function vo(e,t){return{cost:t.cost&&e.costUsd!==void 0?ye(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,X.jsx)(Rn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function yo(e){return e.allComplete?`text-semantic-green`:e.failed&&`text-semantic-red`}function bo(e){let t=ga(e),n=va(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function xo({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:o}=n,s=[...new Map([...r,...n.waitReferences].map(e=>[ve(e),e])).values()];return(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":So(e,t,n,s,i),onClick:a,className:K(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,X.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,X.jsx)(Co,{run:e,identity:t,activity:n,summaryReferences:s}),i&&o?(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:o}):null,(0,X.jsx)(Ue,{"aria-hidden":!0,className:K(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!o&&`ms-auto`,i&&`rotate-180`)})]})}function So(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=bo(e)?.step,u=l?`; step ${l.name}, ${ua(la(l.status,e.status))}`:``,d=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${u}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${d}`}function Co({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:o}=n,s=bo(e)?.step,c=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||o.length?[{id:`chips`,priority:0,content:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Wa,{run:e,references:r}),o.length>0?(0,X.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,X.jsx)(Me,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:K(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,yo(n)),children:[n.glyph,(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),s?(0,X.jsxs)(`span`,{"data-slot":`run-activity-step`,className:K(`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,e.status===`waiting`&&`max-md:hidden`),children:[(0,X.jsx)(Fo,{step:s,runStatus:e.status,decorative:!0}),(0,X.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:s.name,className:`min-w-0 truncate`,children:s.name})]}):null,(0,X.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,X.jsx)(Ha,{items:c,lead:8})})]})}function wo({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,o=Ma(e);return(0,X.jsxs)(Q,{slot:`status-row`,icon:t.glyph,title:(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{"data-slot":`run-activity-status`,className:K(`truncate`,yo(t)),children:t.statusText}),i.nextCheck?(0,X.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,X.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,X.jsx)(Ha,{items:[{id:`chips`,priority:0,content:(0,X.jsx)(Wa,{run:e,references:a})}]}):void 0,open:n,onToggle:Qa(e)||o?r:void 0,children:[(0,X.jsx)(eo,{run:e}),o?(0,X.jsx)(Na,{run:e}):null]})}function To({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=_e(e),o=bo(e);return!a&&!o?null:(0,X.jsxs)(Q,{slot:`workflow`,icon:o?(0,X.jsx)(Fo,{step:o.step,runStatus:e.status}):(0,X.jsx)(Pe,{className:`size-4`}),title:(0,X.jsxs)(X.Fragment,{children:[`Workflow`,a?(0,X.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:ya(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,X.jsx)(fa,{steps:o.steps,runStatus:e.status}):null,(0,X.jsx)(Po,{run:e,available:n})]})}function Eo({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,X.jsx)(Q,{slot:`subagents`,icon:(0,X.jsx)(je,{className:`size-4`}),title:`Subagents`,meta:ya(o.done,o.total,t),open:r,onToggle:i,children:(0,X.jsx)(ta,{agents:a,onSelect:n})})}function Do({run:e,open:t,onToggle:n}){return xa(e)?(0,X.jsx)(Ta,{run:e,open:t,onToggle:n}):null}function Oo({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,X.jsx)(Q,{slot:`plan`,icon:(0,X.jsx)(Oe,{className:`size-4`}),title:`Plan`,meta:ya(a.done,a.total,t),open:n,onToggle:r,children:(0,X.jsx)(aa,{entries:i})})}function ko({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,X.jsx)(Q,{slot:`usage`,icon:(0,X.jsx)(ir,{className:`size-4`}),title:`Usage & agent`,summary:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,X.jsx)(Ha,{items:c})}),open:r,onToggle:i,children:(0,X.jsx)(No,{run:e,tokens:o,cost:a})})}function Ao({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||Wn(e)||za(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,X.jsx)(Q,{slot:`workspace`,icon:(0,X.jsx)(Le,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,X.jsx)(Ha,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,X.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,X.jsx)(Wa,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,X.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,X.jsx)(Me,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,X.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,X.jsx)(Ba,{state:s}):null,(0,X.jsx)(Pt,{run:e}),e.branch?(0,X.jsx)(Mo,{label:`Branch`,children:(0,X.jsx)(Mt,{branch:e.branch})}):null,e.worktreePath?(0,X.jsx)(Mo,{label:`Worktree`,children:(0,X.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,X.jsx)(jt,{run:e,canResume:On(e).terminal,onResume:i})]})})}function jo(e,t){let n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(t);a.current=t;let o=(0,Y.useRef)({active:!1,override:!1});return(0,Y.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function Mo({label:e,children:t}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function No({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Ka(e);return(0,X.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,X.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,X.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Po({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,X.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,X.jsx)(Zt,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:K(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,X.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Fo({step:e,runStatus:t,decorative:n=!1}){let r=la(e.status,t),i=`size-4 shrink-0`;switch(r){case`active`:return(0,X.jsx)(Rt,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:K(i,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,X.jsx)(Re,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:K(i,ma)});case`failed`:return(0,X.jsx)(ke,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:K(i,`text-danger`)});case`pending`:return(0,X.jsx)(Ie,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:K(i,`text-soft-foreground`)});case`done`:return(0,X.jsx)(He,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:K(i,`text-success`)})}}function Io(e,t,n,r){let i=ho(e,t,n,r),a=xa(e),o=S(e.id,{enabled:a}),s=(0,Y.useMemo)(()=>{let t=e.delegation?.role===`root`?e.delegation.receipts.map(e=>e.workerId):[],n=o.data?.workers.map(e=>e.workerId)??[];return new Set([...t,...n]).size},[e.delegation,o.data?.workers]),c=ga(e),l=c.length>0?c[va(e.currentStepId,c)]:void 0;return{statusText:i.statusText,glyph:i.glyph,allComplete:i.allComplete,failed:i.failed,activeStepName:l?.name,shownStepName:l&&la(l.status,e.status)!==`done`?l.name:void 0,workerCount:s,agentCounts:i.agentCounts,cost:i.cost,nextCheckText:i.line.nextCheck?.text,line:i.line}}function Lo(e,t){let n=[`Session activity: ${e.statusText}`];return e.nextCheckText&&n.push(`Next check ${e.nextCheckText}`),e.activeStepName&&n.push(`step ${e.activeStepName}`),e.workerCount>0&&n.push(`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`),e.agentCounts.total>0&&n.push(`${e.agentCounts.done}/${e.agentCounts.total} subagents`),e.cost&&n.push(`cost ${e.cost}`),t===`sidebar`&&n.push(`toggle activity sidebar`),n.join(`; `)}function Ro({props:e,align:t,sideOffset:n,collisionPadding:r=0,contentClassName:i,children:a}){let{run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u,open:d,onOpenChange:f,keepOpen:p=!1,onOpenAutoFocus:m}=e,h=e=>{p&&e.preventDefault()};return(0,X.jsxs)(Yt,{open:d,onOpenChange:e=>{!e&&p||f(e)},children:[(0,X.jsx)(Kt,{asChild:!0,children:a}),(0,X.jsx)(Jt,{align:t,sideOffset:n,collisionPadding:r,"data-slot":`run-activity-popover`,className:i,onOpenAutoFocus:m,onInteractOutside:h,onPointerDownOutside:h,onFocusOutside:h,onEscapeKeyDown:h,children:(0,X.jsx)(po,{presentation:`panel`,run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u})})]})}function zo(e,t=!1){let n=t?`${e.workerCount}w`:`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`,r=`${e.agentCounts.done}/${e.agentCounts.total}${t?``:` agents`}`;return[...e.shownStepName?[{id:`step`,priority:0,content:(0,X.jsx)(`span`,{"data-slot":`run-activity-step`,className:K(`truncate`,t?`max-w-[96px]`:`max-w-[140px]`),children:e.shownStepName})}]:[],...e.workerCount>0?[{id:`workers`,priority:3,content:(0,X.jsx)(`span`,{"data-slot":`activity-workers-badge`,children:n})}]:[],...e.agentCounts.total>0?[{id:`subagents`,priority:2,content:(0,X.jsx)(`span`,{"data-slot":`activity-subagents-badge`,children:r})}]:[],...e.cost?[{id:`cost`,priority:1,content:(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`font-mono text-xs`,children:e.cost})}]:[]]}function Bo(e){let{run:t,thread:n,currentThread:r,currentComplete:i,mode:a,open:o,onOpenChange:s}=e,c=Io(t,n,r,i),l=Lo(c,a),u=c.allComplete?`text-semantic-green`:c.failed?`text-semantic-red`:`text-foreground`,d=(0,X.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger`,"data-activity-mode":a,"aria-expanded":o,"aria-label":l,onClick:a===`sidebar`?()=>s(!o):void 0,className:K(`inline-flex min-h-9 max-w-full items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-[12px] font-medium text-foreground shadow-xs transition-colors`,`pointer-hover:bg-muted/60 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,o&&`border-accent-strong/60`),children:[(0,X.jsxs)(`span`,{"data-slot":`pill`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[c.glyph,(0,X.jsx)(`span`,{"data-slot":`run-activity-status`,className:u,children:(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,children:c.statusText})})]}),(0,X.jsx)(`span`,{className:`-ms-2 grid min-w-0 grid-cols-[minmax(0,max-content)]`,children:(0,X.jsx)(Ha,{items:zo(c),lead:8,room:`[data-slot='run-status-slot']`})}),(0,X.jsx)(Ue,{"aria-hidden":`true`,className:K(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,o&&`rotate-180`)})]});return(0,X.jsx)(`span`,{"data-slot":`run-status-slot`,className:`hidden`,children:a===`sidebar`?d:(0,X.jsx)(Ro,{props:e,align:`end`,sideOffset:6,contentClassName:`w-[380px] max-w-[calc(100vw-2rem)] max-h-[min(70dvh,540px)] overflow-y-auto overscroll-contain p-0`,children:d})})}var Vo=`[data-slot='mobile-status-room']`;function Ho(e){let{run:t,thread:n,currentThread:r,currentComplete:i,open:a}=e,o=Io(t,n,r,i),s=pe(),c=Lo(o,`popover`),{attention:l}=o.line;return(0,X.jsx)(Ro,{props:e,align:`start`,sideOffset:10,collisionPadding:8,contentClassName:`w-[420px] max-w-[calc(100vw-1rem)] max-h-[min(65dvh,460px)] overflow-y-auto overscroll-contain p-0`,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger-mobile`,"aria-expanded":a,"aria-label":c,className:K(`-mt-[18px] -mb-2 inline-flex h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md pt-[18px] pb-2 text-start md:hidden`,`focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-ring`),children:[(0,X.jsx)(An,{"data-slot":`mobile-run-status`,dot:l.tone,shape:l.shape,pulse:l.pulse&&!s,className:`min-w-0 px-2 py-px text-xs leading-4`,children:(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`truncate`,children:o.line.label})}),(0,X.jsx)(`span`,{className:`-ms-1.5 grid min-w-0 shrink-[1000] grid-cols-[minmax(0,max-content)]`,children:(0,X.jsx)(Ha,{items:zo(o,!0),lead:6,room:Vo,className:`h-[18px] gap-1.5 text-xs`})}),(0,X.jsx)(Ue,{"aria-hidden":`true`,className:K(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,a&&`rotate-180`)})]})})}var Uo=2e3;function Wo(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Go(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Ko(e,t){let n=G(),r=(0,Y.useMemo)(()=>Wo(t),[t]),i=(0,Y.useMemo)(()=>Go(t),[t]),a=e?.id,o=e?.status;(0,Y.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:k.runs.detail(a)}),n.invalidateQueries({queryKey:k.runs.list()})},Uo);return()=>clearTimeout(e)},[r,i,a,o,n])}function qo(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Jo({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Y.useState)(void 0),s=(0,Y.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Y.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=zi(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,qo);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}var Yo=12;function Xo({run:e}){let t=G(),n=w({mutationFn:()=>ie(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:k.runs.detail(e.id)}),t.invalidateQueries({queryKey:k.runs.list()}),re(`This task will not resume itself`)},onError:e=>re(e.message,{tone:`danger`})});if(!F(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,X.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,X.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,X.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Yo,`)`]}):(0,X.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,X.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,X.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,X.jsx)(he,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Zo(e){let t=e?.id,[n,r]=(0,Y.useState)(void 0),i=!sn();return{phone:i,folded:i&&t!==void 0&&n===t,open:(0,Y.useCallback)(()=>(0,pi.flushSync)(()=>r(void 0)),[]),setFolded:(0,Y.useCallback)(e=>{(0,pi.flushSync)(()=>r(e?t:void 0))},[t])}}function Qo(e,t){if(e.phone)return{folded:e.folded,onFoldChange:n=>{e.setFolded(n),t.current?.querySelector(n?`[data-slot="ask-folded-row"]`:`[data-slot="ask-fold"]`)?.focus({preventScroll:!0})}}}function $o({pinnedAskId:e,run:t,askModeState:n,replyPending:r,composerPending:i,folded:a}){let o=e!==void 0,s=Dn(t,o),c=n.askId===e?n.mode:`options`;return{hasPendingAsk:o,isReviewGate:s,askMode:c,decisionMode:o?`ask`:s?`review`:`composer`,unifiedReplyActive:o&&c===`reply`&&!a,composerHidden:s||o&&(c===`options`||a),optionDeliveryPending:o&&r&&!i}}function es(e){let{run:t,thread:n,pinnedAsk:r,pendingQuestions:i,scroll:a,onJump:o,onShowOrigin:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,removedRunnerNotice:b,fold:x}=e,S=(0,Y.useRef)(null),C=On(t,wa(t)).cancel,[w,T]=(0,Y.useState)({askId:r?.id,mode:`options`}),[E,D]=(0,Y.useState)(!1),O=e=>T({askId:r?.id,mode:e}),{hasPendingAsk:k,isReviewGate:A,askMode:j,decisionMode:M,unifiedReplyActive:N,composerHidden:P,optionDeliveryPending:F}=$o({pinnedAskId:r?.id,run:t,askModeState:w,replyPending:_.isPending,composerPending:E,folded:x.folded});return(0,X.jsxs)(`div`,{ref:S,"data-slot":`thread-dock`,"data-pending-ask":h||void 0,"data-decision-mode":M,className:K(`relative z-10 shrink-0 bg-background py-1.5 md:pt-2.5 md:pb-4`,A&&`py-0 md:pt-0 md:pb-0`),children:[a.pillVisible?(0,X.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center max-md:justify-end`,children:(0,X.jsx)(ki,{pendingQuestions:i,onJump:()=>{i>0&&x.open(),o()}})}):null,(0,X.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:K(`mx-auto flex w-full min-w-0 max-w-[var(--measure)] flex-col px-[14px] md:px-16`,N?`gap-0`:`gap-1.5 md:gap-2`),children:[A?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xo,{run:t}),(0,X.jsx)(ts,{run:t,sessionOpen:c,attention:l,queued:u,continuable:d,startsNewConversation:f.startsNewConversation,removedRunnerNotice:b})]}),r===void 0?null:(0,X.jsx)(Ct,{ask:{...r,placement:`pinned`},run:t,surface:`decision-zone`,mode:j,onModeChange:O,hideReplyBody:!0,delivery:_,onShowOrigin:s,onStop:C?p.stop:void 0,stopping:p.stopping,onFinish:En(t)?()=>m.mutateAsync():void 0,finishing:m.isPending,fold:Qo(x,S)},r.id),(0,X.jsx)(`div`,{"data-slot":`thread-composer-slot`,hidden:P,className:K(`min-w-0 w-full`,P&&`hidden`,N&&`rounded-b-xl border border-t-0 border-accent-strong/30 bg-accent-strong/[0.04] p-2.5 [html:not(.light)_&]:bg-card`),children:(0,X.jsx)(is,{run:t,thread:n,canStop:C,hasPendingAsk:k,composerHidden:P,optionDeliveryPending:F,onComposerPendingChange:D,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,sessionOpen:c})})]})]})}function ts({run:e,sessionOpen:t,attention:n,queued:r,continuable:i,startsNewConversation:a,removedRunnerNotice:o}){if(e.status===`waiting`&&t)return(0,X.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:n.tone,shape:n.shape,pulse:n.pulse}),n.bucket===`permission`?`Choose an approval option above to continue`:n.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${pn(e,n).label} — you can send a message to resume`]});if(e.status===`running`){let t=Ft(e,{}),n=ga(e),r=n.length>0?n[va(e.currentStepId,n)]:void 0;return(0,X.jsxs)(`div`,{"data-slot":`running-hint`,className:`flex min-w-0 items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse}),(0,X.jsxs)(`span`,{className:`truncate`,children:[t.label,r?` · ${r.name}`:``]})]})}return r?(0,X.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):o===void 0?i&&a?(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null:(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:o})}function ns(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function rs(e,t){let{run:n,hasPendingAsk:r,optionDeliveryPending:i,continuable:a,continueAction:o,queued:s,sendMessage:c,reply:l,providerBlocked:u,providerReason:d,sessionOpen:f}=e,p=async(e,t)=>{let n=await l.send(e,t);if(n!==void 0)throw Error(n)};return r?{onSubmit:p,pendingLabel:l.mode===`resume`?`Continuing…`:`Sending…`,disabled:u||l.blockedBy!==void 0||i,disabledReason:u?d:i?`Sending your answer…`:l.reason,placeholder:t?`Reply`:`Reply — / for skills, @ for files…`}:{onSubmit:a?(e,t)=>o.continueWith(e,t??[]):s?(e,t)=>c.mutateAsync({text:e,images:t}):p,pendingLabel:a?`Continuing…`:`Sending…`,disabled:u||!f&&!s&&!a,disabledReason:u?d:`Session closed — no session to resume.`,placeholder:(t?os:ss)(n,s,a)}}function is(e){let{run:t,thread:n,canStop:r,hasPendingAsk:i,composerHidden:a,onComposerPendingChange:o,stopAction:s,finishAction:c,attention:l,needsAnswer:u,continuable:d,continueAction:f,providerBlocked:p}=e,m=!sn(),h=rs(e,m),g=!i&&d&&!u;return(0,X.jsx)(zn,{...ns(t,d,f),onPendingChange:o,onStop:r?s.stop:void 0,onFinish:En(t)?()=>c.mutateAsync().catch(()=>void 0):void 0,finishing:c.isPending,stopOnEmpty:!i&&as(t,l,u),stopping:s.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:h.pendingLabel,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:!i&&d?f.pills:void 0,onSubmit:h.onSubmit,disabled:h.disabled,disabledReason:h.disabledReason,footerEnd:p&&!f.providerPending?(0,X.jsx)(Zt,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:g,emptySubmitVariant:t.status===`review`?`outline`:`primary`,emptySubmitLabel:g?`Continue`:void 0,placeholder:h.placeholder,autocompleteSkills:!0,phoneRest:m,quickReplies:!a,getMentionCandidates:()=>nr(n)})}function as(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function os(e,t,n){return t?`Add to the prompt`:n?`Add a prompt…`:e.status===`waiting`?`Reply`:`Message the agent`}function ss(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function cs(){let{id:e}=me(),t=l(e),n=Vt(e),r=t.data?.status,i=(0,Y.useMemo)(()=>er(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,Y.useMemo)(()=>er(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,Y.useRef)(void 0),s=(0,Y.useCallback)(e=>{o.current=e},[]),{mutate:c}=m();if((0,Y.useEffect)(()=>{t.data&&o.current!==t.data.id&&P(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Ko(t.data,n.visibleEvents),t.isPending)return(0,X.jsx)(Un,{});if(t.isError){let e=t.error instanceof L&&t.error.status===404;return(0,X.jsx)(on,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,X.jsx)(un,{icon:e?(0,X.jsx)(Bt,{}):(0,X.jsx)(kt,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,X.jsx)(q,{asChild:!0,variant:`outline`,children:(0,X.jsx)(Zt,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,X.jsx)(Un,{}):(0,X.jsx)(us,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var ls=e=>({titles:Object.fromEntries(e.map(e=>[e.id,p(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function us({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:a}){Xt();let o=I({queryKey:k.runs.list(),queryFn:({signal:e})=>te(O(),{signal:e}),select:ls}),{pendingAsk:s,transcriptAsk:l,pendingAskId:u,historyLoading:d}=hs(r,n),f=ne(e),p=$n(e.status,e.error,t),m=Ln(e),h=!m&&e.status!==`queued`,g=e.status===`queued`,_=ur(e),v=ea(e),y=Xn(e.id),b=l||R(e),{hasContinuation:x,continuable:S}=gs(m,g,_),{openAgentId:C,setOpenAgentId:w,activityMode:T,activityOpen:E,setActivityOpen:D,showActivitySidebar:A,closeActivityPopover:j}=ps(e.id),M=(0,Y.useRef)(void 0),N=(0,Y.useCallback)(e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(t=>t.dataset.agentId===e);if(t){t.focus({preventScroll:!0});return}M.current=e,D(!0)},[D]),P=(0,Y.useCallback)(e=>{let t=M.current;if(!t)return;M.current=void 0;let n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);n&&(e.preventDefault(),n.focus({preventScroll:!0}))},[]),{openAgent:F,openAgentChildren:L}=ds(C,n,t,h),z=i(e.id),B=Bn(e),{providerBlocked:V,providerReason:H}=_s(m,yn(e),x,_),U=ms(e,g),W=d?void 0:u??null,G=(0,Y.useMemo)(()=>Fi(n,W),[n,W]),re=G?.questions.length??0,ie=Zo(G),ae=ie.open,oe=(0,Y.useMemo)(()=>Ii(e,t,n,W,{pinPendingAskInTranscript:!1}),[e,t,n,W]),se=(0,Y.useMemo)(()=>Hi(oe,e.id),[oe,e.id]),{taskTitles:ce,recipientBackends:le}=fs(e,o.data),ue=(0,Y.useCallback)(t=>(0,X.jsx)(Lr,{permission:t,runId:e.id,sessionOpen:m}),[e.id,m]),de=S&&e.removedRunner!==void 0?ee(e.removedRunner):void 0,fe=we(e,c()),{search:pe}=ge(),me=et(pe,se.length),he=Ti(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:se.map(({key:e})=>e)}),_e=Jo({pendingAskId:u,askSeq:r?s?.seq:void 0,rows:se,history:r,jumpToRow:he.jumpToRow}),ve=(0,Y.useRef)(u);d||(ve.current=u);let ye=xi(),be=(0,Y.useRef)({reveal:_e.reveal});be.current={reveal:_e.reveal};let xe=(0,Y.useCallback)(()=>{ae(),_i(ye.current??document.body)?.focus({preventScroll:!0})},[ye,ae]),Se=(0,Y.useCallback)(t=>t.placement===`origin`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.context?(0,X.jsx)(vt,{text:t.context}):null,t.resolved?null:(0,X.jsx)(bi,{onGoToQuestion:xe})]}):(0,X.jsx)(Ct,{ask:t,run:e,onShowOrigin:()=>be.current.reveal()}),[e,xe]);qt(he.restickIfStuck);let Ce=r?.currentComplete??!0,K={run:e,thread:t,currentThread:n,currentComplete:Ce,onOpenWorker:w,mode:T,open:E,onOpenChange:D,keepOpen:C!==void 0,onOpenAutoFocus:P};return(0,X.jsxs)(on,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,fillHeight:!0,flushPadding:!0,rootRef:ye,rootProps:{"data-run-id":e.id},className:`overflow-clip`,children:[(0,X.jsx)(It,{run:e,onMarkedUnread:()=>a?.(e.id),desktopActivitySlot:(0,X.jsx)(Bo,{...K}),mobileActivitySlot:(0,X.jsx)(Ho,{...K})}),(0,X.jsxs)(`div`,{"data-slot":`thread-workspace`,children:[(0,X.jsxs)(`div`,{"data-slot":`thread-main`,children:[(0,X.jsx)(`div`,{"data-slot":`thread-transcript`,role:`region`,"aria-label":`Session transcript`,tabIndex:0,children:(0,X.jsx)(vs,{run:e,thread:t,history:r,footer:p,issueUrl:fe,sections:oe,renderAsk:Se,renderPermission:ue,messageActions:U,scroll:he,mode:me,taskTitles:ce,recipientBackends:le})}),(0,X.jsx)(es,{run:e,thread:t,pinnedAsk:G,pendingQuestions:re,scroll:he,onJump:()=>{let e=re>0?G?.id:void 0;he.jumpToLatest(e===void 0?void 0:vi(e,()=>ve.current===e))},onShowOrigin:()=>be.current.reveal(),sessionOpen:m,attention:f,queued:g,continuable:S,continueAction:_,stopAction:v,finishAction:y,needsAnswer:b,sendMessage:z,reply:B,providerBlocked:V,providerReason:H,removedRunnerNotice:de,fold:ie})]}),A?(0,X.jsx)(`aside`,{"data-slot":`thread-activity-sidebar`,"aria-label":`Session activity`,children:(0,X.jsx)(po,{presentation:`panel`,run:e,thread:t,currentThread:n,currentComplete:Ce,onOpenWorker:w})}):null]}),(0,X.jsx)(Zi,{runId:e.id,renderAsk:Se,renderPermission:ue,agent:F,entries:L,taskTitles:ce,recipientBackends:le,onBeforeOpenReport:j,onRestoreAgentFocus:N,onClose:()=>w(void 0)})]})}function ds(e,t,n,r){return{openAgent:(0,Y.useMemo)(()=>e===void 0?void 0:Tr(t.turns,e,r,n.turns),[t.turns,e,r,n.turns]),openAgentChildren:(0,Y.useMemo)(()=>e===void 0?[]:Or(n.turns,t.turns,e),[n.turns,t.turns,e])}}function fs(e,t){let n=e.delegation?.role===`root`||e.delegation?.role===`worker`,r=S(e.id,{enabled:n});return{taskTitles:(0,Y.useMemo)(()=>({...Hr(e,void 0,r.data?.titles),...t?.titles,[e.id]:p(e)}),[e,t,r.data]),recipientBackends:(0,Y.useMemo)(()=>({...t?.backends,...Vr(e,void 0)}),[e,t])}}function ps(e){let[t,n]=(0,Y.useState)(void 0),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!0),[s,c]=(0,Y.useState)(e);s!==e&&(c(e),n(void 0),i(!1));let l=Mn(),u=jn()||l?.open===!0,d=Vn(`(min-width: 1600px)`,!1)&&!u?`sidebar`:`popover`;return{openAgentId:t,setOpenAgentId:n,activityMode:d,activityOpen:d===`sidebar`?a:r,setActivityOpen:d===`sidebar`?o:i,showActivitySidebar:d===`sidebar`&&a,closeActivityPopover:(0,Y.useCallback)(()=>i(!1),[])}}function ms(e,t){let{mutateAsync:n}=h(e.id),{mutateAsync:r}=f(e.id),{mutateAsync:i}=_(e.id);return(0,Y.useMemo)(()=>{if(!t)return;let a={task:{onEdit:async e=>{await n({task:e})},editLabel:`Edit the prompt`}};for(let t of e.queuedMessages??[])a[`queued:${t.id}`]={onEdit:e=>r({msgId:t.id,message:{text:e}}).then(()=>void 0),onRemove:()=>i(t.id).then(()=>void 0)};return a},[t,e.queuedMessages,n,r,i])}function hs(e,t){let n=e?zt(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function gs(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function _s(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function vs({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:a,renderAsk:o,renderPermission:s,messageActions:c,scroll:l,mode:u,taskTitles:d,recipientBackends:f}){let p=kn()===`changes`;return(0,X.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,X.jsx)(ys,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:l.loadOlder}):null,(0,X.jsx)(Ui,{runId:e.id,viewId:`main`,sections:a,mode:`document`,renderAsk:o,renderPermission:s,messageActions:c,scrollControls:l,renderMode:u,taskTitles:d,recipientBackends:f}),t.turns.length===0?e.status===`queued`?(0,X.jsx)(bs,{run:e}):(0,X.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,X.jsx)(ut,{}):null,r&&r.state===`closed`?(0,X.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:K(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[r.label,Te(Ce(e))?(0,X.jsx)(`a`,{"data-slot":`pr-link`,href:Ce(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,Te(i)?(0,X.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`&&!p?(0,X.jsx)(Jn,{runId:e.id}):null]})}function ys({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,X.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,X.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-xs text-soft-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,X.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function bs({run:e}){let t=Hn(b().data??[],e.id);return(0,X.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,X.jsx)(J,{tone:`neutral`,shape:`ring`}),(0,X.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,X.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{cs as TaskThreadRoute};
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Li as t,li as n,ui as r}from"./project-scope-context-DNrHbqd2.js";import{h as i,p as a,v as o}from"./live-protocol-CNUmr-VT.js";import{o as s}from"./dist-CCX8mhHc.js";import{t as c}from"./app-window-CSHwDX9N.js";import{t as l}from"./play-CmVAj_fu.js";import{i as u,n as ee,o as te,r as ne}from"./tool-display-CTbToGmi.js";import{r as re}from"./preview-D3zYSmIA.js";import{t as ie}from"./square-terminal-B6RYYieR.js";import{t as ae}from"./button-BV_AiLj2.js";import{t as oe}from"./status-dot-Da1M54kK.js";import{a as se,o as ce}from"./format-BU7D3IfE.js";import{f as d,p as f,vr as p}from"./index-C3kap2_j.js";var m=e(),h={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function g(e){let{text:t,...n}=f(e),r={...n,status:t},i=h[e.state](e);return i?{...r,action:i}:r}var _={"Run and open":l,Open:c,View:p,"Start again":te};function v({entry:e,inPreview:t,onOpen:n}){let{server:r}=e,i=g(e),a=e.state===`unavailable`,o=n?i.action:void 0,c=d(r.command),l=se(r.registeredAt);return(0,m.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:s(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,a&&`text-muted-foreground`),children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,m.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,m.jsx)(re,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),a?(0,m.jsx)(`span`,{children:`worktree removed`}):l?(0,m.jsx)(`span`,{children:ce(l)}):null]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,m.jsx)(oe,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse===!0,"aria-hidden":`true`}),(0,m.jsx)(`span`,{className:`font-semibold text-foreground`,children:r.label}),(0,m.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,r.port]}),(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:i.status})]}),(0,m.jsx)(le,{entry:e,inPreview:t,action:o,onOpen:n})]}),(0,m.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,m.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:r.command}),r.cwd?(0,m.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,m.jsx)(`span`,{children:`cwd`}),(0,m.jsx)(`span`,{className:`break-all`,children:r.cwd})]}):null]}),o?.run?(0,m.jsx)(y,{icon:(0,m.jsx)(ie,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${o.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,a?(0,m.jsx)(y,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:e,inPreview:t,action:n,onOpen:r}){let{server:i}=e,a=t&&n!==void 0&&!n.run,o=a?`In preview`:n?.label,s=a?c:n?_[n.label]:null;return n&&o&&s?(0,m.jsxs)(ae,{variant:a||n.label===`View`||n.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:px-3.5`,onClick:()=>r?.({port:i.port,run:n.run}),children:[(0,m.jsx)(s,{"aria-hidden":`true`}),o]}):null}function y({icon:e,children:t}){return(0,m.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,m.jsx)(`span`,{children:t})]})}function b(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}function ue(){return{turns:[],itemsById:new Map,turnSeq:0,eventSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function S(e){return typeof e==`string`?e:void 0}function C(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}`}function w(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function de(e){return t.safeParse(e).data}function T(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function E(e){return e.turns.at(-1)??T(e)}function D(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return E(e).entries.push(n),n}var O=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],k=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function A(e){return e.trim().replace(/\s+/g,` `)}function j(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of O){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return A(t)}function M(e,t,n){if(t===e.primarySource&&n===e.primaryText||e.draft.entry.kind!==`note`)return;let r=e.draft.entry;r.details?.some(e=>e.source===t&&e.text===n)||(r.details=[...r.details??[],{source:t,text:n}])}function N(e,t,n){let r=e.failures;if(r)for(let e=r.length-1;e>=0;--e){let i=r[e];if(t!==``&&i.cause===t||t===``&&i.fatal&&(n===void 0||i.stepId===void 0||i.stepId===n))return i}}function P(e,t,n){let r=E(e),i=N(r,n.cause,n.stepId);if(i){i.draft.lastSeq=Math.max(i.draft.lastSeq,t.seq),n.fatal&&(i.fatal=!0),n.stepId!==void 0&&i.stepId===void 0&&(i.stepId=n.stepId),M(i,n.source,n.text);return}let a={draft:D(e,{kind:`note`,id:n.id,text:n.text,tone:`danger`}),cause:n.cause,primarySource:n.source,primaryText:n.text,...n.stepId===void 0?{}:{stepId:n.stepId},fatal:n.fatal};r.failures=[...r.failures??[],a]}function F(e,t,n){if(!k.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=j(n);if(i===``)return!1;let a=N(r,i,S(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,M(a,`lifecycle`,n),!0):!1}function I(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=N(r,n?j(n):``,S(t.stepId));i&&(i.fatal=!0)}function L(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function R(e,t){let n=S(e.stepId);return n===void 0?t:`${n}:${t}`}function z(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function B(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&z(e,t);let s=e.itemsById.get(r);if(s&&s.turn===t){s.entry.entry=o,s.entry.lastSeq=e.eventSeq,s.entry.streaming=a;return}let c={origin:`v2`,entry:o,firstSeq:e.eventSeq,lastSeq:e.eventSeq,streaming:a};t.entries.push(c),e.itemsById.set(r,{turn:t,entry:c})}var V={"not-delivered":0,queued:1,delivered:2,consumed:3},H=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of H)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function W(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function fe(e,t){let n=e.conversationEntries.get(t);n&&W(e,n)}function pe(e,t,n,r){(V[e.delivery]<V.delivered||V[n]>V[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,U(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function G(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){pe(i,t,n,r),W(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...U(t)};W(e,a),e.conversationEntries.set(t.id,a),D(e,a)}function me(e,t){let n=C(t.ts),r=S(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,D(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function he(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=S(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${S(t.event)?` (${S(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${S(t.error)??`unknown error`}`;D(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ge(e,t){let n=S(t.webhookName)??`webhook`,r=S(t.title),i=`v1:${t.seq}`;if(t.ok===!1){D(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${S(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${C(t.ts)}${r?` — ${r}`:``}`;D(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function _e(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${S(t.event)??`delivery`}${S(n.status)?` · ${S(n.status)}`:``}`;D(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function ve(e,t){let r=n.safeParse(t.server);if(!r.success)return;let i=e.previewByPort.get(r.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=E(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${r.data.port}`,server:r.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(r.data.port,{turn:a,draft:o})}function ye(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.lastSeq=t.seq,i.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function be(e,t){let n=i.safeParse(t);if(!n.success)return;let{message:r,delivery:a,deliveredAt:o,consumedAt:s,ts:c}=n.data;G(e,r,a,{deliveredAt:o,consumedAt:s,recordedAt:c})}function xe(e,t){let n=o.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),fe(e,r.requestId))}function Se(e,t){let n=a.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){G(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}D(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ce(e,t){let n=S(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=T(e,t.seq),a=w(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function we(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:T(e,t.seq);r.turnId=S(t.turnId),r.startedAt??=w(t.ts)}function Te(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function Ee(e,t){L(e);let n=Te(e,S(t.turnId));if(!n)return;let r=w(t.ts);n.completed={stopReason:S(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),De=e=>K.has(e.kind);function Oe(e){if(!(!x(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=Oe(t.item);if(!n)return;let r=R(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);B(e,i?.turn??E(e),n,r,a?w(t.ts):void 0,o)}function ke(e,t){let n=e.itemsById.get(R(t,S(t.itemId)??``)),r=S(t.delta)??``;if(!n||r===``||!De(n.entry.entry))return;let i=n.entry.entry;n.entry.lastSeq=t.seq,t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function Ae(e,t){let n=E(e),r=S(t.text)??``;if(r===``)return;let i=w(t.ts);n.entries.push({origin:`v1`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var je=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Me(e){if(!x(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!x(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:je.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Ne=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Pe(e,t){let n=E(e),r=S(t.tool)??`Tool`;if(n.v2Items||Ne.has(r))return;let i=ee(r,t.input),a=i.toolKind===`plan`?Me(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:S(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o,firstSeq:t.seq,lastSeq:t.seq};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Fe(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Ie(e,t){let n=e.itemsById.get(S(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(n.entry.lastSeq=t.seq,r.status=`completed`,r.output=Fe(t.result))}function Le(e,t,n,r){let i=S(t.message)??``;i!==``&&D(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){let n=S(t.message)??``;t.type===`lifecycle`&&n!==``&&F(e,t,n)||Le(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function Re(e,t){let n=S(t.message)??``;n!==``&&P(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:j(n),stepId:S(t.stepId),fatal:!1})}function ze(e,t){let n=S(t.message)??``;n!==``&&P(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:j(n),stepId:S(t.stepId),fatal:t.fatal===!0})}function Be(e,t){if(t.status!==`failed`)return;let n=S(t.stepId),r=S(t.error),i=r?` — ${r}`:``;P(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?j(r):``,stepId:n,fatal:!0})}function Ve(e,t){let n=S(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;D(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:S(t.text)??``,exitCode:r})}function He(e,t){let n=de(t.provider),r=S(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||D(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function Ue(e,t){let n=S(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=S(t.name);i!==void 0&&(r.name=i),D(e,r)}function We(e,t){Array.isArray(t.entries)&&(E(e).planEntries=t.entries)}function Ge(e,t){L(e);let n=S(t.reason)??`end_turn`,r=S(t.message);n===`error`&&I(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var Ke=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function qe(e){return x(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&Ke.has(e.kind)}function Je(e){if(!(!Array.isArray(e)||e.length===0||!e.every(qe)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Ye(e,t){let n=S(t.requestId),r=S(t.title),i=Je(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=S(t.itemId),o=S(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),D(e,s)}function Xe(e,t){let n=e.permissions.get(S(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=S(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=S(t.reason);i!==void 0&&(n.reason=i)}function Ze(e,t){let n=u(t),r=n&&ne(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};D(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function Qe(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=S(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function $e(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function et(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var tt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function nt(e,t){let n=Y(e,t);n&&tt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function rt(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Z=()=>{},it=new Map([[`handoff`,me],[`webhook.failed`,he],[`webhook.dry-run`,_e],[`webhook.report`,ge],[`preview.server-registered`,ve],[`preview.server-state`,ye],[`conversation-message`,be],[`request-outcome`,xe],[`agent-input`,Se],[`user-message`,Ce],[`turn.started`,we],[`turn.completed`,Ee],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,ke],[`text`,Ae],[`tool-call`,Pe],[`tool-result`,Ie],[`note`,J],[`lifecycle`,J],[`error`,Re],[`session.error`,ze],[`step-end`,Be],[`check-output`,Ve],[`provider-auth-required`,He],[`image`,Ue],[`plan.updated`,We],[`session.started`,e=>L(e)],[`session.ended`,Ge],[`permission.requested`,Ye],[`permission.resolved`,Xe],[`ask.requested`,Ze],[`worker-question-routed`,Qe],[`worker-question-fallback`,$e],[`worker-question-undelivered`,et],[`human-ask-closed`,nt],[`human-input-delivered`,rt],[`step-start`,Z],[`token-usage`,Z],[`cost`,Z],[`turn-end`,Z],[`done`,Z],[`session`,Z]]);function at(e,t){e.eventSeq=t.seq,it.get(t.type)?.(e,t)}function ot(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function st(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=new Set;for(let e=t.length-1;e>=0;--e)n.add(t[e]);return[...n]}function ct(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=j(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&j(e.text)===r)}function lt(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!ct(n,t)?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function Q(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
2
+ `)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
3
+ `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
4
+ `):n}var ut=/\s*(?:^|\n)C(?:E(?:Z(?::.*)?)?)?$/,dt=/[ \t]+CEZ(?::[A-Z]*)?$/;function ft(e){return e.replace(ut,``).replace(dt,``)}function $(e,t,n){return t!==``&&e.some(e=>e.norm===``?n>e.firstSeq:e.norm.startsWith(t)||t.startsWith(e.norm))}function pt(e,t){let n=e=>Q(e,!0).replace(/\s+/g,``),r=new Set,i=[],a=[];for(let{origin:o,entry:s,firstSeq:c,streaming:l}of e.entries)if(o===`v2`&&s.kind===`message`){let e=n(s.text);r.add(e),i.push(e),t&&l===!0&&a.push({norm:e,firstSeq:c})}if(i.length===0)return;r.add(i.join(``));let o=[],s={entries:[],texts:[]},c=()=>{let e=n(s.texts.join(``)),t=s.entries[0],i=s.entries.length>=2&&r.has(e);if(t&&(i||$(a,e,t.firstSeq))){s={entries:[],texts:[]};return}o.push(...s.entries),s={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(s.entries.push(t),s.texts.push(t.entry.text)):(c(),o.push(t));c(),e.entries=o}function mt(e,t){let n=new Set;for(let{origin:t,entry:r}of e.entries)t===`v2`&&r.kind===`message`&&n.add(Q(r.text,!0).trim());n.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&n.has(Q(e.entry.text,!0).trim()))),pt(e,t))}function ht(e){let t=e.failures?.filter(e=>e.fatal&&e.cause!==``);if(!t||t.length===0)return;let n=new Map;for(let e of t)n.set(e.cause,e);e.entries=e.entries.filter(e=>{if(e.entry.kind!==`message`||e.entry.role!==`assistant`)return!0;let t=Q(e.entry.text,!0).trim();if(t===``)return!0;let r=n.get(A(t));return r?(r.draft.firstSeq=Math.min(r.draft.firstSeq,e.firstSeq),r.draft.lastSeq=Math.max(r.draft.lastSeq,e.lastSeq),M(r,`assistant`,t),!1):!0})}function gt(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!b(e,`human`)))}function _t(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function vt(e,t,n){let{entry:r}=e;if(r.kind!==`message`||r.role!==`assistant`)return r;let i=Q(r.text,t);return n&&e.streaming===!0?{...r,text:ft(i),streaming:!0}:{...r,text:i}}function yt(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(e=>vt(e,n,t)),itemSeqs:bt(e.entries)}}function bt(e){let t=new Map;for(let{entry:n,firstSeq:r,lastSeq:i}of e)t.has(n.id)||t.set(n.id,{first:r,last:i});return t}function xt(e,t={}){let n=ue();for(let t of e)at(n,t);let r=n.turns.length-1;for(let[e,i]of n.turns.entries())i.v2Items&&mt(i,t.activeTurn===!0&&e===r),ht(i),gt(i);return _t(n),{turns:n.turns.map((e,n)=>yt(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{b as a,lt as i,xt as n,v as o,st as r,ot as t};
@@ -0,0 +1 @@
1
+ import{W as e,Zn as t,_r as n,bt as r,ft as i,g as a,gt as o,in as s}from"./queries-DD_9iITj.js";import{Zi as c,Zr as l,a as u,ht as d}from"./project-scope-context-DNrHbqd2.js";import{a as f}from"./agent-accounts-Du8CHfFX.js";import{V as p,mn as m,xn as h}from"./index-C3kap2_j.js";function g(e,n,r,i){return t(e,n)?.runner??e.runner??(n||r?i:void 0)??`claude`}function _(e,t,n){let r=new Set;for(let i of e.workflowDef?.steps??[]){if(i.command!==void 0||i.kind===`plugin`)continue;let a=i.runner??t,o=i.agentProfile??(a===(e.runner??t)?e.agentProfile:void 0)??n.repoAccount?.[a];n.readyOn(a,o)||r.add(a)}return[...r]}function v(e,t,n,r,i){if(!e)return t!==null||!n||r?i:void 0}function y(e){return e.needsConfig&&e.configPending?`Checking task settings…`:e.needsConfig&&e.configError?`Task settings could not be loaded.`:e.providersPending?`Checking agent providers…`:e.providersError?`Provider authentication could not be verified.`:e.canContinue?void 0:e.untouched?`Connect the required workflow providers (${e.missing.join(`, `)}) to continue.`:`Connect an agent provider to continue.`}function b(){let t=e(),n=r();return{providers:t,registered:n,providersPending:t.isPending||n.isPending,providersError:t.isError||n.isError,providersReady:t.isSuccess&&n.isSuccess}}function x(e,t=null,n){let{registered:r,providersPending:s,providersError:c,providersReady:u}=b(),d=a(n),x=m(e),S=e.removedRunner!==void 0,C=x&&!e.runner||S,w=f(n),T=e.delegation?.role===`worker`,E=d.data?.defaultRunner,D=g(e,x,S,i(E,o(r.data))??E),O=(t,n)=>h(e,t,w.repoAccount,{original:D,target:n},x),{runners:k,signedOut:A}=w.runnersOn(e=>O(e,e)),j=T?D:p(t,k,D),M=k.includes(D),N=x?l(e.workflowDef,j,o(r.data)):[j],P=x&&T&&e.workflowDef?_(e,j,w):N.filter(e=>!w.readyOn(e,O(e,j))),F=u&&(!C||d.isSuccess)&&P.length===0,I=y({needsConfig:C,configPending:d.isPending,configError:d.isError,providersPending:s,providersError:c,canContinue:F,untouched:x,missing:P});return{runners:k,signedOut:A,currentRunner:D,runner:j,currentRunnerConnected:M,canContinue:F,providerPending:s||C&&d.isPending,providerError:c,reason:I,runnerOverride:v(T,t,M,S,j)}}function S(e,t){let r=c();return n({mutationFn:()=>d(e,t?.projectId),onSuccess:()=>{r.invalidateQueries({queryKey:s.runs.all}),t?.onSuccess?.()},onError:e=>u(e.message,{tone:`danger`})})}export{x as n,S as t};
@@ -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{Ct as r,O as i,W as a,_r as o,bt as s,d as c,dt as l,g as u,i as d,in as f,k as p,s as m}from"./queries-DD_9iITj.js";import{Bi as h,Kn as g,R as _,X as v,Z as y,Zi as b,a as x,lt as S,r as C,tt as w}from"./project-scope-context-DNrHbqd2.js";import{o as T,s as E}from"./dist-CCX8mhHc.js";import{t as D}from"./host-storage-Cr_NKfWy.js";import{A as O,Z as k,_ as A,b as j,ct as M,d as ee,ft as N,h as P,l as F,mt as I,ot as L,r as te,rt as R,u as ne,ut as re}from"./design-icons-QbNMZniQ.js";import{t as z}from"./external-link-BE6y205O.js";import{t as ie}from"./eye-B8okNWXU.js";import{t as ae}from"./loader-circle-CPBhhDbB.js";import{t as oe}from"./message-square-B-MD-8rD.js";import{t as se}from"./play-CmVAj_fu.js";import{t as B}from"./button-BV_AiLj2.js";import{i as ce,r as le,t as ue}from"./popover-BQolmvDR.js";import{a as de,i as fe,o as pe,r as me,s as he,t as ge}from"./dialog-DKr-j9S6.js";import{t as V}from"./project-router-CfEuKuz1.js";import{a as _e,i as H,o as U,r as ve,s as ye,t as be}from"./command-4D8sPZJy.js";import{d as xe,f as W,i as Se,o as Ce,p as we,s as Te,t as Ee,u as De}from"./skills-pM_PouEs.js";import{a as Oe,t as ke}from"./agent-accounts-Du8CHfFX.js";import{B as Ae,Bn as je,H as Me,I as Ne,J as Pe,L as Fe,Q as Ie,R as Le,V as Re,Vn as ze,X as G,Y as Be,Z as Ve,dt as He,et as Ue,it as We,kt as K,lt as Ge,ot as Ke,rt as qe,sr as q,st as Je,ut as Ye,wr as Xe,z as Ze,zn as J}from"./index-C3kap2_j.js";import{t as Qe}from"./textarea-BGp28xFr.js";import{t as $e}from"./markdown-Bmdr6MIa.js";import{t as et}from"./diff-BOF9OXhn.js";import{t as Y}from"./change-counts-BLLRvt46.js";import{t as tt}from"./option-select-BxTmKg8G.js";import{t as nt}from"./tab-link-DL1UtKVR.js";var X=e(t(),1),Z=n(),rt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function Q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:T(t,`text-semantic-green`)}):e===`failing`?(0,Z.jsx)(A,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:T(t,`text-semantic-red`)}):e===`pending`?(0,Z.jsx)(ae,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:T(t,`animate-spin text-semantic-amber motion-reduce:animate-none`)}):e===`review`?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-review`,className:T(t,`text-semantic-info`)}):e===`conflict`?(0,Z.jsx)(M,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-conflict`,className:T(t,`text-semantic-conflict`)}):(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:T(t,`text-soft-foreground`)})}function it(e){return e?.available?e.mergeState:null}function at(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function ot(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function st(e){return e===`approved`||e===`not-required`?`passing`:e===`review-required`?`review`:e===`unknown`?`unknown`:`failing`}function ct(e){switch(e){case`approved`:return`Approved`;case`not-required`:return`Not required`;case`review-required`:return`Waiting for review`;case`changes-requested`:return`Changes requested`;case`unknown`:return`Unknown`}}function lt(e){return e===`mergeable`?`passing`:e===`conflicting`?`conflict`:`unknown`}function ut(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function dt(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function ft(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function pt(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function mt(e){return e?rt[e]:`Merge`}function ht(e){return e===`conflicting`?`true`:void 0}function gt({check:e}){return(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Q,{state:e.state}),(0,Z.jsxs)(`span`,{children:[e.name,` · `,e.state,dt(e.required)]})]}),e.url&&E(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function _t({reason:e}){return(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function vt({state:e,selectedMethod:t,overrideRules:n,mergeEnabled:r,refreshPending:i,onRefresh:a,onRunAgent:o,onConfirm:s,onMethodChange:c,onOverrideChange:l}){let u=ot(e),d=st(e.reviewDecision),f=lt(e.mergeable);return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-semantic-green`}):(0,Z.jsx)(M,{size:16,"aria-hidden":`true`,className:T(`mt-0.5 size-5 shrink-0`,e.mergeable===`conflicting`?`text-semantic-conflict`:`text-semantic-amber`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold`,children:u}),(0,Z.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:a,children:[(0,Z.jsx)(k,{size:16,"aria-hidden":`true`,className:T(`size-3.5`,i&&`animate-spin`)}),`Refresh`]})]}),(0,Z.jsxs)(`p`,{className:`mt-1 font-mono text-xs text-soft-foreground`,children:[e.headRef,` (`,ze(e.headSha),`) → `,e.baseRef]}),(0,Z.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:d}),(0,Z.jsxs)(`span`,{children:[`Reviews: `,ct(e.reviewDecision)]})]}),(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:f}),(0,Z.jsxs)(`span`,{children:[`Conflicts: `,ut(e.mergeable)]})]}),e.checks.length===0?(0,Z.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,Z.jsx)(gt,{check:e},e.name)),e.blockers.map(e=>(0,Z.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&o?(0,Z.jsx)(B,{className:`mt-4`,onClick:o,children:`Run agent on this PR`}):null,e.canOverride?(0,Z.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>l(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,Z.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,Z.jsx)(tt,{"aria-label":`Merge method`,value:t??``,onValueChange:e=>c(e),options:e.methods.map(e=>({value:e,label:rt[e]})),className:`w-full min-w-0 flex-1 bg-background sm:w-auto`}),(0,Z.jsx)(B,{disabled:!r,onClick:s,children:mt(t)})]}):null]})]})}function yt({number:e,state:t,selectedMethod:n,confirming:r,overrideRules:i,mergePending:a,mergeError:o,onOpenChange:s,onMerge:c}){return(0,Z.jsx)(ge,{open:r,onOpenChange:s,children:(0,Z.jsxs)(me,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Z.jsxs)(pe,{children:[(0,Z.jsxs)(he,{children:[mt(n),` pull request #`,e,`?`]}),(0,Z.jsx)(fe,{asChild:!0,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),i&&t.canOverride?(0,Z.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-semantic-amber`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),o?(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:o.message}):null,(0,Z.jsxs)(de,{children:[(0,Z.jsx)(B,{variant:`outline`,disabled:a,onClick:()=>s(!1),children:`Cancel`}),(0,Z.jsx)(B,{disabled:a,onClick:c,children:a?`Merging…`:mt(n)})]})]})})}function bt({number:e,onRunAgent:t}){let n=b(),r=c(),i=h({queryKey:f.githubMergeState(e),queryFn:({signal:t})=>y(e,{},{signal:t}),retry:!1}),a=it(i.data),[s,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),g=o({mutationFn:t=>y(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>x(e instanceof Error?e.message:String(e),{tone:`danger`})}),_=at(s,a),v=()=>({mergeState:f.githubMergeState(e),list:f.githubPages(50),comments:f.githubComments(`pr`,e),item:f.githubItem(`pr`,e),refStatus:r===void 0?void 0:f.githubRefStatusOf(r)}),S=o({mutationFn:t=>{if(!a||!_)throw Error(`No merge method is available.`);return w(e,{method:_,expectedHeadSha:a.headSha,...p&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{d(!1),x(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{x(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,Z.jsx)(q,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":ht(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-card-edge bg-card p-4 shadow-card`,children:[(0,Z.jsx)(vt,{state:a,selectedMethod:_,overrideRules:p,mergeEnabled:pt(_,a,p),refreshPending:g.isPending,onRefresh:()=>g.mutate(f.githubMergeState(e)),onRunAgent:t,onConfirm:()=>d(!0),onMethodChange:l,onOverrideChange:m}),(0,Z.jsx)(yt,{number:e,state:a,selectedMethod:_,confirming:u,overrideRules:p,mergePending:S.isPending,mergeError:S.error,onOpenChange:d,onMerge:()=>S.mutate(v())})]}):(0,Z.jsx)(_t,{reason:ft(i.data)})}function xt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function St(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function Ct(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function wt(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function Tt(e){return!e||!/^[0-9a-fA-F]{6}$/.test(e)?{backgroundColor:`var(--border)`}:{backgroundColor:`#${e}`}}function Et({label:e,color:t,className:n}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,title:e,style:wt(t),className:T(`rounded-full border px-1.5 py-px text-[12px] font-medium`,n),children:e})}function Dt(e){return e===`pr`?`pull request`:`issue`}function Ot(e,t,n){return e===`pr`&&!!(t||n)}function kt({backLink:e}){return e?(0,Z.jsxs)(V,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}var At=T(`text-sm`,`[&_[data-streamdown="code-block"]]:relative [&_[data-streamdown="code-block"]]:my-2.5 [&_[data-streamdown="code-block"]]:gap-0 [&_[data-streamdown="code-block"]]:overflow-hidden [&_[data-streamdown="code-block"]]:rounded-lg [&_[data-streamdown="code-block"]]:border [&_[data-streamdown="code-block"]]:border-border [&_[data-streamdown="code-block"]]:bg-background [&_[data-streamdown="code-block"]]:p-0 [&_[data-streamdown="code-block"]]:![content-visibility:visible] [&_[data-streamdown="code-block"]]:![contain-intrinsic-size:auto]`,`[&_[data-streamdown="code-block-header"]]:h-7 [&_[data-streamdown="code-block-header"]]:border-b [&_[data-streamdown="code-block-header"]]:border-border [&_[data-streamdown="code-block-header"]]:bg-muted/40 [&_[data-streamdown="code-block-header"]]:px-3 [&_[data-streamdown="code-block-header"]]:text-xs`,`[&_[data-streamdown="code-block-header"][data-language=""]]:hidden [&_[data-streamdown="code-block-header"]:not([data-language])]:hidden [&_[data-streamdown="code-block-header"]:has(>span:empty)]:hidden`,`[&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:absolute [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:top-1 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:right-1.5 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:mt-0 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:h-auto`,`[&_[data-streamdown="code-block-actions"]]:border-0 [&_[data-streamdown="code-block-actions"]]:bg-transparent [&_[data-streamdown="code-block-actions"]]:p-0 [&_[data-streamdown="code-block-actions"]]:backdrop-blur-none`,`[&_[data-streamdown="image-fallback"]]:inline-flex [&_[data-streamdown="image-fallback"]]:rounded-md [&_[data-streamdown="image-fallback"]]:border [&_[data-streamdown="image-fallback"]]:border-dashed [&_[data-streamdown="image-fallback"]]:border-border [&_[data-streamdown="image-fallback"]]:bg-muted/40 [&_[data-streamdown="image-fallback"]]:px-3 [&_[data-streamdown="image-fallback"]]:py-2 [&_[data-streamdown="image-fallback"]]:not-italic [&_[data-streamdown="image-fallback"]]:after:content-["_—_open_on_GitHub_to_view"]`,`[&_[data-streamdown="code-block-body"]]:rounded-none [&_[data-streamdown="code-block-body"]]:border-0 [&_[data-streamdown="code-block-body"]]:bg-transparent [&_[data-streamdown="code-block-body"]]:px-3.5 [&_[data-streamdown="code-block-body"]]:py-2.5 [&_[data-streamdown="code-block-body"]]:pr-10`);function jt(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Mt({item:e,kindWord:t,commentCount:n,hasDiffStat:r,additions:i,deletions:a}){return(0,Z.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,e.number]}),`·`,(0,Z.jsx)(`span`,{children:t}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsx)(J,{iso:e.createdAt,title:jt(e.createdAt)}),n?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(an,{count:n})]}):null,r?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(`span`,{"data-slot":`gh-diffstat`,children:(0,Z.jsx)(Y,{adds:i??0,dels:a??0})})]}):null,`·`,E(e.url)?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Z.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function Nt({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,Z.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Z.jsx)(nt,{to:K(`prs`,t.filter,e.number,``,t.narrows),active:!n,children:`Conversation`}),(0,Z.jsx)(nt,{to:K(`prs`,t.filter,e.number,`/changes`,t.narrows),active:n,children:`Changes`})]}):(0,Z.jsx)(V,{to:K(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function Pt({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(Et,{label:e,color:t[e]},e)),n?(0,Z.jsx)(on,{checks:n,url:e.url}):null]}):null}function Ft({item:e,colors:t,body:n}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:T(`mt-5`,At),children:n?(0,Z.jsx)($e,{children:n}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),(0,Z.jsx)(Bt,{item:e,colors:t})]})}function It({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,headerAction:c,children:l}){let u=a?.changes??!1,f=Dt(e.kind),p=d(e.kind,e.number,!u).data?.detail,m=p?.body??e.body,h=p?.additions??e.additions,g=p?.deletions??e.deletions,_=Ot(e.kind,h,g),v=r??e.comments;return(0,Z.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Z.jsx)(kt,{backLink:i}),(0,Z.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,Z.jsx)(Lt,{action:c,className:`mb-4`,children:(0,Z.jsxs)(`h2`,{className:`min-w-0 text-[22px] leading-snug font-semibold tracking-tight`,children:[`#`,e.number,` `,e.title]})}):null,(0,Z.jsx)(Lt,{action:e.kind===`pr`?void 0:c,children:(0,Z.jsx)(Mt,{item:e,kindWord:f,commentCount:v,hasDiffStat:_,additions:h,deletions:g})}),e.kind===`pr`?null:(0,Z.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-semibold tracking-tight`,children:e.title}),s,(0,Z.jsx)(Nt,{item:e,subNav:a,changes:u}),(0,Z.jsx)(Pt,{item:e,colors:t,checks:n}),u&&e.kind===`pr`?(0,Z.jsx)(Rt,{item:e}):(0,Z.jsx)(Ft,{item:e,colors:t,body:m})]}),e.kind===`pr`?(0,Z.jsx)(bt,{number:e.number,onRunAgent:o}):null,l]})}function Lt({action:e,className:t,children:n}){return e?(0,Z.jsxs)(`div`,{"data-slot":`gh-header-row`,className:T(`flex flex-wrap items-center gap-x-3 gap-y-2`,t),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,Z.jsx)(`div`,{"data-slot":`gh-header-action`,className:`flex shrink-0 items-center gap-2`,children:e})]}):t?(0,Z.jsx)(`div`,{className:t,children:n}):(0,Z.jsx)(Z.Fragment,{children:n})}function Rt({item:e}){let t=b(),n=m(e.number),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(null),s=n.data,c=e=>s?.available?s.files.filter(t=>t.path.toLowerCase().includes(e.toLowerCase())):[],l=c(r),u=l.some(e=>e.path===a)?a:l[0]?.path??null,d=l.findIndex(e=>e.path===u),p=e=>{i(e);let t=c(e),n=u??a,r=t.some(e=>e.path===n)?n:t[0]?.path??n;r!==a&&o(r)},h=async()=>{let n=s?.available?s.headSha:null,r=f.githubPrChanges(e.number),i=await v(e.number,{refresh:!0});t.setQueryData(r,i),i.available&&n&&n!==i.headSha&&(o(i.files[0]?.path??null),x(`The reviewed revision changed.`))};if(n.isPending)return(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!s)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!s.available)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:s.reason});let g=l.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),_=E(e.url)?`${e.url}/files`:null,y=l.find(e=>e.path===u);return(0,Z.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`strong`,{children:[s.files.length,` changed files`]}),(0,Z.jsx)(Y,{adds:s.additions,dels:s.deletions}),(0,Z.jsx)(je,{sha:s.headSha,variant:`inline`,prefix:`head `,className:`text-muted-foreground`}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto`,onClick:()=>void h(),children:`Refresh`})]}),s.truncated?(0,Z.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[s.reason??`This response is incomplete.`,` `,_?(0,Z.jsx)(`a`,{href:_,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Z.jsx)(`input`,{"aria-label":`Filter changed files`,value:r,onChange:e=>p(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Z.jsx)(tt,{"aria-label":`Select changed file`,value:u??``,onValueChange:o,options:l.map(e=>({value:e.path,label:e.path})),className:`mt-2 w-full min-w-0 bg-background lg:hidden`,contentClassName:`max-w-[calc(100vw-2rem)]`}),(0,Z.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:l.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>o(e.path),className:T(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,u===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Z.jsx)(Y,{adds:e.additions,dels:e.deletions})]})},e.path))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Z.jsx)(B,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,disabled:d<=0,onClick:()=>o(l[d-1]?.path??null),children:(0,Z.jsx)(Xe,{})}),(0,Z.jsx)(B,{"aria-label":`Next file`,variant:`outline`,size:`icon`,disabled:d<0||d>=l.length-1,onClick:()=>o(l[d+1]?.path??null),children:(0,Z.jsx)(ee,{size:16})})]}),l.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(et,{files:g.filter(e=>e.path===u),wrap:!0,className:`min-w-0`}),y&&!y.patch?(0,Z.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,y.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function zt(e){let t=e.filter(e=>e.kind===`review`).length,n=e.length-t,r=`${n} comment${n===1?``:`s`}`;return t===0?r:`${r} · ${t} review${t===1?``:`s`}`}function Bt({item:e,colors:t}){let n=d(e.kind,e.number),r=n.data,i=(0,X.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Vt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsx)(q,{className:`mb-3 h-3 w-24`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(q,{className:`h-14 w-full`}),(0,Z.jsx)(q,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Z.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Activity · `,zt(r.comments)]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Ht(i).map(e=>e.group===`commits`?(0,Z.jsx)(Ut,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(en,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(Gt,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Vt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Ht(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function Ut({commits:e,colors:t}){let[n,r]=(0,X.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Wt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Z.jsx)(Gt,{event:e,colors:t},e.id))]}):(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Wt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Z.jsx)(J,{iso:e[e.length-1].createdAt,className:`shrink-0`})]})})}var Wt={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function Gt({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:T(`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:Wt[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(Zt,{event:e,colors:t}),(0,Z.jsx)(J,{iso:e.createdAt,className:`shrink-0`}),e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Kt({event:e}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Z.jsx)(je,{sha:e.sha,variant:`inline`,className:`shrink-0 text-xs text-muted-foreground`}):null,e.message?(0,Z.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Z.jsx)(Qt,{checks:e.checks})]})}function qt({event:e,colors:t}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Z.jsx)(`span`,{"data-slot":`gh-event-label`,style:wt(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,Z.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function Jt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Yt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Xt={committed:e=>(0,Z.jsx)(Kt,{event:e}),labeled:(e,t)=>(0,Z.jsx)(qt,{event:e,colors:t}),unlabeled:(e,t)=>(0,Z.jsx)(qt,{event:e,colors:t}),assigned:e=>(0,Z.jsx)(Jt,{event:e}),unassigned:e=>(0,Z.jsx)(Jt,{event:e}),merged:()=>(0,Z.jsx)(`span`,{children:`merged this`}),closed:()=>(0,Z.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,Z.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,Z.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,Z.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,Z.jsx)(Yt,{event:e})};function Zt({event:e,colors:t}){return Xt[e.kind]?.(e,t)??null}function Qt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:T(`shrink-0`,rn[e]),children:nn[e]}):null}var $t={approved:{label:`Approved`,tone:`border-success/40 text-semantic-green`},changes_requested:{label:`Changes requested`,tone:`border-danger/40 text-semantic-red`},commented:{label:`Commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`Dismissed`,tone:`border-border text-muted-foreground`}};function en({comment:e}){let t=e.reviewState?$t[e.reviewState]:null;return(0,Z.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(tn,{url:e.avatarUrl,login:e.author}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Z.jsx)(J,{iso:e.createdAt}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:T(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Z.jsx)(`div`,{"data-slot":`gh-thread-body`,className:At,children:e.body?(0,Z.jsx)($e,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no body)`})})]})}function tn({url:e,login:t}){let[n,r]=(0,X.useState)(!1);return e&&!n?(0,Z.jsx)(`img`,{src:e,alt:``,width:20,height:20,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-5 shrink-0 rounded-full`}):(0,Z.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var nn={passing:`✓`,failing:`✗`,pending:`○`},rn={passing:`text-semantic-green`,failing:`text-semantic-red`,pending:`text-semantic-amber`},$={passing:`Checks passing`,failing:`Checks failing`,pending:`Checks pending`};function an({count:e}){return e?(0,Z.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsx)(oe,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function on({checks:e,url:t}){let n=T(`text-xs font-medium`,rn[e],t&&`hover:underline`),r=`${nn[e]} ${$[e]}`;return t?(0,Z.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,Z.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function sn({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:$[e],"aria-label":$[e],className:T(`shrink-0 font-sans text-xs font-semibold`,rn[e]),children:nn[e]})}function cn(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function ln(e,t=[]){let n=cn(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=un(t)),n}function un(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function dn(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function fn(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function pn(e,t,n){let r=(n??``).trim();if(!r)return ln(e,t);let i=cn(e),a=r.startsWith(i)?i+dn(r.slice(i.length),e):dn(r,e),o=fn(a,e)?a:`${i}\n\n${a}`;return t.length?o+un(t):o}function mn(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function hn(e,t,n,r,i={}){return t?{...i,workflow:t,task:pn(e,n.map(e=>e.id),r)}:n.length?{...i,steps:mn(n.map(e=>e.id)).map((e,t)=>({...e,...n[t]?.path===void 0?{}:{skillPath:n[t].path}})),task:pn(e,[],r)}:{...i,workflow:`quick-task`,task:pn(e,[],r)}}function gn(e){let t=a(),n=u(),i=s(),{runners:o,uninstalled:c,signedOut:l,accounts:d,repoAccount:f,accountFor:p}=Oe(),m=n.data?.defaultRunner,h=Re(e.runner,o,m??o[0]??`claude`),g=n.data?.modelsLocked===!0,_=p(h,e.account),v=r(h,!0,_??f?.[h]),y=Ae(g?null:e.model,h,i.data,n.data?.defaultModels,v.data),b=Fe(y,v.data);return{runner:h,runnerExplicit:e.runner!==null,model:y,effort:g?``:Ze(e.effort,b),effortOptions:b,runners:o,uninstalled:c,signedOut:l,defaultRunner:m,canRun:t.isSuccess&&o.length>0,modelsLocked:g,providerPending:t.isPending,providerError:t.isError,accounts:d,account:_,repoAccount:f}}function _n(e){return{runner:Me(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function vn(e){return{..._n(e),...e.account?{agentProfile:e.account}:{}}}function yn(e,t){return e.find(e=>e.id===t)?.label??(t===``?`Runner default`:t)}function bn(e,t){let{runners:n,uninstalled:r,signedOut:i}=e;return n.length>1||r.length>0||i.length>0||n.some(e=>ke(t,e))}function xn({pick:e,onChange:t,disabled:n=!1,accounts:i=!1,layout:a}){let o=(0,X.useRef)(null),c=(0,X.useRef)(null),[l,d]=(0,X.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,X.useLayoutEffect)(()=>{let e=o.current;if(a!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;c.current=n instanceof HTMLElement&&e.contains(n)?n:null,d(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[a]),(0,X.useLayoutEffect)(()=>{let e=c.current;c.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[l]);let f=gn(e),{runner:p,model:m,effort:h,effortOptions:g,runners:_,canRun:v,modelsLocked:y}=f,b=u(),x=s(),S=r(p,!0,f.account??f.repoAccount?.[p]),C=Le(p,x.data,S.data,[e.model,b.data?.defaultModels?.[p]]),w=n||!v,T=i?f.accounts:[],E=bn(f,T)?(0,Z.jsx)(Ie,{icon:(0,Z.jsx)(L,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,uninstalled:f.uninstalled,signedOut:f.signedOut,value:p,accounts:T,account:i?f.account:null,repoAccount:i?f.repoAccount:void 0,disabled:w,onPick:(n,r)=>t(i?{runner:n,account:r,model:n===p?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,D=(0,Z.jsx)(G,{icon:(0,Z.jsx)(j,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:yn(C,m),value:m,disabled:w,readOnly:y===!0,disabledHint:y?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=Fe(n,S.data);t({...e,model:n,effort:e.effort===null?null:Ze(e.effort,r)})},options:C.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Ne(p,x.data,S)},`model`),k=(0,Z.jsx)(G,{icon:(0,Z.jsx)(O,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:g.find(e=>e.value===h)?.label??`Runner default`,value:h,disabled:w,readOnly:y===!0,disabledHint:y?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:g.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return a===`row`?(0,Z.jsx)(`div`,{ref:o,"data-slot":`engine-row-box`,children:(0,Z.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,Z.jsx)(Ve,{fill:`model-pill`,children:l?[E,k,D]:[E,D,k]})})}):(0,Z.jsxs)(Ve,{children:[E,D,k]})}var Sn={workflow:null,skills:[]},Cn=`cez-followup-selection`;function wn(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.flatMap(e=>typeof e==`string`?[{id:e}]:!e||typeof e!=`object`||typeof e.id!=`string`?[]:[{id:e.id,...typeof e.path==`string`?{path:e.path}:{}}]):[]}}function Tn(){try{let e=localStorage.getItem(D(Cn));return e?wn(JSON.parse(e)):{...Sn}}catch{return{...Sn}}}function En(e){try{localStorage.setItem(D(Cn),JSON.stringify(e))}catch{}}var Dn=`cez-followup-prompt:`;function On(e){try{return localStorage.getItem(D(Dn+e))??``}catch{return``}}function kn(e,t){try{let n=D(Dn+e);t===``?localStorage.removeItem(n):localStorage.setItem(n,t)}catch{}}function An({item:e,workflows:t,skills:n,workflow:r,onWorkflowChange:a,selectedSkills:s,onSkillsChange:c,engine:u,onEngineChange:d,queuedRunId:p,onQueued:m}){let h=b(),g=i(),v=e.kind===`pr`?`PR`:`issue`,y=gn(u),C=l(y.runner,y.account),w=s.filter(e=>C.unchecked||e.path===void 0||n.some(t=>t.id===e.id&&(e.path===void 0||t.path===e.path))),T=w.length!==s.length,[D]=(0,X.useState)(()=>cn(e)),[O,k]=(0,X.useState)(()=>On(e.url)||D),A=(0,X.useRef)(null),j=(0,X.useRef)(null);(0,X.useEffect)(()=>{kn(e.url,O===D?``:O)},[e.url,O,D]);let M=(0,X.useMemo)(()=>Ge(g.data?.promptTemplates),[g.data?.promptTemplates]),ee=e=>{let t=A.current,n=He({prompt:O,base:D,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:j.current}),r=Je(O,n,e);k(r.text),j.current=r.caret,requestAnimationFrame(()=>{A.current?.focus(),A.current?.setSelectionRange(r.caret,r.caret)})},N=Ke(M,w.map(e=>e.id)),P=(0,X.useRef)(O);P.current=O;let I=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=Ye(P.current,I.current,N,D);I.current=e.applied,e.text!==P.current&&k(e.text)},[N,D]);let L=o({mutationFn:async()=>!y.canRun||T?null:S(hn(e,r,w,O,vn(y))),onSuccess:t=>{if(t===null)return;let n=t;n&&m(e.url,n.id),x(`Added to the queue — ${v} #${e.number}`),w.length>0&&g.data!==void 0&&_({skillUsage:w.reduce((e,t)=>Ee(e,t.id),g.data.skillUsage)}).then(()=>h.invalidateQueries({queryKey:f.uiState})).catch(()=>{}),kn(e.url,``),k(D),I.current=``,h.invalidateQueries({queryKey:f.runs.all})},onError:e=>x(e.message,{tone:`danger`})}),te=e=>{qe(e)&&(e.preventDefault(),!L.isPending&&y.canRun&&L.mutate())},R=e=>c(s.some(t=>W(t)===W(e))?s.filter(t=>W(t)!==W(e)):[...s,Te(e)]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,Z.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,Z.jsx)(`span`,{children:`Instructions for the agent`}),(0,Z.jsx)(Qe,{ref:A,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:O,onChange:e=>k(e.target.value),onSelect:e=>{j.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,Z.jsx)(Be,{templates:M,onInsert:ee}),(0,Z.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Workflow`}),(0,Z.jsx)(Mn,{workflows:t,value:r,onChange:a})]}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Skills · select one or more`}),(0,Z.jsx)(Pn,{skills:n,skillUsage:g.data?.skillUsage,selected:s,onToggle:R})]}),s.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:s.map(e=>(0,Z.jsx)(jn,{skill:e,skills:n,unchecked:C.unchecked,onRemove:()=>R(e)},W(e)))}):null,T?(0,Z.jsx)(`p`,{role:`alert`,children:`A selected skill path is unavailable. Remove it or choose a current copy before starting.`}):null,(0,Z.jsx)(xn,{layout:`row`,pick:u,onChange:d,disabled:L.isPending||!y.canRun,accounts:!0}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Account`}),(0,Z.jsx)(Nn,{resolved:y,disabled:L.isPending||!y.canRun,onPick:e=>d({...u,account:e})})]}),!y.providerPending&&!y.canRun?(0,Z.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[y.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Z.jsx)(V,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,Z.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[E(e.url)?(0,Z.jsx)(B,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,Z.jsxs)(B,{variant:`primary`,"data-action":`gh-run`,disabled:L.isPending||!y.canRun||T,onClick:()=>L.mutate(),children:[(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,v]}),(0,Z.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-xs font-medium text-muted-foreground`,children:We()}),p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(V,{to:`/tasks/${p}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function jn({skill:e,skills:t,unchecked:n,onRemove:r}){let i=t.find(t=>t.id===e.id&&(e.path===void 0||t.path===e.path)),a=[i?.name??e.id,e.path].filter(Boolean).join(` · `),o=!n&&e.path!==void 0&&!i?` (unavailable)`:n||!i?` (unchecked)`:``;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e.id,onClick:r,title:`Remove skill ${a}`,"aria-label":`Remove skill ${a}`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[a,o,(0,Z.jsx)(I,{size:16,"aria-hidden":`true`,className:`size-3`})]})}function Mn({workflows:e,value:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=(0,X.useRef)(null),c=xe(e,a);return(0,Z.jsxs)(ue,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:T(Ue,t&&`border-foreground/60 font-mono text-xs font-semibold text-foreground`),children:[(0,Z.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,Z.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,Z.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(le,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(be,{shouldFilter:!1,children:[(0,Z.jsx)(_e,{placeholder:`Search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,Z.jsxs)(ye,{ref:s,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,Z.jsx)(ve,{children:`Nothing matches.`}):null,(0,Z.jsx)(H,{children:c.map(e=>{let r=t===e.name;return(0,Z.jsxs)(U,{value:`workflow ${e.name}`,keywords:we(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function Nn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:g,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,...e.configDir?{desc:e.configDir}:{}}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,Z.jsx)(G,{icon:(0,Z.jsx)(re,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function Pn({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),u=(0,X.useRef)(null),{mostUsed:d,project:f,global:p,ranked:m}=De(e,o,t),h=(e,t)=>{let i=n.some(t=>W(t)===W(e));return(0,Z.jsxs)(U,{value:W(e),keywords:we(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.id,"data-selected":i?`true`:void 0,onSelect:()=>r(Te(e)),children:[(0,Z.jsx)(`span`,{className:T(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.path?(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Z.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Z.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,Z.jsx)(F,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},W(e))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Pe,{skill:c,onClose:()=>l(null)}),(0,Z.jsxs)(ue,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:T(Ue,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(le,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(be,{shouldFilter:!1,children:[(0,Z.jsx)(_e,{placeholder:`Search skills…`,value:o,onValueChange:s,onInput:()=>u.current?.scrollTo(0,0)}),(0,Z.jsxs)(ye,{ref:u,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[o.trim()&&!e.some(e=>e.id===o.trim())?(0,Z.jsx)(H,{children:(0,Z.jsxs)(U,{value:`typed-skill`,onSelect:()=>r({id:o.trim()}),children:[`Use skill id “`,o.trim(),`” (unchecked)`]})}):null,(m?m.length===0:d.length===0&&f.length===0&&p.length===0)?(0,Z.jsx)(ve,{children:`Nothing matches.`}):null,m?m.length>0?(0,Z.jsx)(H,{children:m.map(e=>h(e,Se(e)))}):null:(0,Z.jsxs)(Z.Fragment,{children:[d.length>0?(0,Z.jsx)(H,{heading:`Most used`,children:d.map(e=>h(e,Se(e)))}):null,f.length>0?(0,Z.jsx)(H,{heading:`Project skills`,children:f.map(e=>h(e,!0))}):null,p.length>0?(0,Z.jsx)(H,{heading:`Global`,children:p.map(e=>h(e,!1))}):null]})]})]})})]})]})}var Fn=new WeakMap;function In(){let e=Tn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&En({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Ln(){let e=b(),{projectId:t}=C(),n=Fn.get(e);n||Fn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=In());let{snapshot:a,subscribe:o,update:s}=r,c=(0,X.useSyncExternalStore)(o,a,a),u=p(),d=gn(c.engine),f=l(d.runner,d.account),m=i(),h=u.data?.workflows;(0,X.useEffect)(()=>{h&&c.workflow!==null&&!h.some(e=>e.name===c.workflow)&&s({workflow:null})},[s,h,c.workflow]);let g=(0,X.useMemo)(()=>Ce(f.data??[],m.data?.skillUsage),[f.data,m.data?.skillUsage]);return{...c,workflows:u,skillList:g,skillsUnchecked:f.unchecked,setWorkflow:e=>s({workflow:e}),setSelectedSkills:e=>s({selectedSkills:e}),setEngine:e=>s({engine:e}),onQueued:(e,t)=>s({queued:new Map(a().queued).set(e,t)})}}export{on as a,kt as c,Ht as d,xt as f,Ct as h,tn as i,It as l,Tt as m,An as n,sn as o,St as p,ln as r,an as s,Ln as t,Et as u};
@@ -0,0 +1 @@
1
+ import{rt as e}from"./queries-DD_9iITj.js";import{n as t}from"./project-location-BczZtNyO.js";function n(){return{home:e().data?.homeDir??null,root:t()}}export{n as t};
@@ -0,0 +1 @@
1
+ import{_r as e,an as t}from"./queries-DD_9iITj.js";import{Zi as n,a as r,un as i}from"./project-scope-context-DNrHbqd2.js";function a(){let a=n();return e({mutationFn:e=>i(e),onSuccess:e=>a.setQueryData(t.config,e),onError:e=>r(e.message,{tone:`danger`})})}export{a as t};