@wjarka/cezarion 0.18.0-dev.7509 → 0.18.0-dev.7522
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/web/dist/assets/activity-motion-C3PyGX1i.js +2 -0
- package/web/dist/assets/{activity-route-CYetaRaf.js → activity-route-CBE9suPx.js} +1 -1
- package/web/dist/assets/attention-BOjuMCaW.js +1 -0
- package/web/dist/assets/{commit-diff-panel-D5MXcWp1.js → commit-diff-panel-BHLfoc5K.js} +1 -1
- package/web/dist/assets/diff-CPP5-PAO.js +3 -0
- package/web/dist/assets/{diff-view-De-FaJNL.js → diff-view-pVNE2LKd.js} +4 -4
- package/web/dist/assets/{file-preview-XuT7ByQJ.js → file-preview-Dnl25_Yq.js} +2 -2
- package/web/dist/assets/{git-toolbar-Cnxtcw27.js → git-toolbar-B8j0rXz_.js} +1 -1
- package/web/dist/assets/{github-4ugOBSSl.js → github-Bk_W_P7M.js} +1 -1
- package/web/dist/assets/{global-activity-route-B0RZF0VZ.js → global-activity-route-B3Bg4j74.js} +1 -1
- package/web/dist/assets/index-BUcVG7uX.js +14 -0
- package/web/dist/assets/{markdown-D9-0R3BD.js → markdown-DZFo50wI.js} +3 -3
- package/web/dist/assets/picker-pill-Bhsrt_K5.js +15 -0
- package/web/dist/assets/preview-pane-connected-B887FUPw.js +3 -0
- package/web/dist/assets/{project-router-D7rZ5E-b.js → project-router-lPPUPPDI.js} +1 -1
- package/web/dist/assets/project-scope-context-Xjbxntpg.js +4 -0
- package/web/dist/assets/prompt-template-menu-Cl8ES_lT.js +1 -0
- package/web/dist/assets/queries-D5f-3moU.js +1 -0
- package/web/dist/assets/{reference-chip-BEkQoiWt.js → reference-chip-BPdU-pFz.js} +1 -1
- package/web/dist/assets/repo-git-DkdZ-lHF.js +1 -0
- package/web/dist/assets/{report-reader-Buf2_ONr.js → report-reader-ClrhPnHJ.js} +1 -1
- package/web/dist/assets/{reports-bWP2ZBOP.js → reports-CNDxM3-h.js} +1 -1
- package/web/dist/assets/run-header-CGu_4msV.js +2 -0
- package/web/dist/assets/runners-Dc2_oqXR.js +1 -0
- package/web/dist/assets/skills-rESbVzy9.js +1 -0
- package/web/dist/assets/{tab-link-C_n2wSwD.js → tab-link-rmg3phtM.js} +1 -1
- package/web/dist/assets/task-changes-BqMvI8iD.js +1 -0
- package/web/dist/assets/{task-commits-4ClywWZW.js → task-commits-B0vE6rWz.js} +1 -1
- package/web/dist/assets/{task-files-DIQ_8hh_.js → task-files-5YPOAXtn.js} +1 -1
- package/web/dist/assets/{task-github-item-D4zs5cvm.js → task-github-item-D6VreAoa.js} +1 -1
- package/web/dist/assets/task-thread-DO2BE7tp.js +9 -0
- package/web/dist/assets/thread-state-Cn5cetra.js +4 -0
- package/web/dist/assets/{use-desktop-Dq3Z-pSO.js → use-desktop-R2WTomyJ.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-B277xMq3.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-BiIzSoTr.js → useInfiniteQuery-C05yR_S9.js} +1 -1
- package/web/dist/assets/useQuery-7jNqNIJb.js +1 -0
- package/web/dist/assets/{workflows-DX9Mpt9Q.js → workflows-fZms9I7r.js} +3 -3
- package/web/dist/assets/{ws-B3I-G6Q4.js → ws-wEXmfalm.js} +1 -1
- package/web/dist/index.html +13 -14
- package/web/dist/assets/activity-motion-mnPv6Dpn.js +0 -2
- package/web/dist/assets/agent-accounts-9EM12D_s.js +0 -1
- package/web/dist/assets/attention-DjHSGsbe.js +0 -1
- package/web/dist/assets/diff-CbzFxE4W.js +0 -3
- package/web/dist/assets/index-S6DMaCB8.js +0 -14
- package/web/dist/assets/picker-pill-CFcrs68V.js +0 -15
- package/web/dist/assets/preview-pane-connected-B1Eo_Q-v.js +0 -3
- package/web/dist/assets/project-scope-context-DYV7r53s.js +0 -4
- package/web/dist/assets/prompt-template-menu-DYoBkQJP.js +0 -1
- package/web/dist/assets/queries-Bp7cia4e.js +0 -1
- package/web/dist/assets/repo-git-CPKuF-zu.js +0 -1
- package/web/dist/assets/run-header-masTwuK9.js +0 -2
- package/web/dist/assets/runner-facts-BpvNgJqf.js +0 -1
- package/web/dist/assets/skills-BUL45j_L.js +0 -1
- package/web/dist/assets/task-changes-rmp95PMX.js +0 -1
- package/web/dist/assets/task-thread-CdBfevnO.js +0 -9
- package/web/dist/assets/thread-state-3Um_4g0a.js +0 -4
- package/web/dist/assets/use-hand-to-agent-state-BxJSA8sR.js +0 -1
- package/web/dist/assets/useQuery-BfBOHv1O.js +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
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{C as i,E as a,N as o,d as s,p as c,t as l,u,w as d}from"./button-RJMdCnZw.js";import{n as f}from"./live-refetch-CZb2VOyu.js";import{$n as p,Dr as m,E as h,Hr as g,N as _,Vr as v,Xn as y,_ as b,ar as x,d as S,i as C,jn as w,l as T,ti as E,tr as D,w as ee}from"./project-scope-context-DYV7r53s.js";import{Et as te,F as O,Jt as k,Kt as A,N as j,St as ne,W as re,X as M,Yt as N,ft as P,gt as F,m as I,n as L,ot as R,s as z,u as B,x as ie,xt as ae,yt as oe,z as se}from"./queries-Bp7cia4e.js";import{$ as ce,E as le,L as ue,Y as de,Z as fe,_ as pe,b as me,et as he,l as ge,n as _e,p as V,q as ve,tt as ye,w as be,z as H}from"./use-desktop-Dq3Z-pSO.js";import{n as U}from"./toaster-BWMQArHJ.js";import{A as xe,B as Se,F as Ce,K as we,X as Te,at as Ee,c as De,dt as Oe,f as ke,g as Ae,it as je,k as Me,l as Ne,m as Pe,n as Fe,ot as Ie,s as Le,u as W,ut as Re,v as ze,y as Be,z as Ve}from"./design-icons-B6-0w7Aw.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{_ as He,a as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,i as Ye,l as Xe,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as K,v as it,y as at}from"./run-header-masTwuK9.js";import{t as ot}from"./eye-B8okNWXU.js";import{a as st}from"./format-BNCkW110.js";import{t as ct}from"./message-square-B-MD-8rD.js";import{a as lt,c as ut,i as dt,l as ft,n as pt,o as mt,r as ht,s as gt,t as _t}from"./thread-state-3Um_4g0a.js";import{i as vt,o as yt,t as bt,u as xt}from"./reference-chip-BEkQoiWt.js";import{s as St,t as q}from"./project-router-D7rZ5E-b.js";import"./attention-DjHSGsbe.js";import{n as Ct,r as wt,t as Tt}from"./picker-pill-CFcrs68V.js";import{n as Et}from"./runner-facts-BpvNgJqf.js";import{n as Dt,t as Ot}from"./centered-state-dmABwupF.js";import{c as kt,d as At,f as jt,l as Mt,n as Nt,p as Pt,s as Ft,t as It}from"./agent-accounts-9EM12D_s.js";import{Dt as Lt,Et as Rt,Gt as zt,I as Bt,Jt as Vt,Kt as Ht,L as Ut,Ot as Wt,Pt as Gt,S as Kt,St as qt,Tt as Jt,U as Yt,V as Xt,W as Zt,Wt as Qt,Yt as $t,_ as en,_t as tn,bt as nn,c as J,cn as rn,f as an,i as on,jt as sn,kt as cn,l as Y,n as ln,pn as un,qt as dn,rn as fn,s as pn,tn as mn,u as X,un as hn,vt as gn,w as _n,xt as vn}from"./index-S6DMaCB8.js";import{t as yn}from"./zoomable-image-DefjK4q5.js";import{i as bn,r as xn,s as Sn,t as Cn}from"./markdown-D9-0R3BD.js";import{t as wn}from"./report-title-D4Mbu2Er.js";var Tn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),En=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Dn=G(`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`}]]),On=G(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),kn=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),An=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),jn=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Z=e(t(),1),Q=r(),Mn=12;function Nn({run:e}){let t=E(),n=N({mutationFn:()=>T(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:L.runs.detail(e.id)}),t.invalidateQueries({queryKey:L.runs.list()}),U(`This task will not resume itself`)},onError:e=>U(e.message,{tone:`danger`})});if(!p(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,Q.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,Q.jsx)($t,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Q.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Mn,`)`]}):(0,Q.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Q.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,Q.jsx)(c,{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 Pn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Fn=/^[A-Za-z0-9_./:=+,@%-]+$/;function In(e){return e.replaceAll(`'`,`'\\''`)}function Ln(e){return e===``?`''`:Fn.test(e)?e:`\u0027${In(e)}\u0027`}function Rn(e){if(!Pn(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(Ln).join(` `)}}function zn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Bn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Vn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Hn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Un(e){let t=zn(Bn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Hn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Hn(e[2])&&i.push({label:Vn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Vn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Hn(t)&&i.push({label:t,href:t})}return i}var Wn=(0,Z.createContext)(void 0),Gn=(0,Z.createContext)(void 0);function Kn(e,t){let n=new Map;for(let r of Un(e)){let e=bn(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function qn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Jn({text:e,messageKey:t}){let n=(0,Z.useContext)(xn),r=(0,Z.useContext)(Gn),i=t??r;if(!n||i===void 0)return null;let a=Kn(e,n);return a.length===0?null:(0,Q.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,Q.jsx)(Yn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Yn({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:a,href:o}=e,s=(0,Z.useContext)(Wn),l=(0,Z.useContext)(Kt);(0,Z.useLayoutEffect)(()=>l?.register(n,r),[l,n,r]);let u=B(r,n),f=i(),p=d();if(u.isError)return(0,Q.jsx)(c,{id:qn(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:f.pathname+f.search},children:a});let m=u.data?.artifact;if(m&&!Sn(m.name))return null;let h=new URLSearchParams(f.search);h.set(`report`,n),h.set(`card`,t);let g=new URLSearchParams(f.search).has(`report`)?f.state:null,_=new URLSearchParams(f.search);_.delete(`report`),_.delete(`card`);let v=`${f.pathname}${_.size?`?${_}`:``}`,y=window.navigation,b={reportCardEntry:!0,reportReturnTo:g?.reportReturnTo??v,reportReturnKey:g?.reportReturnKey??y?.currentEntry?.key,reportScrollTop:g?.reportScrollTop},x={pathname:f.pathname,search:`?${h}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,Q.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":u.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,Q.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:m?wn(m):a}),(0,Q.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,Q.jsx)(c,{id:qn(t,n),to:x,state:b,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=b.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;p(x,{state:{...b,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${u.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Xn={message:!0,reasoning:!0,tool:!0,hook:!0};function Zn(e){return Object.hasOwn(Xn,e)&&Xn[e]}var Qn=e=>e.kind===`tool`,$n=e=>e.kind===`conversation`,er=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,tr=(e,t,n)=>`${e} ${e===1?t:n}`;function nr(e,t){let n=[];return e>0&&n.push(tr(e,`file`,`files`)),t>0&&n.push(tr(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function rr(e){return`${e} earlier tool call${e===1?``:`s`}`}var ir=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ar(e){for(let t of ir)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function or(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Qn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Zn(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:nr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of sr(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if($n(e)){s(),c.push(e);continue}l(),Qn(e)&&er(e)&&!r.has(e.id)?o.push(e):(s(),Qn(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function sr(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var cr=new Map,lr=(0,Z.createContext)(null);function ur(){return(0,Z.useContext)(lr)}function dr({runId:e,children:t}){let n=(0,Z.useMemo)(()=>({get:t=>cr.get(e)?.get(t),set:(t,n)=>{let r=cr.get(e)??new Map;r.set(t,n),cr.set(e,r)}}),[e]);return(0,Q.jsx)(lr.Provider,{value:n,children:t})}function fr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function pr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function mr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function hr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function gr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var _r=new Map;function vr(e,t){_r.set(e,t)}function yr(e){return _r.get(e)}var br=new Map;function xr(e,t){br.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Sr(e){return br.get(e)}function Cr(e,t,n){let r=br.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var wr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),Tr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Er=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Dr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Or=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function $(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function kr(e){let t=$(e);return t===void 0?void 0:wr.format(t)}function Ar(e){let t=$(e);return t===void 0?void 0:Tr.format(t)}var jr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Mr(e){let t=$(e);return t===void 0?void 0:jr(t)}function Nr(e,t=new Date){let n=$(e);if(n===void 0)return;let r=jr(n);return r===jr(t)?`Today`:r===jr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Er:Dr).format(n)}function Pr(e,t){let n=$(e),r=$(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Fr({ts:e}){let t=kr(e);return t===void 0?null:(0,Q.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Ar(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Ir({startedAt:e,completedAt:t}){let n=kr(t);if(n===void 0)return null;let r=Pr(e,t);return(0,Q.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,Q.jsx)(`time`,{dateTime:t,title:Ar(t),children:n}),r===void 0?null:(0,Q.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Lr({ts:e}){let t=Nr(e),n=$(e);if(t===void 0||n===void 0)return null;let r=Or.format(n);return(0,Q.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,Q.jsx)(`time`,{dateTime:Mr(e),title:r,children:t}),(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Rr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function zr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Rr[e],s=r===void 0?void 0:kr(r);return(0,Q.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:u(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,Q.jsxs)(`p`,{className:u(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,Q.jsx)(ct,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,Q.jsx)(Fr,{ts:r})})]}),(0,Q.jsx)(`div`,{className:u(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function Br({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,onRemove:a,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(e),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await i?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},S=async()=>{g(!0),v(void 0);try{await a?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,Q.jsxs)(zr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,Q.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,Q.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,Q.jsx)(st,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,Q.jsxs)(zr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,Q.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(jn,{className:`size-3.5`})}):null,a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void S(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(Ee,{className:`size-3.5`})}):null]}):null,_?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,Q.jsx)(Cn,{breaks:!0,children:e}),n.length>0?(0,Q.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>x(e.split(`/`).pop()??``)?(0,Q.jsx)(yn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,Q.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(we,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,Q.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}var Vr=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Hr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ur(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Hr).forEach(e=>e.remove());let r=Un(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Hn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Wr(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Ur(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}function Gr({text:e,ts:t,messageKey:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Wr(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,Q.jsxs)(zr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Vr,children:[(0,Q.jsx)(ze,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Vr,children:[(0,Q.jsx)(hn,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,Q.jsx)(`div`,{ref:r,children:(0,Q.jsx)(Cn,{breaks:!0,children:e})}),(0,Q.jsx)(Jn,{text:e,messageKey:n})]})}function Kr({note:e}){return e.icon===`handoff`?(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,Q.jsx)(fn,{className:`size-3`})}),(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:u(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function qr({incident:e}){let t=Et(e.provider);return(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function Jr({text:e}){let t=(0,Z.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
|
-
`,1)[0]??``,r=n.length<e.length;return(0,Q.jsxs)(J,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,Q.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,Q.jsx)(Cn,{inline:!0,children:n})}),r?(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,Q.jsx)(X,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,Q.jsx)(Cn,{children:e})})})]})}function Yr(){return(0,Q.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,Q.jsx)(st,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,Q.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Xr={read:hn,edit:jn,delete:Ee,move:kn,search:Te,execute:mn,think:En,fetch:rn,task:Le,plan:Se,other:Oe},Zr=e=>e.split(`
|
|
3
|
-
`).length;function Qr({text:e,streaming:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Zr(e),s=!t&&!n&&o>12;return(0,Q.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=hr(e.currentTarget)}:void 0,className:u(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,Q.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,Q.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function $r({diffs:e}){return(0,Q.jsx)(Q.Fragment,{children:e.map((e,t)=>(0,Q.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,Q.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...ei(e.oldText).map((e,t)=>(0,Q.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...ei(e.newText).map((e,t)=>(0,Q.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
|
-
`).map((e,t)=>(0,Q.jsx)(ti,{text:e},t))})]},`${e.path}:${t}`))})}function ei(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
-
`)}function ti({text:e}){return(0,Q.jsx)(`span`,{className:u(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function ni(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function ri(e){let t=e.status===`running`||e.status===`pending`,n=ar(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Rn(e.input):gt(e.name).toolKind===e.toolKind?mt(e.name,e.input):void 0)??i,Icon:Xr[e.toolKind]??Oe}}function ii(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function ai({item:e,busy:t}){return(0,Q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,Q.jsx)(st,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,Q.jsx)(`span`,{"data-slot":`tool-exit`,className:u(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function oi({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,Q.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,Q.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,Q.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,Q.jsx)($r,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,Q.jsx)(Qr,{text:e.output,streaming:n}):null,r.length>0?(0,Q.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function si({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=ur(),[a,o]=(0,Z.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:c,verb:l,detail:d,expandedCommand:f,Icon:p}=ri(e),m=ii(e,t.length),h=f!==void 0||m,g=h&&(a??(m&&ni(e)));return(0,Q.jsxs)(J,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:s,className:u(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,Q.jsxs)(X,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:u(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,Q.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:u(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:l}),d===void 0?null:(0,Q.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,Q.jsx)(ai,{item:e,busy:c})]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(oi,{item:e,command:f,busy:c,nested:t,cacheKey:n,renderNested:r})})]})}function ci(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function li({item:e,cacheKey:t}){let n=ur(),[r,i]=(0,Z.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),c=(e.stdout??``)!==``||(e.stderr??``)!==``,l=ci(e);return(0,Q.jsxs)(J,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:u(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,Q.jsxs)(X,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,Q.jsx)(Tn,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,Q.jsx)(`code`,{title:l,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:l}),(0,Q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,Q.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,Q.jsx)(Y,{children:(0,Q.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,Q.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:u(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,Q.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),c?(0,Q.jsxs)(J,{className:`border-t border-border`,children:[(0,Q.jsxs)(X,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,Q.jsxs)(Y,{children:[e.stdout?(0,Q.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,Q.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function ui({group:e,scope:t}){return(0,Q.jsxs)(J,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,Q.jsxs)(X,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,Q.jsx)(si,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function di({count:e,children:t}){return(0,Q.jsxs)(J,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,Q.jsxs)(X,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),rr(e)]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function fi({image:e}){return(0,Q.jsx)(yn,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function pi(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 mi(e,t=null){let n=M(),r=I(),i=qt(e),a=e.removedRunner!==void 0,o=i&&!e.runner||a,s=m(n.data),c=e.runner??(i||a?r.data?.defaultRunner:void 0)??`claude`,l=Pt(t,s,c),u=s.includes(c),d=(i?D(e.workflowDef,l):[l]).filter(e=>!s.includes(e)),f=n.isSuccess&&(!o||r.isSuccess)&&d.length===0,p=pi({needsConfig:o,configPending:r.isPending,configError:r.isError,providersPending:n.isPending,providersError:n.isError,canContinue:f,untouched:i,missing:d});return{runners:s,currentRunner:c,runner:l,currentRunnerConnected:u,canContinue:f,providerPending:n.isPending||o&&r.isPending,providerError:n.isError,reason:p,runnerOverride:t!==null||!u||a?l:void 0}}function hi(e,t,n,r,i,a,o,s){let c=!r&&!n&&e.model?{...i?.defaultModels,[t]:e.model}:i?.defaultModels,l=r?null:o,u=Mt(t,a,[l,c?.[t]]),d=jt(l,t,c,a),f=Ft(t,d,a),p=r?``:s??e.effort??``,m=At(p,f);return{models:u,model:d,effortOptions:f,effort:m,mustClearStoredEffort:!r&&s===null&&p!==``&&m===``}}function gi(e,t,n,r){let i=ce(e.steps),a=i?.profileId??e.agentProfile??`default`;return{sessionStep:i,account:n?r?.[t]??`default`:a}}function _i(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 vi(e,t,n){return!!t&&(n!==he(t,e)||(e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function yi({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function bi(e){let t=A(),n=Wt(e).continueRun,r=I(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(e.id);u!==e.id&&(d(e.id),a(null),s(null),l(null));let f=mi(e,i),{runners:p,canContinue:m,currentRunner:h,runner:g}=f,_=ae(g,n),v=r.data?.modelsLocked===!0,y=g!==h,x=hi(e,g,y,v,r.data,_.data,o,c),{models:S,model:w,effortOptions:T,effort:E}=x,{modelLabel:D,effortLabel:ee}=yi(x),{sessionStep:te,account:O}=gi(e,g,y,Nt().repoAccount),j=N({mutationFn:({text:t,images:n})=>m?b(k(e.id),_i(t,n,f.runnerOverride,v,y,o,c,x)):Promise.reject(Error(f.reason??`Connect an agent provider to continue.`)),onMutate:()=>k(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof C&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}});return{skillRunner:g,skillAccount:O,available:n,canContinue:m,startsNewConversation:vi(e,te,g),reason:f.reason,providerPending:f.providerPending,pills:(0,Q.jsx)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:(0,Q.jsxs)(Ct,{children:[p.length>1?(0,Q.jsx)(wt,{icon:(0,Q.jsx)(je,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:p,value:g,onPick:e=>{e!==g&&(a(e),s(null))}}):(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(je,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:g,value:g,onPick:()=>{},options:[{value:g,label:g}]}),(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(Be,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:D,value:w,readOnly:v,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=Ft(g,e,_.data);E!==``&&At(E,t)===``&&l(``)},options:S.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:kt(g,_.data,_.isError,_.isFetching)}),(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(Me,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:ee,value:E,readOnly:v,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:T.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})}),continueWith:(e,t)=>j.mutateAsync({text:e,images:t})}}var xi=120,Si=e=>e!==`pending`&&e!==`running`,Ci=e=>e.kind===`tool`&&e.toolKind===`task`,wi=e=>Ci(e)&&e.parentItemId===void 0,Ti=e=>Zn(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function Ei(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 Di(e){if(e.kind===`tool`)return Oi(e.title);if(e.kind===`hook`)return Oi(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
|
-
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Oi(n)}}}function Oi(e){return e.length>xi?`${e.slice(0,xi-1).trimEnd()}…`:e}function ki(e,t=!1,n=e){let r=Ni(e,e=>e.items.some(wi));if(r===-1)return[];let i=e=>!t&&!Si(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(wi);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(wi)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>Ai(r,Li(n,e,r.id),t))}function Ai(e,t,n){let r={id:e.id,title:ar(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Ei(e);i!==void 0&&(r.agentType=i),n&&!Si(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Di(t[e]);if(n!==void 0){r.activity=n;break}}return r}function ji(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Mi(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Ni(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Pi(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&&wi(e));if(a!==void 0)return Ai(a,Li(r,e,t),n)}}function Fi(e,t){return Ni(e,e=>e.items.some(e=>e.id===t&&wi(e)))}function Ii(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)Ti(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function Li(e,t,n){let r=Fi(t,n);if(r===-1)return[];let i=Ii(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 Ii(e,n,Math.max(Fi(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:Ri(t,e))}return[...s.values()].sort(zi).map(({entry:e})=>e)}function Ri(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 zi(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function Bi(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`?or(e.children).flatMap(n=>Bi(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Bi(e,t)):[]}function Vi(e){return e.flatMap((e,t)=>e.content.kind===`block`?Bi(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Hi(e,t,n,r){let i=(0,Z.useContext)(Kt),{projectId:o}=a(),s=(0,Z.useMemo)(()=>Vi(t),[t]);(0,Z.useLayoutEffect)(()=>{if(!i)return;let t=[],a={runId:e,...o?{projectId:o}:{}};for(let e of s){let o=Kn(e.text,a);for(let e of o)t.push(i.register(e.artifactId,e.runId));r===`document`&&o.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=qn(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,s,e,o,r,n.jumpToRow])}function Ui(e){let t=E();return N({mutationFn:t=>h(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:L.runs.all})}})}var Wi=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Gi=()=>navigator.onLine;function Ki({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,Q.jsx)(Ji,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,Q.jsx)(qi,{permission:e,runId:t},e.requestId)}function qi({permission:e,runId:t}){let n=Ui(t),r=(0,Z.useSyncExternalStore)(Wi,Gi,()=>!1),i=(0,Z.useRef)(!1),[a,o]=(0,Z.useState)(`pending`),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(),d=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 C&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,Q.jsx)(Ji,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Ji({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Z.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,Q.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-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,Q.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,Q.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,Q.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,Q.jsx)(l,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [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,Q.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}function Yi(e,t){if(e.length===1)return[t.replace(RegExp(`^${Xi(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Zi(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}function Qi({ask:e}){let t=e.answer===void 0?void 0:Yi(e.questions,e.answer);return(0,Q.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=Zi(n,i),o=i!==void 0&&a.length===0;return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,Q.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,Q.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,Q.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,Q.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,Q.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,Q.jsx)($i,{text:i}):null]})]}):i===void 0?null:(0,Q.jsx)($i,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,Q.jsx)($i,{text:e.answer}):null]})}function $i({text:e}){return(0,Q.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}var ea=(0,Z.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function ta(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 na(e,t,n=[]){let r={};for(let e of n)r[e.id]=H(e);for(let e of t??[])r[e.id]=H(e);return r[e.id]=H(e),r}function ra(e,t){return t?.[e]??`Task`}function ia(e,t,n){return t?n?.[e]??`peer task`:ra(e,n)}function aa(e,t){return e.senderRunId===t?`outbound`:`inbound`}function oa(e){return e?.relationship===`peer`}function sa(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function ca(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 la(e){if(e.outcome)return ca(e.outcome.status);if(e.delivery===`not-delivered`)return ua(`not-delivered`)}function ua(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function da(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`?oa(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 ${sn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function fa({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:ra(e,n),linkable:!0}):(0,Q.jsx)(pa,{id:e,children:r})}function pa({id:e,children:t}){let n=P(e);return n.data?t({title:H(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof C&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var ma={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`}},ha=`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 ga({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,Q.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,Q.jsx)(_a,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function _a({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=aa(e.messages[0]??{senderRunId:e.senderRunId},t),a=oa(e.messages[0]),o=ma[a?`peer`:i],s=Ea(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),c=i===`outbound`?`SENT to`:`RECEIVED from`,l=`${c} ${s.map(e=>ia(e,a,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,Q.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:u(`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,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:u(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,Q.jsx)(`span`,{children:c}),s.map((e,t)=>(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,Q.jsx)(fa,{id:e,peer:a,taskTitles:n,children:t=>(0,Q.jsx)(Sa,{view:t,to:`/tasks/${e}`,label:`${c} ${t.title}`})})]},e))]}),a?(0,Q.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,Q.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:sa(e.kind)}),e.messages.length===1&&d?(0,Q.jsx)(ya,{message:d}):null]}),(0,Q.jsx)(va,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,Q.jsx)(xa,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>da(e,r?.[e.recipientRunId])))].map(e=>e?(0,Q.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,Q.jsx)(ba,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,Q.jsx)(Ca,{message:d,runId:t,taskTitles:n}):null,(0,Q.jsx)(wa,{batch:e,heading:l})]})}function va({at:e,className:t,children:n}){return e===void 0||kr(e)===void 0?null:(0,Q.jsxs)(`span`,{className:t,children:[n,(0,Q.jsx)(Fr,{ts:e})]})}function ya({message:e}){let t=la(e),n=ua(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,Q.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function ba({messages:e,peer:t,runId:n,taskTitles:r}){return(0,Q.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=la(e),a=e.createdAt??e.recordedAt;return(0,Q.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(fa,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,Q.jsx)(Sa,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,Q.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,ua(e.delivery)===i?null:(0,Q.jsx)(`span`,{"data-slot":`conversation-delivery`,children:ua(e.delivery)}),(0,Q.jsx)(Ca,{message:e,runId:n,taskTitles:r}),(0,Q.jsx)(va,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function xa({batch:e}){let t=ur(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Z.useState)(()=>t?.get(n)??!1),a=(0,Q.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,Q.jsx)(Cn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,Q.jsxs)(J,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,Q.jsxs)(X,{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,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,Q.jsx)(Y,{children:a})]})}function Sa({view:e,to:t,label:n}){return e.linkable?(0,Q.jsx)(q,{className:ha,to:t,"aria-label":n,children:e.title}):(0,Q.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function Ca({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Z.useContext)(ea),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,Q.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=aa(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:u(ha,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,Q.jsx)(fa,{id:i,peer:oa(e.message),taskTitles:n,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[`View `,c,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function wa({batch:e,heading:t}){return(0,Q.jsxs)(J,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,Q.jsxs)(X,{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,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,Q.jsx)(Y,{children:(0,Q.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>Ta(e)).map((e,t)=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,Q.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function Ta(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...oa(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:ua(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 Ea(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var Da=e(n(),1),Oa=`pending-ask`;function ka(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function Aa(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?ka(t):null}function ja(e,t){let n=`${Oa}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?Aa(r):null}}function Ma(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function Na({onGoToQuestion:e}){return(0,Q.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,Q.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,Q.jsx)(l,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}var Pa={viewKey:void 0,generation:0},Fa=600,Ia=24;function La(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Z.useRef)(e);o.current=e;let s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),p=(0,Z.useRef)(!0),m=(0,Z.useRef)(0),h=(0,Z.useRef)(0),g=(0,Z.useRef)(new Set),_=(0,Z.useCallback)(e=>{for(let t of[...g.current])t(e)},[]),v=(0,Z.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),C=(0,Z.useCallback)(e=>{let t=s.current;if(!t)return;let n=S.current;n?n.scrollTo(e):t.scrollTop=e},[]),w=(0,Z.useCallback)(()=>{let e=s.current;e&&C(e.scrollHeight-e.clientHeight)},[C]),T=(0,Z.useCallback)(()=>{if(s.current){if(x.current!==e){x.current=e;let t=yr(e);t&&!t.atBottom?(p.current=!1,y.current=t.top,b.current=Sr(e)?.rowKeys?{viewKey:e,top:t.top}:null):(p.current=!0,y.current=null,b.current=null)}y.current===null?p.current&&w():C(y.current)}},[e,C,w]),E=(0,Z.useCallback)(e=>b.current?.viewKey===e,[]),D=(0,Z.useCallback)(e=>{let t=b.current;return!t||!E(e)||e!==o.current?!1:(y.current=t.top,p.current=!1,b.current=null,!0)},[E]),ee=(0,Z.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),T())},[n,T]),te=(0,Z.useCallback)(()=>{p.current&&w()},[w]),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(0),A=(0,Z.useRef)(!1),j=(0,Z.useRef)(void 0),ne=(0,Z.useRef)(!1),re=(0,Z.useRef)(!1),M=(0,Z.useRef)(a);M.current=a;let N=(0,Z.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}}),[]),P=(0,Z.useRef)(null),F=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{if(!f())return;let e=e=>{y.current=null,b.current=null,F.current+=1,P.current=null,p.current=!1,C(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[C]);let I=(0,Z.useCallback)(()=>{let e=P.current,t=s.current;if(!e||!t)return;P.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:M.current.indexOf(e.anchor.key),a=S.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):C(mr(t.scrollTop,r,e.anchor,N(t),n))},[N,C]),L=(0,Z.useCallback)(()=>{let e=s.current;if(!e||!r||O.current)return;y.current=null,b.current=null,p.current=!1,O.current=!0;let t=k.current+1;k.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=pr(a,N(e)),l=c===void 0?-1:M.current.indexOf(c.key),u=o.current,d=F.current;r().then(()=>{o.current===u&&F.current===d&&(P.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{k.current===t&&(O.current=!1)})},[N,r]);(0,Z.useEffect)(()=>()=>clearTimeout(j.current),[]);let R=(0,Z.useRef)(null),z=(0,Z.useRef)(0),B=(0,Z.useCallback)(()=>n===`document`?++Pa.generation:++z.current,[n]),ie=(0,Z.useCallback)((e,t)=>n===`document`?Pa.viewKey===e&&Pa.generation===t:o.current===e&&z.current===t,[n]);(0,Z.useEffect)(()=>()=>R.current?.disconnect(),[e,c]);let ae=(0,Z.useCallback)((t,n,r,i)=>{let a=s.current;if(!a||!c)return;y.current=null,b.current=null,F.current+=1,P.current=null,p.current=!1,m.current=0,d(!0),B(),R.current?.disconnect();let o=()=>[...c.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),l=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(R.current?.disconnect(),!0):!1},u=a.querySelector(`[data-slot="run-header"]`),f=u&&getComputedStyle(u).position===`sticky`?u.getBoundingClientRect().height:0,h=S.current;if(i!==void 0)C(i);else if(h)h.scrollToIndex(n,{align:`start`,...f>0?{offset:-f}:{}});else{let e=o();e&&C(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-f)}l()||(R.current=new MutationObserver(()=>{l()}),R.current.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),vr(e,{top:i??a.scrollTop,atBottom:!1})},[c,C,e,B]),oe=(0,Z.useCallback)(t=>{let n=B(),r=o.current;R.current?.disconnect();let a=s.current;if(!a)return;y.current=null,b.current=null,F.current+=1,P.current=null,p.current=!0,h.current=0,_({direction:`tail`}),vr(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let c=()=>{p.current&&w()},l=()=>ie(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>{if(c(),!t||!l()||u())return;R.current?.disconnect();let e=new MutationObserver(()=>{l()?u()&&e.disconnect():e.disconnect()});R.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,w,B,ie,_]),se=a.at(-1),ce=a.length;return(0,Z.useLayoutEffect)(()=>{F.current+=1,P.current=null,O.current=!1,n===`document`?Pa.viewKey!==e&&(Pa.viewKey=e,Pa.generation+=1):z.current+=1},[e,n]),(0,Z.useLayoutEffect)(()=>{let e=P.current;e?(e.anchor===void 0?-1:M.current.indexOf(e.anchor.key))>e.anchorIndex?I():P.current=null:p.current&&w()},[se,ce,I,w]),(0,Z.useLayoutEffect)(()=>{!s.current||!c||T()},[c,T]),(0,Z.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;m.current=0;let r=null,i=!1,a=t.scrollTop,o,l=0,u,f=e=>{h.current=Date.now(),u=e},g=()=>{B(),R.current?.disconnect(),y.current=null,b.current=null,F.current+=1,P.current=null,p.current=!1,m.current=0},v=()=>{y.current=null,b.current=null,F.current+=1,P.current=null,m.current=Date.now()},x=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){g();let e=!A.current;A.current=!0,clearTimeout(j.current),j.current=setTimeout(()=>{A.current=!1},180),e&&fr(t)&&L()}else v()},S=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),g(),!e.repeat&&fr(t)&&L()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),v())},T=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,re.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||(y.current=null,b.current=null,hr(t,80)||(g(),v()))},D=()=>{i=!1},ee=e=>{ne.current=!1,r=e.touches[0]?.clientY??null},te=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),g(),!ne.current&&fr(t)&&(ne.current=!0,L())):r!==null&&n<r-1&&(f(`down`),v()),r=n)},O=e=>{if(e===0||!i&&Date.now()-h.current>=Fa)return;let n=e<0?`up`:`down`;!i&&n!==u||(n!==o&&(o=n,l=0),l+=Math.abs(e),l>=Ia&&(0,Da.flushSync)(()=>_({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},k=()=>{let n=p.current;O(t.scrollTop-a),i&&t.scrollTop!==a&&(t.scrollTop<a?g():v()),i&&!re.current&&t.scrollTop<a&&fr(t)&&(re.current=!0,L()),a=t.scrollTop;let r=hr(t,80);r&&y.current===null&&(p.current||Date.now()-m.current<2e3)&&(p.current=!0),!n&&p.current&&_({direction:`tail`}),d(!r),y.current===null&&!E(e)&&vr(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,k,{passive:!0}),t.addEventListener(`wheel`,x,{passive:!0}),t.addEventListener(`touchstart`,ee,{passive:!0}),t.addEventListener(`touchmove`,te,{passive:!0}),t.addEventListener(`pointerdown`,T,{passive:!0}),window.addEventListener(`pointerup`,D,{passive:!0}),window.addEventListener(`pointercancel`,D,{passive:!0}),t.addEventListener(`keydown`,S);let M;if(typeof ResizeObserver<`u`){M=new ResizeObserver(()=>{let e=y.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;C(Math.min(e,n)),n>=e&&(y.current=null)}else p.current&&w()}),M.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&&M.observe(r),i&&M.observe(i)}return()=>{t.removeEventListener(`scroll`,k),t.removeEventListener(`wheel`,x),t.removeEventListener(`touchstart`,ee),t.removeEventListener(`touchmove`,te),t.removeEventListener(`pointerdown`,T),window.removeEventListener(`pointerup`,D),window.removeEventListener(`pointercancel`,D),t.removeEventListener(`keydown`,S),M?.disconnect()}},[e,c,L,C,w,E,B,_]),{attachContent:ee,scrollElRef:s,virtualizerRef:S,restoreMeasurements:D,ownsMeasurementRestore:E,pillVisible:u,jumpToLatest:oe,jumpToRow:ae,loadOlder:L,restickIfStuck:te,subscribeReaderScroll:v}}function Ra({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Q.jsx)(za,{runId:e,rows:t,controls:r}):(0,Q.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,Q.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 za({runId:e,rows:t,controls:n}){return(0,Q.jsx)(Ba,{runId:e,rows:t,controls:n},e)}function Ba({runId:e,rows:t,controls:n}){let r=(0,Z.useRef)(null),i=(0,Z.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,Z.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Z.useState)(()=>Sr(e)),[l,u]=(0,Z.useState)(()=>({cache:Cr(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Z.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Z.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,Z.useRef)(t.length);f.current=t.length;let p=(0,Z.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Z.useRef)(null),h=(0,Z.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||xr(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Z.useState)(0);return(0,Z.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,Q.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,Q.jsx)(pn,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,Q.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 Va({onJump:e,pendingQuestions:t=0}){return(0,Q.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 gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`size-3.5`}),Ma(t)]})}function Ha(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function Ua(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ha(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 Wa(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}function Ga(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let n of t.turns)c.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:Ua(e,n.items.filter(t=>!e.task||!ut(t,`opening`)).map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Wa(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e))});let l=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return l.length>0&&c.push({id:`pending-permissions`,entries:l,inDaySequence:!1}),i!==void 0&&c.push({id:Oa,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}function Ka(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 qa(e,t){return[{id:`agent:${e}`,entries:t}]}function Ja(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Ya(e,t){let n=[],r;for(let t of e){let e=Ja(t),i=Mr(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 or([...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 Xa({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,Z.useMemo)(()=>Ya(n,e),[n,e]),p=La(`${e}:${t}`,{surface:r}),m=c??p;Hi(e,f,m,r);let h=(0,Z.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,Z.useMemo)(()=>f.map(t=>({key:t.key,node:Za(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??gr(``,g.length),v=g.length===0?i??null:(0,Q.jsx)(Ra,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,Q.jsx)(Ke,{runId:e,children:(0,Q.jsx)(dr,{runId:e,children:(0,Q.jsx)(ea.Provider,{value:h,children:r===`panel`?(0,Q.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,Q.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,Q.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,Q.jsx)(Va,{onJump:m.jumpToLatest})}):null]}):v})})})}function Za(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,Q.jsx)(Qa,{message:e.content.message,actions:t});case`day-separator`:return(0,Q.jsx)(Lr,{ts:e.content.ts});case`turn-time`:return(0,Q.jsx)(Ir,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,Q.jsx)($a,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return ro(e.content)}}function Qa({message:e,actions:t}){return(0,Q.jsx)(Br,{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,Q.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,Q.jsx)(Qi,{ask:e.ask})}):void 0})}function $a({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,Q.jsx)(Gn.Provider,{value:`${t}:${e.entry.id}`,children:(0,Q.jsx)(to,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,Q.jsx)(si,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Q.jsx)(eo,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,Q.jsx)(ui,{group:e,scope:t});case`streak`:return(0,Q.jsx)(di,{count:e.count,children:e.blocks.map(e=>(0,Q.jsx)($a,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,Q.jsx)(ga,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return ro(e)}}function eo({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return or([...e]).map(e=>(0,Q.jsx)($a,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function to({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,Q.jsx)(Gr,{text:e.text,ts:e.ts}):(0,Q.jsx)(Br,{text:e.text,ts:e.ts});case`reasoning`:return(0,Q.jsx)(Jr,{text:e.text});case`tool`:return(0,Q.jsx)(si,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Q.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?` · ${ua(e.delivery)}`:``]}),(0,Q.jsx)(Kr,{note:e})]}):(0,Q.jsx)(Kr,{note:e});case`conversation`:return(0,Q.jsx)(ga,{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,Q.jsx)(fi,{image:e});case`ask`:return n===void 0?(0,Q.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,Q.jsx)(Ki,{permission:e,runId:i});case`provider-auth-required`:return(0,Q.jsx)(qr,{incident:e});case`preview-server`:return(0,Q.jsx)(no,{entry:e});case`hook`:return(0,Q.jsx)(li,{item:e,cacheKey:`${t}:${e.id}`});default:return ro(e)}}function no({entry:e}){let t=en(),n=j().data?.capabilities?.preview===!0;return(0,Q.jsx)(ft,{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 ro(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function io({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,Z.useContext)(Kt),l=(0,Z.useRef)(void 0),u=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,Q.jsx)(Qt,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,Q.jsx)(zt,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.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,Q.jsx)(Wn.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,Q.jsx)(ao,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function ao({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(dn,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Q.jsxs)(Vt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,Q.jsxs)(Ht,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(oo,{status:r.status}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Q.jsx)(Xa,{runId:e,viewId:`agent:${r.id}`,sections:qa(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,Q.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 oo({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,Q.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:u(`rounded-full px-2 py-0.5 text-[11px] 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})}var so=/^diff --git /;function co(e){let t=e.replace(so,``),n=t.lastIndexOf(` b/`);return lo(n>=0?t.slice(n+3):t)}function lo(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function uo(e){let t=lo(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function fo(e){return{path:co(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function po(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=lo(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=lo(t.slice(10));else if(t.startsWith(`new file mode`))e.status=`added`;else if(t.startsWith(`deleted file mode`))e.status=`deleted`;else if(t.startsWith(`Binary files `)||t===`GIT binary patch`)e.binary=!0;else if(t.startsWith(`+++ `)){let n=uo(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=uo(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function mo(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function ho(e){let t=[],n=null,r=!1;for(let i of e.split(`
|
|
7
|
-
`)){if(so.test(i)){n=fo(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):po(n,i);continue}mo(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function go(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var _o=20,vo=300;function yo({runId:e}){let t=E(),n=F(e);(0,Z.useEffect)(()=>{t.invalidateQueries({queryKey:L.runs.diff(e)})},[t,e]);let r=(0,Z.useMemo)(()=>ho(n.data??``),[n.data]),[i,a]=(0,Z.useState)(!1);if(n.isPending)return(0,Q.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,Q.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(r.length===0)return(0,Q.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let o=go(r),s=i?r:r.slice(0,_o);return(0,Q.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[o.files,` `,o.files===1?`file`:`files`,` changed`]}),(0,Q.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,o.additions]}),` `,(0,Q.jsxs)(`span`,{className:`text-danger`,children:[`−`,o.deletions]})]})]}),s.map(e=>(0,Q.jsx)(xo,{file:e},`${e.oldPath??``}→${e.path}`)),r.length>s.length?(0,Q.jsxs)(l,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>a(!0),children:[`Show `,r.length-s.length,` more files`]}):null]})}var bo={added:`added`,deleted:`deleted`,renamed:`renamed`};function xo({file:e}){let[t,n]=(0,Z.useState)(!0),r=bo[e.status];return(0,Q.jsxs)(J,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,Q.jsxs)(X,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,Q.jsx)(un,{className:u(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,Q.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,Q.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,Q.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,Q.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,Q.jsx)(So,{lines:e.lines})})})]})}function So({lines:e}){let[t,n]=(0,Z.useState)(!1),r=t?e:e.slice(0,vo),i=r.join(`
|
|
8
|
-
`),[a,o]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let e=!1;return Yt(i,`diff`).then(t=>{e||o({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let s=a?.text===i?a.tokens:Zt(i,`diff`)?.tokens??null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,Q.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:u(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[s?.[t]===void 0?e:s[t].map((e,t)=>(0,Q.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>vo?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function Co(e){let t=E();return N({mutationFn:()=>_(e),onSuccess:()=>t.invalidateQueries({queryKey:L.runs.all}),onError:e=>U(e.message,{tone:`danger`})})}function wo({run:e}){return(0,Q.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2.5`,children:[(0,Q.jsx)(ot,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,Q.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,Q.jsx)(yo,{runId:e.id}),(0,Q.jsx)(To,{run:e})]})}function To({run:e}){let t=A(),n=E(),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(null),u=Co(e.id),d=mi(e),f=()=>n.invalidateQueries({queryKey:L.runs.all}),p=N({mutationFn:async t=>d.canContinue?b(k(e.id),{text:`Review feedback:\n${t}`,runner:d.runnerOverride}):null,onMutate:()=>k(e.id),onSuccess:(e,n,r)=>{e!==null&&(a(``),t.invalidateAfter(`continue`,r))},onError:e=>U(e.message,{tone:`danger`})}),m=N({mutationFn:()=>ee(e.id),onSuccess:e=>{U(`Draft PR created — ${e.url}`),f()},onError:e=>{e instanceof C&&e.manual!==void 0&&c(e.manual),U(e.message,{tone:`danger`})}}),h=()=>{let e=i.trim();if(e.length===0){U(`Write what to change first.`),r.current?.focus();return}p.mutate(e)};return(0,Q.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Xt,{ref:r,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{Ut({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},className:`min-h-[52px] text-[13px]`}),d.canContinue?null:(0,Q.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:d.reason}),d.providerPending?null:(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(l,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:d.reason??`Send the notes back into the agent's session`,"aria-describedby":d.canContinue?void 0:`review-provider-guidance`,disabled:p.isPending||!d.canContinue,onClick:h,children:[(0,Q.jsx)(On,{"aria-hidden":`true`}),`Send back`]}),s(e.pullRequestUrl)?(0,Q.jsx)(l,{asChild:!0,variant:`outline`,size:`sm`,children:(0,Q.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,Q.jsx)(ye,{"aria-hidden":`true`}),`PR ↗`]})}):(0,Q.jsxs)(l,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:m.isPending,onClick:()=>m.mutate(),children:[(0,Q.jsx)(Ce,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,Q.jsxs)(l,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:nn(`review`),disabled:u.isPending,onClick:()=>u.mutate(),children:[(0,Q.jsx)(De,{"aria-hidden":`true`}),`Accept`]}):null]}),o===null?null:(0,Q.jsx)(Eo,{command:o})]})}function Eo({command:e}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>U(`Command copied to clipboard.`)).catch(()=>U(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(ze,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function Do(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Oo=1500;function ko({status:e}){let t=(0,Z.useRef)(e),[n,r]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||Do())return;r(!0);let i=setTimeout(()=>r(!1),Oo);return()=>clearTimeout(i)},[e]),n?(0,Q.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,Q.jsx)(Dt,{}),(0,Q.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,Q.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function Ao(e){let t=E(),[n,r]=(0,Z.useState)(),i=ve(e);(0,Z.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=N({mutationFn:async()=>{r(e.id);try{if(!(await S(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:L.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function jo({agents:e,onSelect:t}){return e.length===0?null:(0,Q.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,Q.jsx)(Mo,{agent:e,onSelect:t},e.id))})}function Mo({agent:e,onSelect:t}){let n=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(No,{status:e.status,stalled:e.stalled===!0}),(0,Q.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Q.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Mi(e)}),(0,Q.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,Q.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,Q.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,Q.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function No({status:e,stalled:t=!1}){return t?(0,Q.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,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,Q.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,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Q.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,Q.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,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Q.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,Q.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,Q.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Q.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Po(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Fo({entries:e}){return e.length===0?null:(0,Q.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,Q.jsx)(Io,{entry:e},`${t}:${e.content}`))})}function Io({entry:e}){return(0,Q.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:u(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,Q.jsx)(Lo,{status:e.status}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,Q.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function Lo({status:e}){return e===`cancelled`?(0,Q.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Q.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Q.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,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Q.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Q.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,Q.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Q.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Q.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,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function Ro(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 zo(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 Bo({steps:e}){if(e.length===0)return null;let t=zo(e)*100;return(0,Q.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,Q.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Ro(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,Q.jsx)(Vo,{visual:Ro(t.status)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,Q.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,Q.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,Q.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function Vo({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Q.jsx)(ke,{"aria-hidden":!0,className:u(t,`text-success`)});case`active`:return(0,Q.jsx)(st,{role:`status`,"aria-label":`Step running`,className:u(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,Q.jsx)(Ae,{"aria-hidden":!0,className:u(t,`text-danger`)});case`pending`:return(0,Q.jsx)(Pe,{"aria-hidden":!0,className:u(t,`text-soft-foreground`)})}}var Ho={done:`done`,failed:`failed`,cancelled:`cancelled`};function Uo(e){let t=Ho[e.status];return t?e.steps.map(e=>Ro(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):e.steps}function Wo(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>Ro(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 Go({items:e,lead:t=0}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(-1/0);return(0,Z.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,Q.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`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`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,Q.jsx)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&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:n.content},n.id)})})}function Ko({run:e,references:t}){return(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,Q.jsx)(bt,{reference:t,taskTitle:H(e),inert:!0},V(t)))})}function qo(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?It(e.accounts,e.accountBackend)?`default`:void 0:e.known?It(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Jo(e){let t=I(),n=z(),{accounts:r}=Nt(),i=e.runner??t.data?.defaultRunner??`claude`,a=e.model??`auto`,o=e.effort||`auto`,s=[...e.steps].reverse().find(e=>e.profileId),c=s?.profileId,l=s?.backend??i,u=n.data?.profiles.find(e=>e.id===c&&e.provider===l),d=qo({accountId:c,profilesPending:n.isPending,profilesError:n.isError,known:u,accounts:r,accountBackend:l}),f=e.modelIdentity&&e.modelIdentity!==a?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?i:v(e.removedRunner),...d?{account:d}:{},model:a,effort:o,...f?{identity:f}:{}}}var Yo=[`running`,`queued`,`waiting`];function Xo(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`):[]}function Zo(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 Qo(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 $o(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function es(e){let t=Xo(e.waits),n=Yo.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&$o(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Xo(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 ts(e){return es(e)!==void 0}function ns(e){return(es(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function rs({run:e}){let t=es(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,Q.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,Q.jsx)(as,{run:e,wait:t},t.id):t.kind===`worker`?(0,Q.jsx)(os,{wait:t},t.id):t.kind===`process`?(0,Q.jsx)(ds,{run:e,wait:t},t.id):t.kind===`peer`?(0,Q.jsx)(ss,{wait:t},t.id):t.kind===`subagent`?(0,Q.jsx)(cs,{wait:t},t.id):(0,Q.jsx)(ls,{run:e,wait:t},t.id)),i?(0,Q.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,Q.jsx)(as,{run:e,wait:r,settled:!0}):null,a?(0,Q.jsx)(ds,{run:e,wait:a,settled:!0}):null]})}function is(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`,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.slice(0,7)} → ${r?.observedHeadSha?.slice(0,7)??`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`?Qo(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function as({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,a=n&&t.phase===`cancelled`,o=is(e,t,n),c=n?a?t.cancelledAt:r?.observedAt:t.deadline,l=Zo(c),u=`${t.repository}#${t.prNumber}`;return(0,Q.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,Q.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,Q.jsx)(`dd`,{children:o}),(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,Q.jsx)(`dd`,{className:`min-w-0`,children:s(t.prUrl)?(0,Q.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:u}):(0,Q.jsx)(`span`,{children:u})}),l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?a?`Cancelled`:`Observed`:`Deadline`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,Q.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function os({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=Zo(e.deadline);return(0,Q.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,Q.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,Q.jsxs)(`p`,{children:[`Deadline`,` `,(0,Q.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,Q.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function ss({wait:e}){let t=e.peerIds.length,n=Zo(e.deadline);return(0,Q.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,Q.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,Q.jsxs)(`p`,{children:[`Deadline`,` `,(0,Q.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Q.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function cs({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=Zo(e.deadline);return(0,Q.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,Q.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,Q.jsxs)(`p`,{children:[`Check by`,` `,(0,Q.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Q.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function ls({run:e,wait:t}){let n=Zo(t.deadline);return(0,Q.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,Q.jsx)(`p`,{children:Qo(`Automatic check due`,e)}):n?(0,Q.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,Q.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,Q.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,Q.jsx)(`p`,{children:t.note}):null]})}function us(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 ds({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?us(t):t.phase===`resolved`?Qo(us(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?Zo(t.deadline):void 0;return(0,Q.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,Q.jsx)(`p`,{children:r}),i?(0,Q.jsxs)(`p`,{children:[`Until`,` `,(0,Q.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var fs=new Map,ps=new Map;function ms(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=He(e.run);return(0,Q.jsx)(vt,{projectId:t,repoBase:n,requests:i,children:(0,Q.jsx)(hs,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!me(e.run)||!!pe(e.run,n)})})}function hs({run:e,thread:t,currentThread:n,currentComplete:r=!0,onOpenWorker:i,readerScroll:a,prNumbers:o,hasReferences:s,references:c}){let l=_e(),u=Jo(e),[d,f]=(0,Z.useState)(()=>fs.get(e.id)??!1),p=js(a,d),m=p.open,[h,g]=(0,Z.useState)({}),_=gs(e,t??n,n,r,o),v=qe(e),y=t=>h[t]??ps.get(`${e.id}:${t}`)??t===`workers`,b=t=>{let n=!y(t);ps.set(`${e.id}:${t}`,n),g(e=>({...e,[t]:n}))},x=e=>({open:y(e),onToggle:()=>b(e)});return(0,Q.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:p.ref,"data-state":m?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Q.jsx)(xs,{run:e,identity:u,activity:_,references:c,open:m,onToggle:()=>{fs.set(e.id,!m),f(!m),p.chose(!m)}}),m?(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,Q.jsx)(ws,{run:e,activity:_,...x(`status`)}),(0,Q.jsx)(Ts,{run:e,desktop:l,automations:_.automations,...x(`workflow`)}),(0,Q.jsx)(Es,{activity:_,desktop:l,onOpenWorker:i,...x(`subagents`)}),(0,Q.jsx)(Ds,{run:e,...x(`workers`)}),(0,Q.jsx)(Os,{activity:_,desktop:l,...x(`plan`)}),(0,Q.jsx)(ks,{run:e,identity:u,activity:_,...x(`usage`)}),(0,Q.jsx)(As,{run:e,references:c,conflicts:_.conflicts,hasReferences:s,onResume:()=>v.mutate(),...x(`workspace`)})]}):null]})}function gs(e,t,n,r,i){let a=j(),o=ln(a.data),s=ne(),c=it(e,{queuePosition:e.status===`queued`?ue(s.data??[]).get(e.id):void 0}),l=yt(i),u=!de(e)&&e.status!==`queued`,d=(0,Z.useMemo)(()=>r?ki(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),f=_t(n)??[],p=Xe(e),m=ji(d),h=Po(f);return{line:c,..._s(e,c,p,r?m:void 0,h),...vs(e,o),conflicts:l,waitReferences:ns(e),agents:d,agentCounts:m,planEntries:f,planCounts:h,automations:Gt(a.data)}}function _s(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`||e.status===`cancelled`,glyph:o?(0,Q.jsx)(ke,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,Q.jsx)($t,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function vs(e,t){return{cost:t.cost&&e.costUsd!==void 0?ge(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,Q.jsx)(on,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function ys(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function bs(e){let t=Uo(e),n=Wo(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function xs({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:o}=n,s=[...new Map([...r,...n.waitReferences].map(e=>[V(e),e])).values()];return(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":Ss(e,t,n,s,i),onClick:a,className:u(`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,Q.jsx)(Ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,Q.jsx)(Cs,{run:e,identity:t,activity:n,summaryReferences:s}),i&&o?(0,Q.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:o}):null,(0,Q.jsx)(Ne,{"aria-hidden":!0,className:u(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!o&&`ms-auto`,i&&`rotate-180`)})]})}function Ss(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=bs(e)?.step,u=l?Ro(l.status):void 0,d=l?`; step ${l.name}, ${u===`active`?`running`:u}`:``,f=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${d}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${f}`}function Cs({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:o}=n,s=bs(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,Q.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||o.length?[{id:`chips`,priority:0,content:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ko,{run:e,references:r}),o.length>0?(0,Q.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Q.jsx)(Ie,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:u(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,ys(n)),children:[n.glyph,(0,Q.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),s?(0,Q.jsxs)(`span`,{"data-slot":`run-activity-step`,className:`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,children:[(0,Q.jsx)(Fs,{step:s,decorative:!0}),(0,Q.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:s.name,className:`min-w-0 truncate`,children:s.name})]}):null,(0,Q.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,Q.jsx)(Go,{items:c,lead:8})})]})}function ws({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,o=$e(e);return(0,Q.jsxs)(K,{slot:`status-row`,icon:t.glyph,title:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{"data-slot":`run-activity-status`,className:u(`truncate`,ys(t)),children:t.statusText}),i.nextCheck?(0,Q.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,Q.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,Q.jsx)(Go,{items:[{id:`chips`,priority:0,content:(0,Q.jsx)(Ko,{run:e,references:a})}]}):void 0,open:n,onToggle:ts(e)||o?r:void 0,children:[(0,Q.jsx)(rs,{run:e}),o?(0,Q.jsx)(Ye,{run:e}):null]})}function Ts({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=be(e),o=bs(e);return!a&&!o?null:(0,Q.jsxs)(K,{slot:`workflow`,icon:o?(0,Q.jsx)(Fs,{step:o.step}):(0,Q.jsx)(Re,{className:`size-4`}),title:(0,Q.jsxs)(Q.Fragment,{children:[`Workflow`,a?(0,Q.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:Ge(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,Q.jsx)(Bo,{steps:o.steps}):null,(0,Q.jsx)(Ps,{run:e,available:n})]})}function Es({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,Q.jsx)(K,{slot:`subagents`,icon:(0,Q.jsx)(Le,{className:`size-4`}),title:`Subagents`,meta:Ge(o.done,o.total,t),open:r,onToggle:i,children:(0,Q.jsx)(jo,{agents:a,onSelect:n})})}function Ds({run:e,open:t,onToggle:n}){return nt(e)?(0,Q.jsx)(tt,{run:e,open:t,onToggle:n}):null}function Os({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,Q.jsx)(K,{slot:`plan`,icon:(0,Q.jsx)(Se,{className:`size-4`}),title:`Plan`,meta:Ge(a.done,a.total,t),open:n,onToggle:r,children:(0,Q.jsx)(Fo,{entries:i})})}function ks({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,Q.jsx)(K,{slot:`usage`,icon:(0,Q.jsx)(Dn,{className:`size-4`}),title:`Usage & agent`,summary:(0,Q.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Q.jsx)(Go,{items:c})}),open:r,onToggle:i,children:(0,Q.jsx)(Ns,{run:e,tokens:o,cost:a})})}function As({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||Lt(e)||Ue(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,Q.jsx)(K,{slot:`workspace`,icon:(0,Q.jsx)(xe,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,Q.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Q.jsx)(Go,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,Q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,Q.jsx)(Ko,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,Q.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Q.jsx)(Ie,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,Q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,Q.jsx)(Qe,{state:s}):null,(0,Q.jsx)(Ze,{run:e}),e.branch?(0,Q.jsx)(Ms,{label:`Branch`,children:(0,Q.jsx)(et,{branch:e.branch})}):null,e.worktreePath?(0,Q.jsx)(Ms,{label:`Worktree`,children:(0,Q.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,Q.jsx)(Je,{run:e,canResume:Wt(e).terminal,onResume:i})]})})}function js(e,t){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(t);a.current=t;let o=(0,Z.useRef)({active:!1,override:!1});return(0,Z.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 Ms({label:e,children:t}){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function Ns({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Jo(e);return(0,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,Q.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,Q.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,Q.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,Q.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Ps({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,Q.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,Q.jsx)(q,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:u(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,Q.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Fs({step:e,decorative:t=!1}){let n=Ro(e.status),r=`size-4 shrink-0`;switch(n){case`active`:return(0,Q.jsx)(st,{...t?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":n,className:u(r,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,Q.jsx)(Ae,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:u(r,`text-danger`)});case`pending`:return(0,Q.jsx)(Pe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:u(r,`text-soft-foreground`)});case`done`:return(0,Q.jsx)(ke,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:u(r,`text-success`)})}}var Is={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function Ls(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Rs({ask:e,run:t,onShowOrigin:n}){let r=e.context?(0,Q.jsx)(Bs,{text:e.context}):null;if(e.resolved)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(0,Q.jsxs)(zr,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?Is[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,Q.jsx)(Qi,{ask:e})]})]});let i=e.placement===`pinned`&&n?n:void 0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,e.routedToParent?(0,Q.jsx)(Vs,{ask:e,onShowOrigin:i}):(0,Q.jsx)(Hs,{ask:e,run:t,onShowOrigin:i})]})}function zs({onShowOrigin:e}){return(0,Q.jsx)(l,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,onClick:e,children:`Show where it was asked`})}function Bs({text:e}){return(0,Q.jsx)(zr,{role:`agent`,children:(0,Q.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,Q.jsx)(Cn,{breaks:!0,children:e})})})}function Vs({ask:e,onShowOrigin:t}){return(0,Q.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,Q.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,Q.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,Q.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,Q.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,Q.jsxs)(`li`,{className:`break-words`,children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,Q.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,Q.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,Q.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,Q.jsx)(q,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,Q.jsx)(zs,{onShowOrigin:t}):null]})}function Hs({ask:e,run:t,onShowOrigin:n}){let r=tn(t),i=r.blockedBy!==void 0,a=e.questions,o=a.length===1&&a[0]?.options!==void 0&&a[0]?.multiSelect!==!0,[s,c]=(0,Z.useState)({}),[l,u]=(0,Z.useState)({}),d=(e,t)=>c(n=>({...n,[e]:t})),f=e=>u(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),p=e=>{d(e,[]),u(t=>({...t,[e]:t[e]??``}))},m=a.some((e,t)=>!e.options||l[t]!==void 0),h=a.every((e,t)=>(s[t]?.length??0)>0||!!l[t]?.trim()),g=()=>void r.send(a.map((e,t)=>Ls(e,s[t]??[],l[t])).join(`
|
|
9
|
-
`)),_=r.mode===`resume`;return(0,Q.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":r.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-4 pt-3.5 pb-3.5`,children:[(0,Q.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.map((e,t)=>(0,Q.jsx)(Ws,{question:e,disabled:r.isPending||i,selected:s[t]??[],isOther:l[t]!==void 0,otherAnswer:l[t]??``,onSelect:n=>{i||(f(t),o?r.send(Ls(e,n)):d(t,n))},onOtherToggle:()=>{i||(l[t]===void 0?p(t):f(t))},onOtherChange:e=>u(n=>({...n,[t]:e}))},e.id??t))}),(0,Q.jsx)(Us,{oneTap:o,hasOtherAnswer:m,resuming:_,disabled:r.isPending||i||!h,questionCount:a.length,onSend:g}),r.blockedBy===`provider`?(0,Q.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r.reason}),(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,r.blockedBy===`no-session`?(0,Q.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:r.reason}):null,r.error?(0,Q.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:r.error}):null,n?(0,Q.jsx)(zs,{onShowOrigin:n}):null]})}function Us({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return e&&!t?n?(0,Q.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,Q.jsxs)(`div`,{className:`mbs-3 flex items-center gap-2.5`,children:[(0,Q.jsx)(l,{size:`sm`,className:`min-h-11`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),(0,Q.jsx)(`span`,{"data-slot":n?`ask-resume-hint`:`ask-hint`,className:`text-[11px] text-soft-foreground`,children:n?`the session has ended — sending reopens it`:t?`${i>1?`answer each question above`:`enter your answer above`} — or type a reply below`:`${i>1?`answer each question`:`pick one or more`} — or type a reply below`})]})}function Ws({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,Z.useId)(),d=e.options,f=d!==void 0&&e.multiSelect===!0,p=e=>{if(!f){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,Q.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,Q.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[12px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),f?(0,Q.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,Q.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),d?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>{let r=n.includes(e.label);return(0,Q.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>p(e.label),className:u(`flex min-h-11 w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[14px] font-semibold text-foreground`,children:[f?(0,Q.jsx)(`span`,{"aria-hidden":!0,className:u(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})}),(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(l,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,className:u(`w-full justify-start text-left`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`}),r?(0,Q.jsxs)(`div`,{className:`mt-2.5`,children:[(0,Q.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,Q.jsx)(Xt,{id:c,rows:2,value:i,disabled:t,onChange:e=>s(e.target.value),className:`bg-card`})]}):null]})]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,Q.jsx)(Xt,{id:c,rows:2,value:i,disabled:t,onChange:e=>s(e.target.value),className:`bg-card`})]})]})}var Gs=2e3;function Ks(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 qs(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 Js(e,t){let n=E(),r=(0,Z.useMemo)(()=>Ks(t),[t]),i=(0,Z.useMemo)(()=>qs(t),[t]),a=e?.id,o=e?.status;(0,Z.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:L.runs.detail(a)}),n.invalidateQueries({queryKey:L.runs.list()})},Gs);return()=>clearTimeout(e)},[r,i,a,o,n])}function Ys(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Xs({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Z.useState)(void 0),s=(0,Z.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,Z.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Ka(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Ys);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}}function Zs(){let e=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let t=e.current,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=()=>{n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${r.getBoundingClientRect().height}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(),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function Qs(){let{id:e}=a(),t=P(e),n=an(e),r=t.data?.status,i=(0,Z.useMemo)(()=>pt(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),o=(0,Z.useMemo)(()=>pt(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),s=(0,Z.useRef)(void 0),c=(0,Z.useCallback)(e=>{s.current=e},[]),{mutate:u}=O();if((0,Z.useEffect)(()=>{t.data&&s.current!==t.data.id&&fe(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Js(t.data,n.visibleEvents),t.isPending)return(0,Q.jsx)(_n,{});if(t.isError){let e=t.error instanceof C&&t.error.status===404;return(0,Q.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(Ot,{icon:e?(0,Q.jsx)(xt,{}):(0,Q.jsx)(An,{}),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,Q.jsx)(l,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(q,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Q.jsx)(_n,{}):(0,Q.jsx)($s,{run:t.data,thread:i,currentThread:o,history:n,onMarkedUnread:c})}function $s({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:a}){St();let o=ne(),{pendingAsk:s,transcriptAsk:c,pendingAskId:l,historyLoading:u}=ec(r,n),d=w(e),f=dt(e.status,e.error),p=vn(e),m=!p&&e.status!==`queued`,h=e.status===`queued`,g=bi(e),_=Ao(e),v=Co(e.id),b=c||y(e),{hasContinuation:x,continuable:S}=tc(p,h,g),[C,T]=(0,Z.useState)(void 0),[E,D]=(0,Z.useState)(e.id);E!==e.id&&(D(e.id),T(void 0));let ee=(0,Z.useMemo)(()=>C===void 0?void 0:Pi(n.turns,C,m,t.turns),[n.turns,C,m,t.turns]),O=(0,Z.useMemo)(()=>C===void 0?[]:Li(t.turns,n.turns,C),[t.turns,n.turns,C]),k=te(e.id),A=tn(e),{providerBlocked:j,providerReason:M}=nc(p,cn(e),x,g),{mutateAsync:N}=se(e.id),{mutateAsync:P}=ie(e.id),{mutateAsync:F}=R(e.id),I=(0,Z.useMemo)(()=>h?{onEditTask:async e=>{await N({task:e})},onEditMessage:(e,t)=>P({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>F(e).then(()=>void 0)}:void 0,[h,N,P,F]),L=u?void 0:l??null,z=(0,Z.useMemo)(()=>Ga(e,t,n,L),[e,t,n,L]),B=(0,Z.useMemo)(()=>Ya(z,e.id),[z,e.id]),ae=e.delegation?.role===`root`||e.delegation?.role===`worker`,ce=oe(e.id,{enabled:ae}),ue=(0,Z.useMemo)(()=>na(e,o.data,ce.data?.titles),[e,o.data,ce.data]),de=(0,Z.useMemo)(()=>ta(e,o.data),[e,o.data]),fe=(0,Z.useCallback)(t=>(0,Q.jsx)(Ki,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),me=(0,Z.useMemo)(()=>{if(I===void 0)return;let t={task:{onEdit:I.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>I.onEditMessage(n.id,e),onRemove:()=>I.onRemoveMessage(n.id)};return t},[I,e.queuedMessages]),he=pe(e,re()),{search:ge}=i(),_e=gr(ge,B.length),V=La(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:B.map(({key:e})=>e)}),{pinnedAsk:ve,pendingQuestions:ye}=rc(z),be=Xs({pendingAskId:l,askSeq:r?s?.seq:void 0,rows:B,history:r,jumpToRow:V.jumpToRow}),H=(0,Z.useRef)(l);u||(H.current=l);let U=(0,Z.useRef)({rows:B,jumpToRow:V.jumpToRow,reveal:be.reveal});U.current={rows:B,jumpToRow:V.jumpToRow,reveal:be.reveal};let xe=(0,Z.useCallback)(t=>t.placement===`origin`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,Q.jsx)(Bs,{text:t.context}):null,t.resolved?null:(0,Q.jsx)(Na,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=U.current,r=Ka(e,t.id,`pinned`);r&&n(r.key,r.index,e=>Aa(e))}})]}):(0,Q.jsx)(Rs,{ask:t,run:e,onShowOrigin:()=>U.current.reveal()}),[e]);return le(V.restickIfStuck),(0,Q.jsxs)(`div`,{ref:Zs(),"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,Q.jsx)(rt,{run:e,onMarkedUnread:()=>a?.(e.id)}),(0,Q.jsx)(ic,{run:e,thread:t,history:r,footer:f,issueUrl:he,sections:z,renderAsk:xe,renderPermission:fe,messageActions:me,scroll:V,mode:_e,taskTitles:ue,recipientBackends:de}),(0,Q.jsx)(ko,{status:e.status}),(0,Q.jsx)(io,{runId:e.id,renderAsk:xe,renderPermission:fe,agent:ee,entries:O,taskTitles:ue,recipientBackends:de,onClose:()=>T(void 0)}),(0,Q.jsx)(ac,{run:e,thread:t,currentThread:n,currentComplete:r?.currentComplete??!0,scroll:V,pendingQuestions:ye,onJump:()=>{let e=ye>0?ve?.id:void 0;V.jumpToLatest(e===void 0?void 0:ja(e,()=>H.current===e))},onOpenWorker:T,sessionOpen:p,attention:d,queued:h,continuable:S,continueAction:g,stopAction:_,finishAction:v,needsAnswer:b,sendMessage:k,reply:A,providerBlocked:j,providerReason:M}),(0,Q.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function ec(e,t){let n=e?lt(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 tc(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function nc(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function rc(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function ic({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:a,renderAsk:o,renderPermission:c,messageActions:l,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,Q.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 md:gap-3.5 md:px-16 md:py-5`,children:[n?(0,Q.jsx)(uc,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,Q.jsx)(Xa,{runId:e.id,viewId:`main`,sections:a,mode:`document`,renderAsk:o,renderPermission:c,messageActions:l,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,Q.jsx)(dc,{run:e}):(0,Q.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,Q.jsx)(Yr,{}):null,r&&r.state===`closed`?(0,Q.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:u(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,s(me(e))?(0,Q.jsx)(`a`,{"data-slot":`pr-link`,href:me(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,s(i)?(0,Q.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`?(0,Q.jsx)(wo,{run:e}):null]})}function ac({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:_,reply:v,providerBlocked:y,providerReason:b}){return(0,Q.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible?(0,Q.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,Q.jsx)(Va,{pendingQuestions:a,onJump:o})}):null,(0,Q.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,Q.jsx)(ms,{run:e,thread:t,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},e.id),(0,Q.jsx)(Nn,{run:e}),e.status===`waiting`&&c?(0,Q.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)($t,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,Q.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)($t,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&e.removedRunner!==void 0?(0,Q.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:g(e.removedRunner)}):d&&f.startsNewConversation?(0,Q.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,Q.jsx)(sc,{run:e,thread:t,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,sessionOpen:c})]})]})}function oc(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 sc({run:e,thread:t,stopAction:n,finishAction:r,attention:i,needsAnswer:a,continuable:o,continueAction:s,queued:c,sendMessage:l,reply:u,providerBlocked:d,providerReason:f,sessionOpen:p}){let m=We(e);return(0,Q.jsx)(Bt,{...oc(e,o,s),onStop:Wt(e,m).cancel?n.stop:void 0,onFinish:Jt(e)?()=>r.mutateAsync().catch(()=>void 0):void 0,finishing:r.isPending,secondaryAction:gn(e,m)?(0,Q.jsx)(at,{run:e,compactOnMobile:!0}):void 0,stopOnEmpty:cc(e,i,a),stopping:n.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:o?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:o?s.pills:void 0,onSubmit:o?(e,t)=>s.continueWith(e,t):c?(e,t)=>l.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await u.send(e,t);if(n!==void 0)throw Error(n)},disabled:d||!p&&!c&&!o,disabledReason:d?f:`Session closed — no session to resume.`,footerEnd:d&&!s.providerPending?(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:o&&!a,emptySubmitLabel:o&&!a?`Continue`:void 0,placeholder:lc(e,c,o),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>ht(t)})}function cc(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function lc(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 uc({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Q.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,Q.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Q.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,Q.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,Q.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function dc({run:e}){let t=Rt(ne().data??[],e.id);return(0,Q.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Q.jsx)($t,{tone:`neutral`,shape:`ring`}),(0,Q.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Q.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Qs as TaskThreadRoute};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{t,u as n}from"./button-RJMdCnZw.js";import{Ur as r,lr as i,ur as a}from"./project-scope-context-DYV7r53s.js";import{E as o,_ as s,f as c,g as l,h as ee,m as te}from"./live-protocol-CjfZMf1X.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./app-window-CSHwDX9N.js";import{i as ne}from"./format-BNCkW110.js";import{t as re}from"./play-CmVAj_fu.js";import{Yt as ie,g as ae,h as oe,tn as se,un as ce}from"./index-S6DMaCB8.js";var f=u(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),p=u(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),m=e(),le={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 ue(e){let{text:t,...n}=ae(e),r={...n,status:t},i=le[e.state](e);return i?{...r,action:i}:r}var de={"Run and open":re,Open:d,View:ce,"Start again":f};function fe({entry:e,inPreview:t,onOpen:r}){let{server:i}=e,a=ue(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=oe(i.command),l=ne(i.registeredAt);return(0,m.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:n(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`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)(p,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,m.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,m.jsx)(`span`,{children:`worktree removed`}):l?(0,m.jsxs)(`span`,{children:[l,` ago`]}):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)(ie,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,m.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,m.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,m.jsx)(pe,{entry:e,inPreview:t,action:s,onOpen:r})]}),(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:i.command}),i.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:i.cwd})]}):null]}),s?.run?(0,m.jsx)(h,{icon:(0,m.jsx)(se,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,m.jsx)(h,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function pe({entry:e,inPreview:n,action:r,onOpen:i}){let{server:a}=e,o=n&&r!==void 0&&!r.run,s=o?`In preview`:r?.label,c=o?d:r?de[r.label]:null;return r&&s&&c?(0,m.jsxs)(t,{variant:o||r.label===`View`||r.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>i?.({port:a.port,run:r.run}),children:[(0,m.jsx)(c,{"aria-hidden":`true`}),s]}):null}function h({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 g(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}var _=120;function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y(e){let t=e.replace(/\s+/g,` `).trim();return t.length>_?`${t.slice(0,_-1)}…`:t}var b=e=>e===void 0?void 0:y(e);function x(e,...t){if(v(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t}}function S(e,...t){return b(x(e,...t))}function me(e){if(!v(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.join(` `)}}function he(e){if(!v(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)v(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function ge(e){return S(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function C(e,t){return t?`${e} ${t}`:e}var w=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`spawnagent`,`task`],[`subtask`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function T(e,t){switch(e){case`notebookedit`:return x(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`);case`filechange`:{let e=he(t);return e.length===1?e[0]:void 0}default:return x(t,`file_path`,`filePath`,`path`)}}function _e(e,t){let n=e===`write`?`Write`:`Edit`;if(e!==`filechange`)return{toolKind:`edit`,title:C(n,b(T(e,t)))};let r=he(t);return{toolKind:`edit`,title:C(n,r.length>1?`${r.length} files`:r[0])}}function E(e,t){return e===`imageview`?x(t,`path`):x(t,`file_path`,`filePath`,`path`)}function ve(e,t){return{toolKind:`read`,title:C(e===`imageview`?`View image`:`Read`,b(E(e,t)))}}function D(e){return x(e,`pattern`,`query`)}function O(e,t){return e===`webfetch`?x(t,`url`):x(t,`query`)}function ye(e,t){return{toolKind:`fetch`,title:C(e===`webfetch`?`Fetch`:`Web search`,b(O(e,t)))}}var k=e=>x(e,`skill`,`name`,`command`),A=e=>x(e,`subagent_type`,`subagentType`);function be(e,t){return e===`skill`?k(t):x(t,`prompt`,`task`,`description`)??A(t)}function xe(e,t){if(e===`skill`){let e=b(k(t));return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:S(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=b(A(t)),i=S(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function Se(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=S(n,`server`),t=S(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:ge(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?y(e):`Tool`,subtitle:ge(n)}}function j(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(w.get(n)){case`execute`:return{toolKind:`execute`,title:C(`Ran`,b(me(t))),subtitle:S(t,`description`)};case`edit`:return _e(n,t);case`read`:return ve(n,t);case`search`:return{toolKind:`search`,title:C(`Search`,b(D(t))),subtitle:S(t,`path`)};case`fetch`:return ye(n,t);case`task`:return xe(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return Se(e,n,t)}}function Ce(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(w.get(n)){case`execute`:return me(t);case`edit`:return T(n,t);case`read`:return E(n,t);case`search`:return D(t);case`fetch`:return O(n,t);case`task`:return be(n,t);default:return}}function we(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&o.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?l:ee).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function Te(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function M(e){let t=Te(e);return t&&{seq:e.seq,...t}}function Ee(e,t){let n=we(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?M(t):n===void 0?void 0:e}function De(e){let t;for(let n of e)t=Ee(t,n);return t}function Oe(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function ke(){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 N(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function P(e){return typeof e==`string`?e:void 0}function F(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`})}`}function I(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}var Ae=new Set(r.options);function je(e){return typeof e==`string`&&Ae.has(e)?e:void 0}function L(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 R(e){return e.turns.at(-1)??L(e)}function z(e,t){R(e).entries.push({origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq})}function B(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function V(e,t){let n=P(e.stepId);return n===void 0?t:`${n}:${t}`}function Me(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 Ne(e,t,n,r,i){let a=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&a.kind!==`hook`&&Me(e,t);let o=e.itemsById.get(r);if(o&&o.turn===t){o.entry.entry=a,o.entry.lastSeq=e.eventSeq;return}let s={origin:`v2`,entry:a,firstSeq:e.eventSeq,lastSeq:e.eventSeq};t.entries.push(s),e.itemsById.set(r,{turn:t,entry:s})}var H={"not-delivered":0,queued:1,delivered:2,consumed:3},Pe=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of Pe)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 Ie(e,t,n,r){(H[e.delivery]<H.delivered||H[n]>H[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){Ie(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),z(e,a)}function Le(e,t){let n=F(t.ts),r=P(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,z(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function Re(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=P(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${P(t.event)?` (${P(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${P(t.error)??`unknown error`}`;z(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ze(e,t){let n=P(t.webhookName)??`webhook`,r=P(t.title),i=`v1:${t.seq}`;if(t.ok===!1){z(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${P(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${F(t.ts)}${r?` — ${r}`:``}`;z(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function Be(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${P(t.event)??`delivery`}${P(n.status)?` · ${P(n.status)}`:``}`;z(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function Ve(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=R(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function He(e,t){let n=a.safeParse(t.state),r=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!r||r.draft.entry.kind!==`preview-server`)return;let{server:i,id:o}=r.draft.entry;r.draft.lastSeq=t.seq,r.draft.entry={kind:`preview-server`,id:o,server:i,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function Ue(e,t){let n=te.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:s}=n.data;G(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:s})}function We(e,t){let n=s.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 Ge(e,t){let n=c.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}z(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ke(e,t){let n=P(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=L(e,t.seq),a=I(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 qe(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:L(e,t.seq);r.turnId=P(t.turnId),r.startedAt??=I(t.ts)}function Je(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 Ye(e,t){B(e);let n=Je(e,P(t.turnId));if(!n)return;let r=I(t.ts);n.completed={stopReason:P(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),Xe=e=>K.has(e.kind);function Ze(e){if(!(!N(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=Ze(t.item);if(!n)return;let r=V(t,n.id);Ne(e,e.itemsById.get(r)?.turn??R(e),n,r,t.type===`item.completed`?I(t.ts):void 0)}function Qe(e,t){let n=e.itemsById.get(V(t,P(t.itemId)??``)),r=P(t.delta)??``;if(!n||r===``||!Xe(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 $e(e,t){let n=R(e),r=P(t.text)??``;if(r===``)return;let i=I(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 et=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function tt(e){if(!N(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!N(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:et.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var nt=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function rt(e,t){let n=R(e),r=P(t.tool)??`Tool`;if(n.v2Items||nt.has(r))return;let i=j(r,t.input),a=i.toolKind===`plan`?tt(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:P(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 it(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function at(e,t){let n=e.itemsById.get(P(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=it(t.result))}function J(e,t,n,r){let i=P(t.message)??``;i!==``&&z(e,{kind:`note`,id:n,text:i,tone:r})}function Y(e,t){J(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ot(e,t){J(e,t,`v1:${t.seq}`,`danger`)}function st(e,t){J(e,t,`v2:${t.seq}`,`danger`)}function ct(e,t){if(t.status!==`failed`)return;let n=P(t.error)?` — ${P(t.error)}`:``;z(e,{kind:`note`,id:`v1:${t.seq}`,text:`step ${P(t.stepId)??`?`} failed${n}`,tone:`danger`})}function lt(e,t){let n=P(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;z(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:P(t.text)??``,exitCode:r})}function ut(e,t){let n=je(t.provider),r=P(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||z(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function dt(e,t){let n=P(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=P(t.name);i!==void 0&&(r.name=i),z(e,r)}function ft(e,t){Array.isArray(t.entries)&&(R(e).planEntries=t.entries)}function pt(e,t){B(e);let n=P(t.message);e.sessionEnded={reason:P(t.reason)??`end_turn`,...n===void 0?{}:{message:n}}}var mt=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function ht(e){return N(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&mt.has(e.kind)}function gt(e){if(!(!Array.isArray(e)||e.length===0||!e.every(ht)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function _t(e,t){let n=P(t.requestId),r=P(t.title),i=gt(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=P(t.itemId),o=P(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),z(e,s)}function vt(e,t){let n=e.permissions.get(P(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=P(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=P(t.reason);i!==void 0&&(n.reason=i)}function yt(e,t){let n=M(t),r=n&&Oe(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};z(e,i),e.pendingAsk=i}function X(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function bt(e,t){let n=X(e,t);if(!n)return;n.routedToParent=!0;let r=P(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function xt(e,t){let n=X(e,t);n&&(n.routedToParent=!1)}function St(e,t){let n=X(e,t);n&&Z(e,n,`undeliverable`)}var Ct=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function wt(e,t){let n=X(e,t);n&&Ct.has(t.reason)&&Z(e,n,t.reason)}function Z(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Tt(e,t){let n=X(e,t);if(n){if(t.source===`cezar`){Z(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},Et=new Map([[`handoff`,Le],[`webhook.failed`,Re],[`webhook.dry-run`,Be],[`webhook.report`,ze],[`preview.server-registered`,Ve],[`preview.server-state`,He],[`conversation-message`,Ue],[`request-outcome`,We],[`agent-input`,Ge],[`user-message`,Ke],[`turn.started`,qe],[`turn.completed`,Ye],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,Qe],[`text`,$e],[`tool-call`,rt],[`tool-result`,at],[`note`,Y],[`lifecycle`,Y],[`error`,ot],[`session.error`,st],[`step-end`,ct],[`check-output`,lt],[`provider-auth-required`,ut],[`image`,dt],[`plan.updated`,ft],[`session.started`,e=>B(e)],[`session.ended`,pt],[`permission.requested`,_t],[`permission.resolved`,vt],[`ask.requested`,yt],[`worker-question-routed`,bt],[`worker-question-fallback`,xt],[`worker-question-undelivered`,St],[`human-ask-closed`,wt],[`human-input-delivered`,Tt],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function Dt(e,t){e.eventSeq=t.seq,Et.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 kt(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=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function At(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label: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 $(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}function jt(e){let t=e=>$(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function Mt(e){let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text,!0).trim()))),jt(e))}function Nt(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!g(e,`human`)))}function Pt(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 Ft(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(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:$(e.text,n)}:e),itemSeqs:It(e.entries)}}function It(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 Lt(e,t={}){let n=ke();for(let t of e)Dt(n,t);for(let e of n.turns)e.v2Items&&Mt(e),Nt(e);Pt(n);let r=n.turns.length-1;return{turns:n.turns.map((e,n)=>Ft(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{De as a,g as c,f as d,At as i,fe as l,Lt as n,Ce as o,kt as r,j as s,Ot as t,p as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{d as r,t as i,u as a}from"./button-RJMdCnZw.js";import{C as o,Dr as s,Jt as c,Pt as l,et as u,r as d,ti as f,tt as p}from"./project-scope-context-DYV7r53s.js";import{$ as m,D as h,Nt as g,Rt as _,X as v,Yt as y,j as b,kt as x,m as S,n as C,xt as w}from"./queries-Bp7cia4e.js";import{t as T}from"./useQuery-BfBOHv1O.js";import{a as E,o as D,r as O,tt as k}from"./use-desktop-Dq3Z-pSO.js";import{n as A}from"./toaster-BWMQArHJ.js";import{Y as j,c as M,ct as N,ft as P,g as ee,it as F,k as I,l as L,m as R,ot as te,r as z,tt as ne,u as re,ut as ie,y as ae}from"./design-icons-B6-0w7Aw.js";import{t as oe}from"./eye-B8okNWXU.js";import{a as se,i as B}from"./format-BNCkW110.js";import{t as ce}from"./message-square-B-MD-8rD.js";import{t as le}from"./play-CmVAj_fu.js";import{a as ue,i as de,o as fe,r as pe,s as me,t as he}from"./dialog-7Mg2IZCP.js";import{d as V,t as ge,y as H}from"./prompt-template-menu-DYoBkQJP.js";import{t as U}from"./project-router-D7rZ5E-b.js";import{_ as _e,a as ve,b as W,c as ye,d as be,f as xe,h as Se,n as Ce,p as we,r as Te,s as Ee,t as G,u as De,v as K,x as Oe,y as ke}from"./picker-pill-CFcrs68V.js";import{d as Ae,f as q,i as je,o as Me,p as Ne,s as Pe,t as Fe,u as Ie}from"./skills-pM_PouEs.js";import{c as Le,d as Re,f as ze,h as Be,l as Ve,n as He,p as Ue,s as We,t as Ge}from"./agent-accounts-9EM12D_s.js";import{F as Ke,L as qe,R as Je,V as Ye,hn as Xe}from"./index-S6DMaCB8.js";import{t as Ze}from"./markdown-D9-0R3BD.js";import{t as Qe}from"./diff-CbzFxE4W.js";import{t as $e}from"./tab-link-C_n2wSwD.js";var J=e(t(),1),Y=n(),et={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function X({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:a(t,`text-success`)}):e===`failing`?(0,Y.jsx)(ee,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:a(t,`text-danger`)}):e===`pending`?(0,Y.jsx)(se,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:a(t,`animate-spin text-warning`)}):(0,Y.jsx)(R,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:a(t,`text-soft-foreground`)})}function tt(e){return e?.available?e.mergeState:null}function nt(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function rt(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 it(e){return e===`approved`||e===`not-required`?`passing`:e===`unknown`?`unknown`:`failing`}function at(e){return e===`mergeable`?`passing`:e===`conflicting`?`failing`:`unknown`}function ot(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function st(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function ct(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function lt(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function Z(e){return e?et[e]:`Merge`}function ut(e){return e===`conflicting`?`true`:void 0}function dt({check:e}){return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(X,{state:e.state}),(0,Y.jsxs)(`span`,{children:[e.name,` · `,e.state,st(e.required)]})]}),e.url&&r(e.url)?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function ft({reason:e}){return(0,Y.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function pt({state:e,selectedMethod:t,overrideRules:n,mergeEnabled:r,refreshPending:o,onRefresh:s,onRunAgent:c,onConfirm:l,onMethodChange:u,onOverrideChange:d}){let f=rt(e),p=it(e.reviewDecision),m=at(e.mergeable);return(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,Y.jsx)(te,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:f}),(0,Y.jsxs)(i,{type:`button`,variant:`ghost`,size:`sm`,disabled:o,onClick:s,children:[(0,Y.jsx)(j,{size:16,"aria-hidden":`true`,className:a(`size-3.5`,o&&`animate-spin`)}),`Refresh`]})]}),(0,Y.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[e.headRef,` (`,e.headSha.slice(0,7),`) → `,e.baseRef]}),(0,Y.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(X,{state:p}),(0,Y.jsxs)(`span`,{children:[`Reviews: `,e.reviewDecision.replaceAll(`-`,` `)]})]}),(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(X,{state:m}),(0,Y.jsxs)(`span`,{children:[`Conflicts: `,ot(e.mergeable)]})]}),e.checks.length===0?(0,Y.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,Y.jsx)(dt,{check:e},e.name)),e.blockers.map(e=>(0,Y.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&c?(0,Y.jsx)(i,{className:`mt-4`,onClick:c,children:`Run agent on this PR`}):null,e.canOverride?(0,Y.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>d(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,Y.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,onChange:e=>u(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:e.methods.map(e=>(0,Y.jsx)(`option`,{value:e,children:et[e]},e))}),(0,Y.jsx)(i,{disabled:!r,onClick:l,children:Z(t)})]}):null]})]})}function mt({number:e,state:t,selectedMethod:n,confirming:r,overrideRules:a,mergePending:o,mergeError:s,onOpenChange:c,onMerge:l}){return(0,Y.jsx)(he,{open:r,onOpenChange:c,children:(0,Y.jsxs)(pe,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Y.jsxs)(fe,{children:[(0,Y.jsxs)(me,{children:[Z(n),` pull request #`,e,`?`]}),(0,Y.jsx)(de,{asChild:!0,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),a&&t.canOverride?(0,Y.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),s?(0,Y.jsx)(`p`,{className:`text-sm text-danger`,children:s.message}):null,(0,Y.jsxs)(ue,{children:[(0,Y.jsx)(i,{variant:`outline`,disabled:o,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(i,{disabled:o,onClick:l,children:o?`Merging…`:Z(n)})]})]})})}function ht({number:e,onRunAgent:t}){let n=f(),r=m(),i=T({queryKey:C.githubMergeState(e),queryFn:({signal:t})=>p(e,{},{signal:t}),retry:!1}),a=tt(i.data),[o,s]=(0,J.useState)(null),[c,u]=(0,J.useState)(!1),[d,h]=(0,J.useState)(!1),g=y({mutationFn:t=>p(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>A(e instanceof Error?e.message:String(e),{tone:`danger`})}),_=nt(o,a),v=()=>({mergeState:C.githubMergeState(e),list:C.githubPages(50),comments:C.githubComments(`pr`,e),item:C.githubItem(`pr`,e),refStatus:r===void 0?void 0:C.githubRefStatusOf(r)}),b=y({mutationFn:t=>{if(!a||!_)throw Error(`No merge method is available.`);return l(e,{method:_,expectedHeadSha:a.headSha,...d&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),A(`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)=>{A(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,Y.jsx)(H,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,Y.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":ut(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,Y.jsx)(pt,{state:a,selectedMethod:_,overrideRules:d,mergeEnabled:lt(_,a,d),refreshPending:g.isPending,onRefresh:()=>g.mutate(C.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:s,onOverrideChange:h}),(0,Y.jsx)(mt,{number:e,state:a,selectedMethod:_,confirming:c,overrideRules:d,mergePending:b.isPending,mergeError:b.error,onOpenChange:u,onMerge:()=>b.mutate(v())})]}):(0,Y.jsx)(ft,{reason:ct(i.data)})}function gt(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 _t(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 vt(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 Q(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 yt({label:e,color:t,plain:n=!1}){return(0,Y.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:Q(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function bt(e){return e===`pr`?`pull request`:`issue`}function xt(e,t,n){return e===`pr`&&!!(t||n)}function St({backLink:e}){return e?(0,Y.jsxs)(U,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,Y.jsx)(z,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}function Ct({item:e,kindWord:t,commentCount:n,hasDiffStat:i,additions:a,deletions:o}){return(0,Y.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,Y.jsx)(`span`,{children:t}),`·`,(0,Y.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Y.jsxs)(`span`,{children:[B(e.createdAt),` ago`]}),n?(0,Y.jsxs)(Y.Fragment,{children:[`·`,(0,Y.jsx)(qt,{count:n})]}):null,i?(0,Y.jsxs)(Y.Fragment,{children:[`·`,(0,Y.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,a??0]}),` `,(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,o??0]})]})]}):null,`·`,r(e.url)?(0,Y.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,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Y.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function wt({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,Y.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Y.jsx)($e,{to:V(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,Y.jsx)($e,{to:V(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,Y.jsx)(U,{to:V(`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 Tt({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Y.jsx)(yt,{label:e,color:t[e]},e)),n?(0,Y.jsx)(Jt,{checks:n,url:e.url}):null]}):null}function Et({item:e,colors:t,body:n}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:n?(0,Y.jsx)(Ze,{children:n}):(0,Y.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,Y.jsx)(kt,{item:e,colors:t})]})}function Dt({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,children:c}){let l=a?.changes??!1,u=bt(e.kind),d=h(e.kind,e.number,!l).data?.detail,f=d?.body??e.body,p=d?.additions??e.additions,m=d?.deletions??e.deletions,g=xt(e.kind,p,m),_=r??e.comments;return(0,Y.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Y.jsx)(St,{backLink:i}),(0,Y.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,Y.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,Y.jsx)(Ct,{item:e,kindWord:u,commentCount:_,hasDiffStat:g,additions:p,deletions:m}),e.kind===`pr`?null:(0,Y.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,(0,Y.jsx)(wt,{item:e,subNav:a,changes:l}),(0,Y.jsx)(Tt,{item:e,colors:t,checks:n}),l&&e.kind===`pr`?(0,Y.jsx)(Ot,{item:e}):(0,Y.jsx)(Et,{item:e,colors:t,body:f})]}),e.kind===`pr`?(0,Y.jsx)(ht,{number:e.number,onRunAgent:o}):null,c]})}function Ot({item:e}){let t=f(),n=b(e.number),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),d=n.data,p=d?.available?d.files.filter(e=>e.path.toLowerCase().includes(o.toLowerCase())):[],m=p.findIndex(e=>e.path===c);(0,J.useEffect)(()=>{p.length>0&&!p.some(e=>e.path===c)&&l(p[0].path)},[d?.available?d.headSha:``,o]);let h=async()=>{let n=d?.available?d.headSha:null,r=C.githubPrChanges(e.number),i=await u(e.number,{refresh:!0});t.setQueryData(r,i),i.available&&n&&n!==i.headSha&&(l(i.files[0]?.path??null),A(`The reviewed revision changed.`))};if(n.isPending)return(0,Y.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!d)return(0,Y.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!d.available)return(0,Y.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:d.reason});let g=p.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??``})),_=r(e.url)?`${e.url}/files`:null,v=p.find(e=>e.path===c);return(0,Y.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Y.jsxs)(`strong`,{children:[d.files.length,` changed files`]}),(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,d.additions]}),(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,d.deletions]}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:d.headSha,children:[`head `,d.headSha.slice(0,8)]}),(0,Y.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void h(),children:`Refresh`})]}),d.truncated?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[d.reason??`This response is incomplete.`,` `,_?(0,Y.jsx)(`a`,{href:_,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Y.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Y.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Y.jsx)(`input`,{"aria-label":`Filter changed files`,value:o,onChange:e=>s(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Y.jsx)(`select`,{"aria-label":`Select changed file`,value:c??``,onChange:e=>l(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:p.map(e=>(0,Y.jsx)(`option`,{children:e.path},e.path))}),(0,Y.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e.path),className:a(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,c===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Y.jsx)(i,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<=0,onClick:()=>l(p[m-1]?.path??null),children:(0,Y.jsx)(Xe,{})}),(0,Y.jsx)(i,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<0||m>=p.length-1,onClick:()=>l(p[m+1]?.path??null),children:(0,Y.jsx)(re,{size:16})})]}),p.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Qe,{files:g.filter(e=>e.path===c),wrap:!0,className:`min-w-0`}),v&&!v.patch?(0,Y.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,v.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function kt({item:e,colors:t}){let n=h(e.kind,e.number),r=n.data,i=(0,J.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(At(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,Y.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Y.jsx)(H,{className:`mb-3 h-3 w-24`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(H,{className:`h-14 w-full`}),(0,Y.jsx)(H,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Y.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Y.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,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Y.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Y.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-5`,children:jt(i).map(e=>e.group===`commits`?(0,Y.jsx)(Mt,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Y.jsx)(Ut,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Y.jsx)(Pt,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Y.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-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var At=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function jt(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 Mt({commits:e,colors:t}){let[n,r]=(0,J.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Nt.committed}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Y.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Y.jsx)(Pt,{event:e,colors:t},e.id))]}):(0,Y.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Nt.committed}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Y.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:B(e[e.length-1].createdAt)})]})})}var Nt={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function Pt({event:e,colors:t}){return(0,Y.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:a(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:Nt[e.kind]}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Y.jsx)(Bt,{event:e,colors:t}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:B(e.createdAt)}),e.url?(0,Y.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,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Ft({event:e}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,Y.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Y.jsx)(Vt,{checks:e.checks})]})}function It({event:e,colors:t}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Y.jsx)(`span`,{"data-slot":`gh-event-label`,style:Q(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,Y.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function Lt({event:e}){return(0,Y.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Rt({event:e}){return(0,Y.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var zt={committed:e=>(0,Y.jsx)(Ft,{event:e}),labeled:(e,t)=>(0,Y.jsx)(It,{event:e,colors:t}),unlabeled:(e,t)=>(0,Y.jsx)(It,{event:e,colors:t}),assigned:e=>(0,Y.jsx)(Lt,{event:e}),unassigned:e=>(0,Y.jsx)(Lt,{event:e}),merged:()=>(0,Y.jsx)(`span`,{children:`merged this`}),closed:()=>(0,Y.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,Y.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,Y.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,Y.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,Y.jsx)(Rt,{event:e})};function Bt({event:e,colors:t}){return zt[e.kind]?.(e,t)??null}function Vt({checks:e}){return e?(0,Y.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:a(`shrink-0`,Kt[e]),children:Gt[e]}):null}var Ht={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function Ut({comment:e}){let t=e.reviewState?Ht[e.reviewState]:null;return(0,Y.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Y.jsx)(Wt,{url:e.avatarUrl,login:e.author}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Y.jsx)(`span`,{children:B(e.createdAt)}),t?(0,Y.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:a(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,Y.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,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Y.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,Y.jsx)(Ze,{children:e.body}):(0,Y.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function Wt({url:e,login:t}){let[n,r]=(0,J.useState)(!1);return e&&!n?(0,Y.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,Y.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Gt={passing:`✓`,failing:`✗`,pending:`○`},Kt={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function qt({count:e}){return e?(0,Y.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,Y.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function Jt({checks:e,url:t}){let n=a(`text-[11px] font-medium`,Kt[e],t&&`hover:underline`),r=`${Gt[e]} checks ${e}`;return t?(0,Y.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,Y.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function Yt({checks:e}){return(0,Y.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:a(`shrink-0 font-sans text-[11px] font-semibold`,Kt[e]),children:Gt[e]})}function Xt(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Zt(e,t=[]){let n=Xt(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=Qt(t)),n}function Qt(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function $t(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 en(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 tn(e,t,n){let r=(n??``).trim();if(!r)return Zt(e,t);let i=Xt(e),a=r.startsWith(i)?i+$t(r.slice(i.length),e):$t(r,e),o=en(a,e)?a:`${i}\n\n${a}`;return t.length?o+Qt(t):o}function nn(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 rn(e,t,n,r,i={}){return t?{...i,workflow:t,task:tn(e,n.map(e=>e.id),r)}:n.length?{...i,steps:nn(n.map(e=>e.id)).map((e,t)=>({...e,...n[t]?.path===void 0?{}:{skillPath:n[t].path}})),task:tn(e,[],r)}:{...i,workflow:`quick-task`,task:tn(e,[],r)}}function an(e){let t=v(),n=S(),r=s(t.data),i=n.data?.defaultRunner,a=Ue(e.runner,r,i??r[0]??`claude`),o=w(a),c=n.data?.modelsLocked===!0,{accounts:l,repoAccount:u}=He(),d=l.some(t=>t.provider===a&&t.id===e.account)?e.account:null,f=ze(c?null:e.model,a,n.data?.defaultModels,o.data),p=We(a,f,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:f,effort:c?``:Re(e.effort,p),effortOptions:p,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:c,providerPending:t.isPending,providerError:t.isError,accounts:l,account:d,repoAccount:u}}function on(e){return{runner:Be(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 sn(e){return{...on(e),...e.account?{agentProfile:e.account}:{}}}function cn({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,J.useRef)(null),o=(0,J.useRef)(null),[s,c]=(0,J.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,J.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(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)}},[i]),(0,J.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let l=an(e),{runner:u,model:d,effort:f,effortOptions:p,runners:m,canRun:h,modelsLocked:g}=l,_=S(),v=w(u),y=Ve(u,v.data,[e.model,_.data?.defaultModels?.[u]]),b=n||!h,x=r?l.accounts:[],C=m.length>1||m.some(e=>Ge(x,e))?(0,Y.jsx)(Te,{icon:(0,Y.jsx)(F,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:m,value:u,accounts:x,account:r?l.account:null,repoAccount:r?l.repoAccount:void 0,disabled:b,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===u?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,T=(0,Y.jsx)(G,{icon:(0,Y.jsx)(ae,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:d===``?`Default`:y.find(e=>e.id===d).label,value:d,disabled:b,readOnly:g===!0,disabledHint:g?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=We(u,n,v.data);t({...e,model:n,effort:e.effort===null?null:Re(e.effort,r)})},options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Le(u,v.data,v.isError,v.isFetching)},`model`),E=(0,Y.jsx)(G,{icon:(0,Y.jsx)(I,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:p.find(e=>e.value===f)?.label??`auto`,value:f,disabled:b,readOnly:g===!0,disabledHint:g?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:p.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,Y.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,Y.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,Y.jsx)(Ce,{children:s?[C,E,T]:[C,T,E]})})}):(0,Y.jsxs)(Ce,{children:[C,T,E]})}var ln={workflow:null,skills:[]},un=`cez-followup-selection`;function dn(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 fn(){try{let e=localStorage.getItem(un);return e?dn(JSON.parse(e)):{...ln}}catch{return{...ln}}}function pn(e){try{localStorage.setItem(un,JSON.stringify(e))}catch{}}var $=`cez-followup-prompt:`;function mn(e){try{return localStorage.getItem($+e)??``}catch{return``}}function hn(e,t){try{t===``?localStorage.removeItem($+e):localStorage.setItem($+e,t)}catch{}}function gn({item:e,workflows:t,skills:n,workflow:a,onWorkflowChange:s,selectedSkills:l,onSkillsChange:u,engine:d,onEngineChange:p,queuedRunId:m,onQueued:h}){let g=f(),v=x(),b=e.kind===`pr`?`PR`:`issue`,S=an(d),w=_(S.runner,S.account),T=l.filter(e=>w.unchecked||e.path===void 0||n.some(t=>t.id===e.id&&(e.path===void 0||t.path===e.path))),E=T.length!==l.length,[D]=(0,J.useState)(()=>Xt(e)),[O,k]=(0,J.useState)(()=>mn(e.url)||D),j=(0,J.useRef)(null),N=(0,J.useRef)(null);(0,J.useEffect)(()=>{hn(e.url,O===D?``:O)},[e.url,O,D]);let P=(0,J.useMemo)(()=>De(v.data?.promptTemplates),[v.data?.promptTemplates]),ee=e=>{let t=j.current,n=xe({prompt:O,base:D,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:N.current}),r=ye(O,n,e);k(r.text),N.current=r.caret,requestAnimationFrame(()=>{j.current?.focus(),j.current?.setSelectionRange(r.caret,r.caret)})},F=Ee(P,T.map(e=>e.id)),I=(0,J.useRef)(O);I.current=O;let L=(0,J.useRef)(``);(0,J.useEffect)(()=>{let e=be(I.current,L.current,F,D);L.current=e.applied,e.text!==I.current&&k(e.text)},[F,D]);let R=y({mutationFn:async()=>!S.canRun||E?null:o(rn(e,a,T,O,sn(S))),onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),A(`Added to the queue — ${b} #${e.number}`),T.length>0&&v.data!==void 0&&c({skillUsage:T.reduce((e,t)=>Fe(e,t.id),v.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:C.uiState})).catch(()=>{}),hn(e.url,``),k(D),L.current=``,g.invalidateQueries({queryKey:C.runs.all})},onError:e=>A(e.message,{tone:`danger`})}),te=e=>{qe({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!R.isPending&&S.canRun&&R.mutate())},z=e=>u(l.some(t=>q(t)===q(e))?l.filter(t=>q(t)!==q(e)):[...l,Pe(e)]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Y.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,Y.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,Y.jsx)(`span`,{children:`Instructions for the agent`}),(0,Y.jsx)(Ye,{ref:j,"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=>{N.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,Y.jsx)(ge,{templates:P,onInsert:ee}),(0,Y.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Workflow`}),(0,Y.jsx)(vn,{workflows:t,value:a,onChange:s})]}),(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Skills · select one or more`}),(0,Y.jsx)(bn,{skills:n,skillUsage:v.data?.skillUsage,selected:l,onToggle:z})]}),l.length>0?(0,Y.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:l.map(e=>(0,Y.jsx)(_n,{skill:e,skills:n,unchecked:w.unchecked,onRemove:()=>z(e)},q(e)))}):null,E?(0,Y.jsx)(`p`,{role:`alert`,children:`A selected skill path is unavailable. Remove it or choose a current copy before starting.`}):null,(0,Y.jsx)(cn,{layout:`row`,pick:d,onChange:p,disabled:R.isPending||!S.canRun,accounts:!0}),(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Account`}),(0,Y.jsx)(yn,{resolved:S,disabled:R.isPending||!S.canRun,onPick:e=>p({...d,account:e})})]}),!S.providerPending&&!S.canRun?(0,Y.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[S.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Y.jsx)(U,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,Y.jsxs)(`p`,{className:`text-[11px] 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,Y.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[r(e.url)?(0,Y.jsx)(i,{asChild:!0,variant:`outline`,children:(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,Y.jsxs)(i,{variant:`primary`,"data-action":`gh-run`,disabled:R.isPending||!S.canRun||E,onClick:()=>R.mutate(),children:[(0,Y.jsx)(le,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,b]}),(0,Y.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Je()}),m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Y.jsx)(U,{to:`/tasks/${m}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function _n({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,Y.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,Y.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3`})]})}function vn({workflows:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),c=(0,J.useRef)(null),l=Ae(e,o);return(0,Y.jsxs)(O,{open:r,onOpenChange:e=>{i(e),e||s(``)},children:[(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:a(ve,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,Y.jsx)(ie,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,Y.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,Y.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Y.jsx)(E,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Y.jsxs)(Se,{shouldFilter:!1,children:[(0,Y.jsx)(ke,{placeholder:`search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,Y.jsxs)(Oe,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Y.jsx)(_e,{children:`Nothing matches.`}):null,(0,Y.jsx)(K,{children:l.map(e=>{let r=t===e.name;return(0,Y.jsxs)(W,{value:`workflow ${e.name}`,keywords:Ne(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function yn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:we,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,Y.jsx)(G,{icon:(0,Y.jsx)(N,{"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 bn({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Ie(e,s,t),g=(e,t)=>{let i=n.some(t=>q(t)===q(e));return(0,Y.jsxs)(W,{value:q(e),keywords:Ne(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.id,"data-selected":i?`true`:void 0,onSelect:()=>r(Pe(e)),children:[(0,Y.jsx)(`span`,{className:a(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.path?(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Y.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Y.jsx)(oe,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},q(e))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ke,{skill:l,onClose:()=>u(null)}),(0,Y.jsxs)(O,{open:i,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:a(ve,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Y.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Y.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Y.jsx)(E,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Y.jsxs)(Se,{shouldFilter:!1,children:[(0,Y.jsx)(ke,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,Y.jsxs)(Oe,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!e.some(e=>e.id===s.trim())?(0,Y.jsx)(K,{children:(0,Y.jsxs)(W,{value:`typed-skill`,onSelect:()=>r({id:s.trim()}),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,Y.jsx)(_e,{children:`Nothing matches.`}):null,h?h.length>0?(0,Y.jsx)(K,{children:h.map(e=>g(e,je(e)))}):null:(0,Y.jsxs)(Y.Fragment,{children:[f.length>0?(0,Y.jsx)(K,{heading:`Most used`,children:f.map(e=>g(e,je(e)))}):null,p.length>0?(0,Y.jsx)(K,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,Y.jsx)(K,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var xn=new WeakMap;function Sn(){let e=fn(),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)&&pn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Cn(){let e=f(),{projectId:t}=d(),n=xn.get(e);n||xn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=Sn());let{snapshot:i,subscribe:a,update:o}=r,s=(0,J.useSyncExternalStore)(a,i,i),c=g(),l=an(s.engine),u=_(l.runner,l.account),p=x(),m=c.data?.workflows;(0,J.useEffect)(()=>{m&&s.workflow!==null&&!m.some(e=>e.name===s.workflow)&&o({workflow:null})},[o,m,s.workflow]);let h=(0,J.useMemo)(()=>Me(u.data??[],p.data?.skillUsage),[u.data,p.data?.skillUsage]);return{...s,workflows:c,skillList:h,skillsUnchecked:u.unchecked,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{qt as a,jt as c,Q as d,vt as f,Yt as i,gt as l,gn as n,Dt as o,Zt as r,yt as s,Cn as t,_t as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Gr as e,ni as t}from"./project-scope-context-DYV7r53s.js";function n(n,r){return e(n,t,r)}export{n as t};
|