@wjarka/cezarion 0.14.3 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/core/cursor-acp-runner.d.ts +13 -0
  2. package/dist/core/cursor-acp-runner.js +118 -5
  3. package/dist/core/cursor-acp-runner.js.map +1 -1
  4. package/dist/core/cursor-provider-error.d.ts +30 -0
  5. package/dist/core/cursor-provider-error.js +53 -0
  6. package/dist/core/cursor-provider-error.js.map +1 -0
  7. package/dist/core/usage-limit.js +1 -1
  8. package/dist/core/usage-limit.js.map +1 -1
  9. package/dist/delegation/transport.d.ts +4 -4
  10. package/dist/runs/agent-tmpdir.d.ts +20 -11
  11. package/dist/runs/agent-tmpdir.js +109 -60
  12. package/dist/runs/agent-tmpdir.js.map +1 -1
  13. package/dist/runs/event-history.js +14 -1
  14. package/dist/runs/event-history.js.map +1 -1
  15. package/dist/server/server.d.ts +58 -58
  16. package/dist/skills-remote.d.ts +3 -2
  17. package/dist/skills-remote.js +5 -2
  18. package/dist/skills-remote.js.map +1 -1
  19. package/dist/workflows/run.js +6 -5
  20. package/dist/workflows/run.js.map +1 -1
  21. package/package.json +3 -3
  22. package/scripts/mock-cursor-acp.mjs +11 -1
  23. package/web/dist/assets/{commit-list-CEVhJoCF.js → commit-list-DOWYQ7G6.js} +1 -1
  24. package/web/dist/assets/{compare-variants-CZqdiqvW.js → compare-variants-B1XteHt-.js} +1 -1
  25. package/web/dist/assets/{github-BPfdr6aa.js → github-BhnijVvD.js} +1 -1
  26. package/web/dist/assets/index-DK0Mkv2m.css +1 -0
  27. package/web/dist/assets/{index-C4iEPAUV.js → index-DTsigc4h.js} +5 -5
  28. package/web/dist/assets/pill-BoBISMI9.js +1 -0
  29. package/web/dist/assets/{repo-git-C1Qv1JmM.js → repo-git-QEHH7y-w.js} +1 -1
  30. package/web/dist/assets/run-header-BKeByMek.js +1 -0
  31. package/web/dist/assets/{skills-_ZVZxmKz.js → skills-DOT1odMt.js} +1 -1
  32. package/web/dist/assets/{task-changes-BU9upwUw.js → task-changes-CUQTi97I.js} +1 -1
  33. package/web/dist/assets/{task-commits-CbJutMBx.js → task-commits-D_N8-awD.js} +1 -1
  34. package/web/dist/assets/{task-files-_hQyxAc7.js → task-files-CfYcMt07.js} +1 -1
  35. package/web/dist/assets/task-thread-Bnd_Pc07.js +9 -0
  36. package/web/dist/assets/thread-loading-B0WsjYr0.js +1 -0
  37. package/web/dist/assets/{workflows-B6Er16t0.js → workflows-C1I-xV9B.js} +1 -1
  38. package/web/dist/index.html +4 -4
  39. package/web/dist/assets/index-DPOGn7D5.css +0 -1
  40. package/web/dist/assets/pill-Dvvq0Otw.js +0 -1
  41. package/web/dist/assets/run-header-C9Aeh27u.js +0 -1
  42. package/web/dist/assets/task-thread-Yo52ML6l.js +0 -9
  43. package/web/dist/assets/thread-loading-B9uTF0dX.js +0 -1
@@ -1,9 +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{Aa as r,Ca as i,Da as a,Dt as o,Ea as s,Et as c,Fa as l,Fr as u,H as d,J as f,Jt as p,Ma as m,Mi as h,Mn as g,Ni as _,On as v,Pa as y,Pn as b,Pr as x,Pt as S,Q as C,Qn as w,Rn as T,Rt as E,Ta as D,X as O,Xr as k,Y as A,Z as j,_i as M,at as ee,ci as N,cr as P,d as F,dr as te,en as I,et as L,fa as ne,fn as re,gn as ie,ht as ae,in as R,it as oe,l as se,ma as z,ni as ce,nt as le,pi as ue,qn as de,qt as fe,sa as B,si as pe,sr as me,u as he,xa as ge,xt as _e}from"./alert-dialog-BOp2HnnL.js";import{C as ve,S as ye,T as be,c as xe,i as Se,n as Ce,s as we,t as V,w as Te,x as Ee,y as De}from"./utils-GZNjgma4.js";import{n as Oe,r as ke,t as Ae}from"./collapsible-bb0csfMs.js";import{n as je,s as Me,t as Ne}from"./agent-accounts-BxBsIXGa.js";import{t as Pe}from"./textarea-DfvlPIgO.js";import{t as H}from"./createLucideIcon-BHp8sXmF.js";import{A as Fe,E as Ie,O as Le,b as Re,d as ze,g as Be,l as Ve,m as He,s as Ue,u as We}from"./pill-Dvvq0Otw.js";import{t as Ge}from"./external-link-BE6y205O.js";import{I as Ke,S as qe,_ as Je,b as Ye,c as Xe,g as Ze,l as Qe,v as $e,x as et}from"./prompt-templates-BGGpAIzb.js";import{a as tt,c as nt,i as rt,l as it,n as at,o as ot,r as st,s as ct,t as lt,u as ut}from"./run-header-C9Aeh27u.js";import{s as dt,t as U,u as W}from"./project-router-CvFAMDcP.js";import{t as ft}from"./message-square-B-MD-8rD.js";import{t as pt}from"./search-x-I9Q8pgUa.js";import{t as mt}from"./square-terminal-B6RYYieR.js";import{t as G}from"./markdown-Ir62-VMS.js";import{c as ht,i as gt,l as _t,n as vt,o as yt,s as bt,t as xt}from"./thread-loading-B9uTF0dX.js";import{t as St}from"./use-submit-shortcut-KWJsC906.js";import{t as Ct}from"./lib-BQXq3kEf.js";import{t as wt}from"./zoomable-image-COhBxkky.js";import{t as Tt}from"./run-diff-DrQsmf3-.js";import{t as Et}from"./use-desktop-BaYgO7YW.js";var Dt=120;function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Dt?`${t.slice(0,Dt-1)}…`:t}function J(e,...t){if(K(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return q(t)}}function Ot(e){if(!K(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return q(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return q(e.join(` `))}}function kt(e){if(!K(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)K(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function At(e){return J(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function Y(e,t){return t?`${e} ${t}`:e}function jt(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:Y(`Ran`,Ot(t)),subtitle:J(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:Y(`Edit`,J(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:Y(`Write`,J(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:Y(`Edit`,J(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=kt(t);return{toolKind:`edit`,title:Y(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:Y(`Read`,J(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:Y(`View image`,J(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:Y(`Search`,J(t,`pattern`,`query`)),subtitle:J(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:Y(`Fetch`,J(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:Y(`Web search`,J(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=J(t,`subagent_type`,`subagentType`),i=J(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=J(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:J(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=J(t,`server`),n=J(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:At(t)}}}if(n.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()!==``?q(e):`Tool`,subtitle:At(t)}}var Mt=class extends m{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,u=o&&c===`forward`,d=i&&c===`forward`,f=o&&c===`backward`,p=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:y(t,n.data),hasPreviousPage:l(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:s&&!u&&!f,isRefetching:a&&!d&&!p}}};function Nt(e,t){return a(e,Mt,t)}var Pt=H(`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`}]]),Ft=H(`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`}]]),It=H(`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`}]]),Lt=H(`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`}]]),Rt=H(`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`}]]),X=e(t(),1),zt=[`run-event`,`ui-event`];function Bt(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function Vt(e,t={}){let[n,r]=(0,X.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,X.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),m,h=e=>{p=Date.now();let t=Bt(e.data);!t||!(t.seq>n)||(n=t.seq,r(e=>{let n=[...e,t];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)}))},g=()=>{p=Date.now()},_=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||v()},1500))},v=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(Se(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of zt)l.addEventListener(e,h);l.addEventListener(`ping`,g),l.addEventListener(`error`,()=>{l?.readyState===2&&_()})},y=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,v())},b=()=>{clearTimeout(u),u=void 0,l?.close()},x=e=>{e.persisted&&v()};return m=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,v())},1e4),document.addEventListener(`visibilitychange`,y),window.addEventListener(`pagehide`,b),window.addEventListener(`pageshow`,x),v(),()=>{d=!0,clearTimeout(u),clearInterval(m),document.removeEventListener(`visibilitychange`,y),window.removeEventListener(`pagehide`,b),window.removeEventListener(`pageshow`,x),l?.close()}},[e,i,a,o,s,c]),n}var Ht=5,Ut=200,Wt=5e3;function Gt(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function Kt(e){let t=we(),n=r(),i=[`run-history`,t,e],a=[`run-history-context`,t,e],o=Nt({queryKey:i,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>h(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:Ht,retry:1}),c=s({queryKey:a,enabled:e!==void 0,queryFn:({signal:t})=>_(e,{signal:t}),retry:1}),l=o.isError||c.isError,u=Vt(l?e:void 0),d=o.data?.pages??[],f=d.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),p=(0,X.useRef)(!1),m=(0,X.useCallback)(()=>{e===void 0||p.current||(p.current=!0,h(e,void 0).then(r=>{n.setQueryData([`run-history`,t,e],e=>{if(!e)return{pages:[r],pageParams:[void 0]};let t=[...e.pages],n=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);for(i>=0&&t[i].newerCursor===void 0?(t[i]=r,n[i]=void 0):(t.push(r),n.push(void 0));t.length>Ht;)t.shift(),n.shift();return{pages:t,pageParams:n}})}).catch(()=>{}).finally(()=>{p.current=!1}))},[n,e,t]),g=Vt(!l&&f?e:void 0,{cursor:f?.liveCursor,afterSeq:f?.asOfSeq,maxEvents:Wt,compactAt:Ut,onCompact:m}),v=(0,X.useMemo)(()=>Gt(...d.map(e=>e.events)),[d]),y=(0,X.useMemo)(()=>l?u:Gt(v,g),[l,u,v,g]),b=(0,X.useMemo)(()=>{if(l)return u;let e=c.data?.contextEvents??[],t=c.data?.asOfSeq??0;return Gt(e,y.filter(({seq:e})=>e>t))},[c.data,l,u,y]),x=(0,X.useCallback)(async()=>{await o.fetchPreviousPage()},[o.fetchPreviousPage]),S=(0,X.useCallback)(async()=>{l||await n.resetQueries({queryKey:i,exact:!0})},[l,i,n]);return{visibleEvents:y,currentEvents:b,isPending:!l&&o.isPending,contextPending:!l&&c.isPending,fallback:l,hasOlder:!l&&!!o.hasPreviousPage,isFetchingOlder:o.isFetchingPreviousPage,olderError:o.isFetchPreviousPageError?o.error instanceof Error?o.error.message:`Could not load earlier items`:void 0,loadOlder:x,jumpToLatest:S,retainedPages:d.length}}var Z=n();function qt({run:e}){let t=r(),n=D({mutationFn:()=>pe(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:R.runs.detail(e.id)}),t.invalidateQueries({queryKey:R.runs.list()}),B(`This task will not resume itself`)},onError:e=>B(e.message,{tone:`danger`})});if(e.status!==`failed`||!e.autoResumeAt)return null;let i=new Date(e.autoResumeAt);if(!Number.isFinite(i.getTime()))return null;let a=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(i);return(0,Z.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,Z.jsx)(Le,{tone:`pending`,pulse:!0}),(0,Z.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:a})]}),(0,Z.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,Z.jsx)(z,{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`})]})}var Jt=e=>e.kind===`tool`,Yt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Xt=(e,t,n)=>`${e} ${e===1?t:n}`;function Zt(e,t){let n=[];return e>0&&n.push(Xt(e,`file`,`files`)),t>0&&n.push(Xt(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Qt(e){return`${e} earlier tool call${e===1?``:`s`}`}var $t=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function en(e){for(let t of $t)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 tn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Jt).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&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:Zt(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=[]};for(let e of i)Jt(e)&&Yt(e)&&!r.has(e.id)?o.push(e):(s(),Jt(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();let c=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,l=e=>e.kind===`context-group`?e.tools.length:1,u=[],d=[],f=()=>{if(d.length>3){let e=d.slice(0,d.length-3);u.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+l(t),0),blocks:e}),u.push(...d.slice(d.length-3))}else u.push(...d);d=[]};for(let e of a)c(e)?d.push(e):(f(),u.push(e));return f(),u}var nn=new Map,rn=(0,X.createContext)(null);function an(){return(0,X.useContext)(rn)}function on({runId:e,children:t}){let n=(0,X.useMemo)(()=>({get:t=>nn.get(e)?.get(t),set:(t,n)=>{let r=nn.get(e)??new Map;r.set(t,n),nn.set(e,r)}}),[e]);return(0,Z.jsx)(rn.Provider,{value:n,children:t})}function sn(e){return e.scrollTop<Math.max(600,e.clientHeight)}function cn(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function ln(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 un(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function dn(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var fn=new Map;function pn(e,t){fn.set(e,t)}function mn(e){return fn.get(e)}var hn=new Map;function gn(e,t){hn.set(e,t)}function _n(e,t){let n=hn.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}var vn={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg`,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`,accent:`text-message-agent-accent`,body:`max-md:text-[13px]`}};function yn({role:e,children:t,className:n,...r}){let i=vn[e];return(0,Z.jsxs)(`article`,{...r,"data-role":e,"aria-label":i.speaker,className:V(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,i.classes,n),children:[(0,Z.jsxs)(`p`,{className:V(`m-0 flex items-center gap-2 text-[11px] leading-none font-semibold tracking-[0.6px] uppercase`,i.accent),children:[(0,Z.jsx)(ft,{"aria-hidden":`true`,className:`size-4 shrink-0`}),i.label]}),(0,Z.jsx)(`div`,{className:V(`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,i.body),children:t})]})}function bn({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let s=t-n.length,[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(e),[f,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(),_=()=>{d(e),g(void 0),l(!0)},v=async()=>{let t=u.trim();if(!t||t===e){l(!1);return}m(!0),g(void 0);try{await r?.(t),l(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{m(!1)}},y=async()=>{m(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{m(!1)}};return c?(0,Z.jsxs)(yn,{role:`user`,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,Z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),l(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[13.5px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,Z.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l(!1),disabled:f,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,Z.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:f,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:f?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):`Save`})]}),h?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:h}):null]}):(0,Z.jsxs)(yn,{role:`user`,"data-slot":`user-bubble`,className:`group`,children:[r||i?(0,Z.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:[r?(0,Z.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:f,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,Z.jsx)(Rt,{className:`size-3.5`})}):null,i?(0,Z.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:f,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,Z.jsx)(p,{className:`size-3.5`})}):null]}):null,h?(0,Z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:h}):null,(0,Z.jsx)(G,{breaks:!0,children:e}),n.length>0?(0,Z.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>De(e.split(`/`).pop()??``)?(0,Z.jsx)(wt,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,Z.jsxs)(`a`,{href:xe(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,Z.jsx)(S,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,s>0?(0,Z.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[s,` image`,s>1?`s`:``,` attached`]}):null]})}function xn({text:e}){return(0,Z.jsx)(yn,{role:`agent`,"data-slot":`assistant-message`,children:(0,Z.jsx)(G,{children:e})})}function Sn({note:e}){return(0,Z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:V(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Cn={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function wn({incident:e}){let t=Cn[e.provider];return(0,Z.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,Z.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,Z.jsx)(U,{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 Tn({text:e}){let t=(0,X.useId)();if(e.trim()===``)return null;let n=e.split(`
2
- `,1)[0]??``,r=n.length<e.length;return(0,Z.jsxs)(Ae,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,Z.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,Z.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,Z.jsx)(G,{inline:!0,children:n})}),r?(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,Z.jsx)(ke,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,Z.jsx)(Oe,{children:(0,Z.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,Z.jsx)(G,{children:e})})})]})}function En(){return(0,Z.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,Z.jsx)(W,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,Z.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Dn={read:ut,edit:Rt,delete:p,move:It,search:E,execute:mt,think:Pt,fetch:Fe,task:f,plan:o,other:I},On=e=>e.split(`
3
- `).length;function kn({text:e,streaming:t}){let[n,r]=(0,X.useState)(!1),i=(0,X.useRef)(null),a=(0,X.useRef)(!0);(0,X.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=On(e),s=!t&&!n&&o>12;return(0,Z.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=un(e.currentTarget)}:void 0,className:V(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,Z.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,Z.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,Z.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 An({diffs:e}){return(0,Z.jsx)(Z.Fragment,{children:e.map((e,t)=>(0,Z.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...jn(e.oldText).map((e,t)=>(0,Z.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...jn(e.newText).map((e,t)=>(0,Z.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
- `).map((e,t)=>(0,Z.jsx)(Mn,{text:e},t))})]},`${e.path}:${t}`))})}function jn(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
- `)}function Mn({text:e}){return(0,Z.jsx)(`span`,{className:V(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function Nn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function Pn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=an(),[a,o]=(0,X.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},c=e.status===`running`||e.status===`pending`,l=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,u=l&&(a??Nn(e)),{verb:d,detail:f}=en(e.title),p=Dn[e.toolKind]??I;return(0,Z.jsxs)(Ae,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:u,onOpenChange:s,className:V(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,Z.jsxs)(ke,{disabled:!l,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,Z.jsx)(j,{"aria-hidden":!0,className:V(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!l&&`invisible`)}),(0,Z.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:V(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:d}),f===void 0?null:(0,Z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:f}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,Z.jsx)(W,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,Z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,Z.jsx)(`span`,{"data-slot":`tool-exit`,className:V(`rounded-full px-2 py-px font-mono text-[10.5px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,Z.jsx)(Oe,{children:(0,Z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.error!==void 0&&e.error!==``?(0,Z.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,Z.jsx)(An,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,Z.jsx)(kn,{text:e.output,streaming:c}):null,t.length>0?(0,Z.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:r?.(t,n??e.id)}):null]})})]})}function Fn({group:e,scope:t}){return(0,Z.jsxs)(Ae,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,Z.jsxs)(ke,{className:`group flex h-[34px] 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,Z.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,Z.jsx)(Oe,{children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,Z.jsx)(Pn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function In({count:e,children:t}){return(0,Z.jsxs)(Ae,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,Z.jsxs)(ke,{className:`group flex items-center gap-1.5 rounded-md p-0.5 text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,Z.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Qt(e)]}),(0,Z.jsx)(Oe,{children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Ln({image:e}){return(0,Z.jsx)(wt,{"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 Rn(e,t=null){let n=T(),r=re(),i=ze(e),a=i&&!e.runner,o=ne(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=qe(t,o,s),l=o.includes(s),u=(i?Ee(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=a&&r.isPending?`Checking task settings…`:a&&r.isError?`Task settings could not be loaded.`:n.isPending?`Checking agent providers…`:n.isError?`Provider authentication could not be verified.`:d?void 0:i?`Connect the required workflow providers (${u.join(`, `)}) to continue.`:`Connect an agent provider to continue.`;return{runners:o,currentRunner:s,runner:c,currentRunnerConnected:l,canContinue:d,providerPending:n.isPending||a&&r.isPending,providerError:n.isError,reason:f,runnerOverride:t!==null||!l?c:void 0}}function zn(e){let t=r(),n=Be(e).continueRun,i=re(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(e.id);p!==e.id&&(m(e.id),o(null),c(null),u(null),f(null));let h=Rn(e,a),{runners:g,canContinue:_,currentRunner:v,runner:y}=h,b=me(y,n),x=i.data?.modelsLocked===!0,S=y!==v,C=!x&&!S&&e.model?{...i.data?.defaultModels,[y]:e.model}:i.data?.defaultModels,w=x?null:s,T=$e(y,b.data,[w,C?.[y]]),E=et(w,y,C,b.data),O=Ze(y,E,b.data),k=x?``:l??e.effort??``,A=Ye(k,O),j=!x&&l===null&&k!==``&&A===``,{accounts:M,repoAccount:N}=je(),P=[...e.steps].reverse().find(e=>e.sessionId),F=P?.profileId??e.agentProfile??`default`,te=S?N:{...N,[v]:F},I=M.some(e=>e.provider===y&&e.id===d)?d:null,L=D({mutationFn:({text:t,images:n})=>_?ue(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:h.runnerOverride,model:!x&&s!==null?E:void 0,effort:!x&&l!==null?A:j?``:void 0,agentProfile:I??void 0}):Promise.reject(Error(h.reason??`Connect an agent provider to continue.`)),onSuccess:()=>t.invalidateQueries({queryKey:R.runs.all}),onError:e=>{e instanceof ce&&e.status===409&&t.invalidateQueries({queryKey:R.runs.all})}});return{available:n,canContinue:_,startsNewConversation:!!P&&(y!==(P.backend??v)||(I??e.agentProfile??P.profileId??`default`)!==(P.profileId??`default`)),reason:h.reason,providerPending:h.providerPending,pills:(0,Z.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:[g.length>1||g.some(e=>Ne(M,e))?(0,Z.jsx)(Qe,{icon:(0,Z.jsx)(fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:g,value:y,accounts:M,account:I,repoAccount:te,onPick:(e,t)=>{f(t),e!==y&&(o(e),c(null))}}):(0,Z.jsx)(Xe,{icon:(0,Z.jsx)(fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:y,value:y,onPick:()=>{},options:[{value:y,label:y}]}),(0,Z.jsx)(Xe,{icon:(0,Z.jsx)(ae,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:O.find(e=>e.value===A)?.label??`auto`,value:A,readOnly:x,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>u(e),options:O.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]}),modelPicker:(0,Z.jsx)(Xe,{icon:(0,Z.jsx)(ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:T.find(e=>e.id===E)?.label??`auto`,value:E,readOnly:x,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{c(e);let t=Ze(y,e,b.data);A!==``&&Ye(A,t)===``&&u(``)},options:T.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Je(y,b.data,b.isError,b.isFetching)}),continueWith:(e,t)=>L.mutateAsync({text:e,images:t})}}var Bn=120,Vn=e=>e!==`pending`&&e!==`running`,Hn=e=>e.kind===`tool`&&e.toolKind===`task`,Q=e=>Hn(e)&&e.parentItemId===void 0,Un=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function Wn(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>Q(e)&&t.has(e.id)))return n;return 0}function Gn(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 Kn(e){if(e.kind===`tool`)return qn(e.title);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 qn(n)}}}function qn(e){return e.length>Bn?`${e.slice(0,Bn-1).trimEnd()}…`:e}function Jn(e,t=!1){let n=Qn(e,e=>e.items.some(Q));if(n===-1)return[];let r=e=>!t&&!Vn(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(Q);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(Q)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?Wn(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!Un(n))continue;let e=n.parentItemId;if(e===void 0||!o.has(e))continue;let t=c.get(e);t?t.push(n):c.set(e,[n])}return a.map(e=>Yn(e,c.get(e.id)??[],t))}function Yn(e,t,n){let r={id:e.id,title:en(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Gn(e);i!==void 0&&(r.agentType=i),n&&!Vn(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Kn(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Xn(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Zn(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Qn(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function $n(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&Q(e));if(i!==void 0)return Yn(i,er(e,t),n)}}function er(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&Q(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)Un(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}function tr(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,X.useRef)(e);o.current=e;let s=(0,X.useRef)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!1),f=(0,X.useRef)(!0),p=(0,X.useRef)(null),m=(0,X.useRef)(null),h=(0,X.useRef)(null),g=(0,X.useCallback)(e=>{let t=s.current;if(!t)return;let n=h.current;n?n.scrollTo(e):t.scrollTop=e},[]),_=(0,X.useCallback)(()=>{let e=s.current;e&&g(e.scrollHeight-e.clientHeight)},[g]),v=(0,X.useCallback)(()=>{if(s.current){if(m.current!==e){m.current=e;let t=mn(e);t&&!t.atBottom?(f.current=!1,p.current=t.top):(f.current=!0,p.current=null)}p.current===null?f.current&&_():g(p.current)}},[e,g,_]),y=(0,X.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),v())},[n,v]),b=(0,X.useCallback)(()=>{f.current&&_()},[_]),x=(0,X.useRef)(!1),S=(0,X.useRef)(0),C=(0,X.useRef)(!1),w=(0,X.useRef)(void 0),T=(0,X.useRef)(!1),E=(0,X.useRef)(!1),D=(0,X.useRef)(a);D.current=a;let O=(0,X.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}}),[]),k=(0,X.useRef)(null),A=(0,X.useRef)(0),j=(0,X.useCallback)(()=>{let e=k.current,t=s.current;if(!e||!t)return;k.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:D.current.indexOf(e.anchor.key),a=h.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):g(ln(t.scrollTop,r,e.anchor,O(t),n))},[O,g]),M=(0,X.useCallback)(()=>{let e=s.current;if(!e||!r||x.current)return;p.current=null,f.current=!1,x.current=!0;let t=S.current+1;S.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=cn(a,O(e)),l=c===void 0?-1:D.current.indexOf(c.key),u=o.current,d=A.current;r().then(()=>{o.current===u&&A.current===d&&(k.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{S.current===t&&(x.current=!1)})},[O,r]);(0,X.useEffect)(()=>()=>clearTimeout(w.current),[]);let ee=(0,X.useCallback)(()=>{let t=s.current;if(!t)return;p.current=null,A.current+=1,k.current=null,f.current=!0,pn(e,{top:t.scrollHeight-t.clientHeight,atBottom:!0});let n=()=>{f.current&&_()};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})})},[i,e,_]),N=a.at(-1),P=a.length;return(0,X.useLayoutEffect)(()=>{A.current+=1,k.current=null,x.current=!1},[e]),(0,X.useLayoutEffect)(()=>{let e=k.current;e?(e.anchor===void 0?-1:D.current.indexOf(e.anchor.key))>e.anchorIndex?j():k.current=null:f.current&&_()},[N,P,j,_]),(0,X.useLayoutEffect)(()=>{!s.current||!c||v()},[c,v]),(0,X.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;let r=0,i=null,a=!1,o=t.scrollTop,l=()=>{p.current=null,A.current+=1,k.current=null,f.current=!1,r=0},u=()=>{A.current+=1,k.current=null,r=Date.now()},m=e=>{if(e.deltaY<0){l();let e=!C.current;C.current=!0,clearTimeout(w.current),w.current=setTimeout(()=>{C.current=!1},180),e&&sn(t)&&M()}else u()},h=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(l(),!e.repeat&&sn(t)&&M()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&u()},v=()=>{a=!0,E.current=!1,o=t.scrollTop,un(t,80)||(l(),u())},y=()=>{a=!1},b=e=>{T.current=!1,i=e.touches[0]?.clientY??null},x=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(i!==null&&n>i+1?(l(),!T.current&&sn(t)&&(T.current=!0,M())):i!==null&&n<i-1&&u(),i=n)},S=()=>{a&&!E.current&&t.scrollTop<o&&sn(t)&&(E.current=!0,M()),o=t.scrollTop;let n=un(t,80);n&&p.current===null&&(f.current||Date.now()-r<2e3)&&(f.current=!0),d(!n),p.current===null&&pn(e,{top:t.scrollTop,atBottom:n})};t.addEventListener(`scroll`,S,{passive:!0}),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,b,{passive:!0}),t.addEventListener(`touchmove`,x,{passive:!0}),t.addEventListener(`pointerdown`,v,{passive:!0}),window.addEventListener(`pointerup`,y,{passive:!0}),t.addEventListener(`keydown`,h);let D;if(typeof ResizeObserver<`u`){D=new ResizeObserver(()=>{let e=p.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;g(Math.min(e,n)),n>=e&&(p.current=null)}else f.current&&_()}),D.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&&D.observe(r),i&&D.observe(i)}return()=>{t.removeEventListener(`scroll`,S),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,b),t.removeEventListener(`touchmove`,x),t.removeEventListener(`pointerdown`,v),window.removeEventListener(`pointerup`,y),t.removeEventListener(`keydown`,h),D?.disconnect()}},[e,c,M,g,_]),{attachContent:y,scrollElRef:s,virtualizerRef:h,pillVisible:u,jumpToLatest:ee,loadOlder:M,restickIfStuck:b}}function nr({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Z.jsx)(rr,{runId:e,rows:t,controls:r}):(0,Z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,Z.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 rr({runId:e,rows:t,controls:n}){return(0,Z.jsx)(ir,{runId:e,rows:t,controls:n},e)}function ir({runId:e,rows:t,controls:n}){let r=(0,X.useRef)(null),i=(0,X.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,X.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,X.useState)(()=>_n(e,t.length)),l=(0,X.useRef)(t.length);l.current=t.length;let u=(0,X.useRef)(null),d=(0,X.useCallback)(t=>{n.virtualizerRef.current=t,t?u.current=t:u.current&&=(gn(e,{rows:l.current,cache:u.current.cache}),null)},[e,n.virtualizerRef]),[f,p]=(0,X.useState)(0);return(0,X.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||p(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,Z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,Z.jsx)(Ct,{ref:d,scrollRef:n.scrollElRef,startMargin:f,shift:s,...c===void 0?{}:{cache:c},children:t.map(e=>(0,Z.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))})})}function ar({onJump:e}){return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,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,Z.jsx)(d,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}function or(e,t){let n=[];e.task&&n.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[]},entries:[]});for(let t of e.queuedMessages??[])n.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[]},entries:[]});for(let e of t.turns)n.push({id:e.id,userMessageKey:`${e.id}:user`,...e.userMessage===void 0?{}:{userMessage:{text:e.userMessage.text,imageCount:e.userMessage.imageCount,images:e.userMessage.images}},entries:e.items});return n}function sr(e,t){return[{id:`agent:${e}`,entries:t}]}function cr(e,t){let n=[];for(let t of e){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 tn([...t.entries]))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}})}return n}function lr({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,messageActions:o,scrollControls:s,renderMode:c}){let l=(0,X.useMemo)(()=>cr(n,e),[n,e]),u=tr(`${e}:${t}`,{surface:r}),d=s??u,f=(0,X.useMemo)(()=>l.map(e=>({key:e.key,node:e.content.kind===`user-message`?(0,Z.jsx)(ur,{message:e.content.message,actions:o?.[e.key]}):(0,Z.jsx)(dr,{block:e.content.block,scope:e.scope,renderAsk:a})})),[o,a,l]),p=c??dn(``,f.length),m=f.length===0?i??null:(0,Z.jsx)(nr,{runId:`${e}:${t}`,rows:f,mode:p,controls:d});return(0,Z.jsx)(on,{runId:e,children:r===`panel`?(0,Z.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,Z.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:m}),d.pillVisible?(0,Z.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,Z.jsx)(ar,{onJump:d.jumpToLatest})}):null]}):m})}function ur({message:e,actions:t}){return(0,Z.jsx)(bn,{text:e.text,imageCount:e.imageCount,images:e.images,onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel})}function dr({block:e,scope:t,renderAsk:n}){switch(e.kind){case`entry`:return(0,Z.jsx)(pr,{entry:e.entry,scope:t,renderAsk:n});case`tool-card`:return(0,Z.jsx)(Pn,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Z.jsx)(fr,{entries:e,scope:t,renderAsk:n})});case`context-group`:return(0,Z.jsx)(Fn,{group:e,scope:t});case`streak`:return(0,Z.jsx)(In,{count:e.count,children:e.blocks.map(e=>(0,Z.jsx)(dr,{block:e,scope:t,renderAsk:n},e.id))});default:return mr(e)}}function fr({entries:e,scope:t,renderAsk:n}){return tn([...e]).map(e=>(0,Z.jsx)(dr,{block:e,scope:t,renderAsk:n},e.id))}function pr({entry:e,scope:t,renderAsk:n}){switch(e.kind){case`message`:return e.role===`assistant`?(0,Z.jsx)(xn,{text:e.text}):(0,Z.jsx)(bn,{text:e.text});case`reasoning`:return(0,Z.jsx)(Tn,{text:e.text});case`tool`:return(0,Z.jsx)(Pn,{item:e,cacheKey:`${t}:${e.id}`});case`note`:if(e.conversation){let t=e.conversation,n=`inline-flex min-h-11 max-w-full items-center break-all underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;return(0,Z.jsxs)(`div`,{"data-slot":`conversation-message`,className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0 space-y-1 break-all text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`p`,{className:`capitalize`,children:[`Agent `,t.kind]}),(0,Z.jsx)(`p`,{children:(0,Z.jsxs)(U,{className:n,to:`/tasks/${t.senderRunId}`,"aria-label":`Sender task ${t.senderRunId}`,children:[`Sender task `,t.senderRunId]})}),(0,Z.jsx)(`p`,{children:(0,Z.jsxs)(U,{className:n,to:`/tasks/${t.recipientRunId}`,"aria-label":`Recipient task ${t.recipientRunId}`,children:[`Recipient task `,t.recipientRunId]})}),(0,Z.jsxs)(`p`,{children:[`Message `,t.id,t.kind===`request`||t.requestId?` · Request ${t.requestId??t.id}`:``]}),(0,Z.jsxs)(`p`,{children:[`Delivery: `,t.delivery,t.state&&t.state!==`accepted`?` · ${t.state}`:``]})]}),(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:(0,Z.jsx)(Sn,{note:e})})]})}return e.attribution?(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Z.jsx)(`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}`}),(0,Z.jsx)(Sn,{note:e})]}):(0,Z.jsx)(Sn,{note:e});case`image`:return(0,Z.jsx)(Ln,{image:e});case`ask`:return n===void 0?(0,Z.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`provider-auth-required`:return(0,Z.jsx)(wn,{incident:e});default:return mr(e)}}function mr(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function hr({runId:e,renderAsk:t,agent:n,entries:r,onClose:i}){return(0,Z.jsx)(gt,{open:n!==void 0,onOpenChange:e=>{e||i()},children:(0,Z.jsx)(yt,{"data-slot":`subagent-sheet`,side:`right`,className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:n===void 0?null:(0,Z.jsx)(gr,{runId:e,renderAsk:t,agent:n,entries:r})})})}function gr({runId:e,renderAsk:t,agent:n,entries:r}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ht,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Z.jsxs)(_t,{className:`flex min-w-0 items-center gap-2 pr-8 text-[15px]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n.title}),n.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:n.agentType})]}),(0,Z.jsxs)(bt,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(_r,{status:n.status}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[n.toolCalls,` `,n.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Z.jsx)(lr,{runId:e,viewId:`agent:${n.id}`,sections:sr(n.id,r),mode:`panel`,renderAsk:t,empty:(0,Z.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 _r({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,Z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:V(`rounded-full px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function vr({run:e}){return(0,Z.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,Z.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,Z.jsx)(Ke,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,Z.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,Z.jsx)(Tt,{runId:e.id}),(0,Z.jsx)(yr,{run:e})]})}function yr({run:e}){let t=r(),n=(0,X.useRef)(null),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(null),c=at(e.id),l=Rn(e),u=()=>t.invalidateQueries({queryKey:R.runs.all}),d=D({mutationFn:async t=>l.canContinue?ue(e.id,{text:`Review feedback:\n${t}`,runner:l.runnerOverride}):null,onSuccess:e=>{e!==null&&(a(``),u())},onError:e=>B(e.message,{tone:`danger`})}),f=D({mutationFn:()=>M(e.id),onSuccess:e=>{B(`Draft PR created — ${e.url}`),u()},onError:e=>{e instanceof ce&&e.manual!==void 0&&s(e.manual),B(e.message,{tone:`danger`})}}),p=()=>{let e=i.trim();if(e.length===0){B(`Write what to change first.`),n.current?.focus();return}d.mutate(e)};return(0,Z.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Pe,{ref:n,"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=>{St({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(),p())},className:`min-h-[52px] text-[13px]`}),l.canContinue?null:(0,Z.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:l.reason}),l.providerPending?null:(0,Z.jsx)(U,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(F,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:l.reason??`Send the notes back into the agent's session`,"aria-describedby":l.canContinue?void 0:`review-provider-guidance`,disabled:d.isPending||!l.canContinue,onClick:p,children:[(0,Z.jsx)(Ft,{"aria-hidden":`true`}),`Send back`]}),Ce(e.pullRequestUrl)?(0,Z.jsx)(F,{asChild:!0,variant:`outline`,size:`sm`,children:(0,Z.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,Z.jsx)(Ge,{"aria-hidden":`true`}),`PR ↗`]})}):(0,Z.jsxs)(F,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:f.isPending,onClick:()=>f.mutate(),children:[(0,Z.jsx)(_e,{"aria-hidden":`true`}),`Draft PR`]}),(0,Z.jsxs)(F,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:Ve(`review`),disabled:c.isPending,onClick:()=>c.mutate(),children:[(0,Z.jsx)(A,{"aria-hidden":`true`}),`Accept`]})]}),o===null?null:(0,Z.jsx)(br,{command:o})]})}function br({command:e}){return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>B(`Command copied to clipboard.`)).catch(()=>B(`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,Z.jsx)(oe,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function xr(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Sr=1500;function Cr({status:e}){let t=(0,X.useRef)(e),[n,r]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||xr())return;r(!0);let i=setTimeout(()=>r(!1),Sr);return()=>clearTimeout(i)},[e]),n?(0,Z.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,Z.jsx)(he,{}),(0,Z.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,Z.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 wr(e){let t=r(),[n,i]=(0,X.useState)(),a=We(e.status);(0,X.useEffect)(()=>{(!a||n&&n!==e.id)&&i(void 0)},[a,e.id,n]);let o=D({mutationFn:async()=>{i(e.id);try{if(!(await N(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw i(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:R.runs.all})});return{stopping:!!e.stopping||o.isPending||a&&n===e.id,stop:()=>o.mutateAsync()}}function Tr({agents:e,onSelect:t}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,Z.jsx)(Er,{agent:e,onSelect:t},e.id))})}function Er({agent:e,onSelect:t}){let n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Dr,{status:e.status,stalled:e.stalled===!0}),(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Zn(e)}),(0,Z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,Z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,Z.jsx)(`button`,{type:`button`,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,Z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Dr({status:e,stalled:t=!1}){return t?(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,Z.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,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Or(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function kr({entries:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,Z.jsx)(Ar,{entry:e},`${t}:${e.content}`))})}function Ar({entry:e}){return(0,Z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:V(`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,Z.jsx)(jr,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,Z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function jr({status:e}){return e===`cancelled`?(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Z.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,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Z.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,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function Mr(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function Nr(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 Pr(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 Fr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`string`?e:void 0}function Ir(e){return e===`claude`||e===`codex`||e===`opencode`||e===`pi`||e===`cursor`?e:void 0}function Lr(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);return t&&(n=n.replace(/\s*CEZ:ASK[ \t]+[\s\S]*$/,``)),n.includes(`CEZ:`)?n.split(`
7
- `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
8
- `):n}function Rr(e){let t=e=>Lr(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 zr(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var Br=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,Vr=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Hr(e){if(!Fr(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!Fr(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Vr.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function Ur(e,t={}){let n=[],r=new Map,i,a=0,o,s=e=>{a+=1;let t={id:e===void 0?`turn-fallback-${a}`:`turn-seq-${e}`,entries:[],v2Items:!1};return n.push(t),t},c=()=>n.at(-1)??s(),l=(e,t)=>{let n=$(e.stepId);return n===void 0?t:`${n}:${t}`},u=(e,t,n)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&r.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=r.get(n);if(a&&a.turn===e){a.entry.entry=i,r.set(n,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),r.set(n,{turn:e,entry:o})},d=new Map,f=new Set,p=new Set;for(let t of e)switch(t.type){case`conversation-message`:{let e=Te.safeParse(t);if(!e.success)break;let{message:n}=e.data,r=d.get(n.id);if(r){r.conversation&&r.conversation.delivery!==`delivered`&&(r.conversation.delivery=e.data.delivery);break}let i={kind:`note`,id:`conversation-message:${n.id}`,text:n.text,tone:`dim`,conversation:{...n,delivery:e.data.delivery}};d.set(n.id,i),c().entries.push({origin:`meta`,entry:i});break}case`request-outcome`:{let e=be.safeParse(t);if(!e.success||f.has(e.data.outcome.requestId))break;let{outcome:n}=e.data;f.add(n.requestId),c().entries.push({origin:`meta`,entry:{kind:`note`,id:`request-outcome:${n.requestId}`,text:`Request outcome: ${n.status} · Request ${n.requestId}${n.replyId?` · Reply ${n.replyId}`:``}`,tone:`dim`}});break}case`agent-input`:{let e=ve.safeParse(t);if(!e.success)break;let{input:n}=e.data;if(p.has(n.id))break;if(p.add(n.id),n.conversation){let e=d.get(n.id);if(e?.conversation)e.conversation.delivery=`delivered`;else{let e={kind:`note`,id:`conversation-message:${n.id}`,text:n.text,tone:`dim`,conversation:{id:n.id,...n.conversation,delivery:`delivered`}};d.set(n.id,e),c().entries.push({origin:`meta`,entry:e})}break}c().entries.push({origin:`meta`,entry:{kind:`note`,id:`agent-input:${n.id}`,text:n.text,tone:`dim`,attribution:{source:n.source,parentRunId:n.parentRunId}}});break}case`user-message`:{let e=$(t.text)??``;o&&!o.resolved&&(o.resolved=!0,e!==``&&(o.answer=e),o=void 0);let n=s(t.seq);n.userMessage={text:e,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[]};break}case`turn.started`:{let e=$(t.turnId),r=n.at(-1);r&&r.turnId===void 0&&!r.v2Items?r.turnId=e:s(t.seq).turnId=e;break}case`turn.completed`:{let e=$(t.turnId),r;for(let t=n.length-1;t>=0&&!r;--t)n[t].turnId===e&&(r=n[t]);let i=r??n.at(-1);i&&(i.completed={stopReason:$(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{}});break}case`item.started`:case`item.updated`:case`item.completed`:{if(!Fr(t.item))break;let e=t.item.kind,n=t.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof n!=`string`||n===``)break;let i=t.item,a=l(t,i.id);u(r.get(a)?.turn??c(),i,a);break}case`item.delta`:{let e=$(t.itemId)??``,n=r.get(l(t,e)),i=$(t.delta)??``;if(!n||i===``||!Br(n.entry.entry))break;let a=n.entry.entry;t.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+i:t.field!==`output`&&a.kind!==`tool`&&(a.text+=i);break}case`text`:{let e=c(),n=$(t.text)??``;if(n===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:n}});break}case`tool-call`:{let e=c();if(e.v2Items)break;let n=$(t.tool)??`Tool`;if(Wr.has(n))break;let i=jt(n,t.input);if(i.toolKind===`plan`){let n=Hr(t.input);n!==void 0&&(e.planEntries=n)}let a={kind:`tool`,id:$(t.id)??`v1:${t.seq}`,name:n,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},o={origin:`v1`,entry:a};e.entries.push(o),r.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=r.get($(t.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let n=e.entry.entry;if(n.kind!==`tool`)break;n.status=`completed`,n.output=zr(t.result);break}case`note`:case`lifecycle`:{let e=$(t.message)??``;if(e===``)break;let n=t.tone===`danger`?`danger`:`dim`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:n}});break}case`error`:{let e=$(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=$(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${t.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(t.status!==`failed`)break;let e=$(t.error)?` — ${$(t.error)}`:``;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:`step ${$(t.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=$(t.command)??`check`,n=typeof t.exitCode==`number`?t.exitCode:-1,r={kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:n===0?`completed`:`failed`,output:$(t.text)??``,exitCode:n};c().entries.push({origin:`meta`,entry:r});break}case`provider-auth-required`:{let e=Ir(t.provider),n=$(t.authFailureId);if(e===void 0||n===void 0||n.length<1||n.length>128)break;c().entries.push({origin:`meta`,entry:{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:e,authFailureId:n}});break}case`image`:{let e=$(t.url);if(e===void 0)break;let n={kind:`image`,id:`v1:${t.seq}`,url:e},r=$(t.name);r!==void 0&&(n.name=r),c().entries.push({origin:`meta`,entry:n});break}case`plan.updated`:Array.isArray(t.entries)&&(c().planEntries=t.entries);break;case`session.ended`:i={reason:$(t.reason)??`end_turn`,...$(t.message)===void 0?{}:{message:$(t.message)}};break;case`ask.requested`:{let e=$(t.requestId);if(e===void 0||!Array.isArray(t.questions))break;let n=t.questions.filter(e=>Fr(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(n.length===0)break;let r={kind:`ask`,id:e,questions:n,resolved:!1};c().entries.push({origin:`meta`,entry:r}),o=r;break}case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of n){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add(Lr(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has(Lr(e.entry.text,!0).trim()))),Rr(e))}return{turns:n.map((e,r)=>{let i=e.entries.some(({entry:e})=>e.kind===`ask`),a=t.activeTurn===!0&&r===n.length-1;return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...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:Lr(e.text,i||a)}:e)}}),...i===void 0?{}:{sessionEnded:i}}}var Wr=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]),Gr=new Map,Kr=new Map;function qr({run:e,currentThread:t,onOpenWorker:n}){let r=Et(),[i,a]=(0,X.useState)(()=>Gr.get(e.id)??r),[s,l]=(0,X.useState)({}),u=!(e.status===`running`||e.status===`waiting`)&&e.status!==`queued`,d=e.steps,p=(0,X.useMemo)(()=>Jn(t.turns,u),[t.turns,u]),m=Mr(t)??[],h=e.delegation!==void 0&&e.delegation.role!==`invalid`,g=ct(e),_=d.length===0||d.every(e=>e.status===`done`||e.status===`skipped`),v=Xn(p),y=Or(m),b=[d.length>0?`workflow`:void 0,p.length>0?`subagents`:void 0,h?`workers`:void 0,m.length>0?`plan`:void 0].filter(e=>e!==void 0);if(b.length===0)return null;let x=t=>s[t]??Kr.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);Kr.set(`${e.id}:${t}`,n),l(e=>({...e,[t]:n}))},w=e.status===`done`&&_&&g===`complete`&&v.done===v.total&&y.done===y.total,T=g===`pending`,E=w?`All complete`:e.status===`failed`?`Failed`:e.status===`cancelled`?`Cancelled`:e.status===`running`?`Working`:e.status===`done`?g===`unknown`?`Workers unavailable`:T?`In progress`:`Incomplete`:`In progress`,D=e.status===`failed`||e.status===`cancelled`;return(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-state":i?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>{Gr.set(e.id,!i),a(!i)},className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-left text-[13.5px] hover:bg-muted/40`,children:[(0,Z.jsx)(c,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Run activity`}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-count`,className:`shrink-0 text-[12.5px] text-muted-foreground tabular-nums`,children:[`· `,b.length,` `,b.length===1?`section`:`sections`]}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-status`,className:V(`ml-auto flex min-w-0 shrink items-center gap-1.5 truncate text-[12.5px]`,w?`text-success`:D?`text-danger`:`text-muted-foreground`),children:[w?(0,Z.jsx)(C,{"aria-hidden":!0,className:`size-3.5 shrink-0`}):null,(0,Z.jsx)(`span`,{className:`truncate`,children:E})]}),(0,Z.jsx)(O,{"aria-hidden":!0,className:V(`size-4 shrink-0 text-soft-foreground transition-transform`,i&&`rotate-180`)})]}),i?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[d.length>0?(0,Z.jsx)(nt,{slot:`workflow`,icon:(0,Z.jsx)(Jr,{steps:d}),title:d[rt(d)].name,meta:it(rt(d)+1,d.length,r,`step`),open:x(`workflow`),onToggle:()=>S(`workflow`),children:(0,Z.jsx)(st,{steps:d})}):null,p.length>0?(0,Z.jsx)(nt,{slot:`subagents`,icon:(0,Z.jsx)(f,{className:`size-4`}),title:`Subagents`,meta:it(v.done,v.total,r),open:x(`subagents`),onToggle:()=>S(`subagents`),children:(0,Z.jsx)(Tr,{agents:p,onSelect:n})}):null,h?(0,Z.jsx)(ot,{run:e,open:x(`workers`),onToggle:()=>S(`workers`)}):null,m.length>0?(0,Z.jsx)(nt,{slot:`plan`,icon:(0,Z.jsx)(o,{className:`size-4`}),title:`Plan`,meta:it(y.done,y.total,r),open:x(`plan`),onToggle:()=>S(`plan`),children:(0,Z.jsx)(kr,{entries:m})}):null]}):null]})}function Jr({steps:e}){let t=tt(e[rt(e)].status),n=`size-4 shrink-0`;switch(t){case`active`:return(0,Z.jsx)(W,{role:`status`,"aria-label":`Step running`,"data-slot":`workflow-glyph`,"data-visual":t,className:V(n,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,Z.jsx)(le,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:V(n,`text-danger`)});case`pending`:return(0,Z.jsx)(L,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:V(n,`text-soft-foreground`)});case`done`:return(0,Z.jsx)(C,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:V(n,`text-success`)})}}function Yr(e,t){return`${e.header}: ${t.join(`, `)}`}function Xr({ask:e,run:t}){return e.resolved?(0,Z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,Z.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):(0,Z.jsx)(Zr,{ask:e,run:t})}function Zr({ask:e,run:t}){let n=Ue(t),r=n.blockedBy!==void 0,i=e.questions,a=i.length===1&&i[0]?.multiSelect!==!0,[o,s]=(0,X.useState)({}),c=(e,t)=>s(n=>({...n,[e]:t})),l=i.every((e,t)=>(o[t]?.length??0)>0),u=()=>void n.send(i.map((e,t)=>Yr(e,o[t]??[])).join(`
9
- `)),d=n.mode===`resume`;return(0,Z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-delivery":n.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,Z.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:i.map((e,t)=>(0,Z.jsx)(Qr,{question:e,disabled:n.isPending||r,selected:o[t]??[],onSelect:i=>{r||(a?n.send(Yr(e,i)):c(t,i))}},e.id??t))}),a?d?(0,Z.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mt-3 text-[11.5px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,Z.jsx)(F,{size:`sm`,disabled:n.isPending||r||!l,onClick:u,children:d?`Send answer & reopen`:`Send answer`}),(0,Z.jsx)(`span`,{"data-slot":d?`ask-resume-hint`:`ask-hint`,className:`text-[11.5px] text-soft-foreground`,children:d?`the session has ended — sending reopens it`:`${i.length>1?`answer each question`:`pick one or more`} — or type a reply below`})]}),n.blockedBy===`provider`?(0,Z.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,Z.jsx)(`span`,{children:n.reason}),(0,Z.jsx)(U,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,n.blockedBy===`no-session`?(0,Z.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:n.reason}):null,n.error?(0,Z.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:n.error}):null]})}function Qr({question:e,disabled:t,selected:n,onSelect:r}){let i=e.multiSelect===!0,a=e=>{if(!i){r([e]);return}r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,Z.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,Z.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),i?(0,Z.jsx)(`span`,{className:`ml-auto text-[10.5px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,Z.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map(e=>{let r=n.includes(e.label);return(0,Z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>a(e.label),className:V(`flex 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] disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06]`:`border-border bg-card`),children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13.5px] font-semibold text-foreground`,children:[i?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:V(`flex size-4 shrink-0 items-center justify-center rounded border text-[10px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})})]})}var $r=2e3;function ei(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 ti(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 ni(e,t){let n=r(),i=(0,X.useMemo)(()=>ei(t),[t]),a=(0,X.useMemo)(()=>ti(t),[t]),o=e?.id,s=e?.status,c=e?.activity;(0,X.useEffect)(()=>{if(!(i!==0&&(s===`running`||s===`waiting`))&&!(a!==0&&s===`running`&&c!==`monitoring`)||o===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:R.runs.detail(o)}),n.invalidateQueries({queryKey:R.runs.list()})},$r);return()=>clearTimeout(e)},[i,a,o,s,c,n])}function ri(){let{id:e}=i(),t=w(e),n=Kt(e),r=t.data?.status,a=(0,X.useMemo)(()=>Ur(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),o=(0,X.useMemo)(()=>Ur(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),s=(0,X.useRef)(void 0),c=(0,X.useCallback)(e=>{s.current=e},[]),{mutate:l}=v();if((0,X.useEffect)(()=>{t.data&&s.current!==t.data.id&&Ie(t.data)&&l(t.data.id)},[l,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),ni(t.data,n.visibleEvents),t.isPending)return(0,Z.jsx)(xt,{});if(t.isError){let e=t.error instanceof ce&&t.error.status===404;return(0,Z.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(se,{icon:e?(0,Z.jsx)(pt,{}):(0,Z.jsx)(Lt,{}),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,Z.jsx)(F,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(U,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Z.jsx)(xt,{}):(0,Z.jsx)(ii,{run:t.data,thread:a,currentThread:o,history:n,onMarkedUnread:c})}function ii({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){dt();let a=r?ye(r.currentEvents)!==void 0:n.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),o=k(e,a),s=Pr(e.status,e.error),c=e.status===`running`||e.status===`waiting`,l=!c&&e.status!==`queued`,d=e.status===`queued`,f=zn(e),p=wr(e),m=a||e.hasPendingHumanAsk===!0,h=!c&&!d&&f.available,_=h&&f.canContinue,[v,y]=(0,X.useState)(void 0),[S,C]=(0,X.useState)(e.id);S!==e.id&&(C(e.id),y(void 0));let w=(0,X.useMemo)(()=>v===void 0?void 0:$n(n.turns,v,l),[n.turns,v,l]),T=(0,X.useMemo)(()=>v===void 0?[]:er(n.turns,v),[n.turns,v]),E=te(e.id),D=Ue(e),O=Re(e),A=c&&!O.usable,j=h&&!f.canContinue,M=A||j,ee=A?O.reason:f.reason,{mutateAsync:N}=g(e.id),{mutateAsync:P}=ie(e.id),{mutateAsync:F}=de(e.id),I=(0,X.useMemo)(()=>d?{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,[d,N,P,F]),L=(0,X.useMemo)(()=>or(e,t),[e,t]),ne=(0,X.useMemo)(()=>cr(L,e.id),[L,e.id]),re=(0,X.useCallback)(t=>(0,Z.jsx)(Xr,{ask:t,run:e}),[e]),ae=(0,X.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]),R=x(e,b()),{search:oe}=ge(),se=dn(oe,ne.length),z=tr(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:ne.map(({key:e})=>e)});return Me(z.restickIfStuck),(0,Z.jsxs)(`div`,{"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(lt,{run:e,hasPendingHumanAsk:a,onMarkedUnread:()=>i?.(e.id)}),(0,Z.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:[r?(0,Z.jsx)(ai,{hasOlder:r.hasOlder,loading:r.isFetchingOlder,error:r.olderError,fallback:r.fallback,retainedPages:r.retainedPages,onLoad:z.loadOlder}):null,(0,Z.jsx)(lr,{runId:e.id,viewId:`main`,sections:L,mode:`document`,renderAsk:re,messageActions:ae,scrollControls:z,renderMode:se}),t.turns.length===0?e.status===`queued`?(0,Z.jsx)(oi,{run:e}):(0,Z.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`&&e.activity!==`monitoring`?(0,Z.jsx)(En,{}):null,s&&s.state===`closed`?(0,Z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":s.state,className:V(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,s.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[s.label,Ce(u(e))?(0,Z.jsx)(`a`,{"data-slot":`pr-link`,href:u(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,Ce(R)?(0,Z.jsx)(`a`,{"data-slot":`issue-link`,href:R,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,Z.jsx)(vr,{run:e}):null]}),(0,Z.jsx)(Cr,{status:e.status}),(0,Z.jsx)(hr,{runId:e.id,renderAsk:re,agent:w,entries:T,onClose:()=>y(void 0)}),(0,Z.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[z.pillVisible?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed right-6 bottom-[calc(24px+env(safe-area-inset-bottom))] z-30 flex justify-center`,children:(0,Z.jsx)(ar,{onJump:z.jumpToLatest})}):null,(0,Z.jsxs)(`div`,{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,Z.jsx)(qr,{run:e,currentThread:n,onOpenWorker:y},e.id),(0,Z.jsx)(qt,{run:e}),e.status===`waiting`?(0,Z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Le,{tone:o.tone,pulse:o.pulse}),o.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${o.label.charAt(0).toUpperCase()}${o.label.slice(1)} — you can send a message to resume`]}):null,d?(0,Z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Le,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,_&&f.startsNewConversation?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,Z.jsx)(vt,{onStop:Be(e).cancel?p.stop:void 0,stopOnEmpty:e.status===`queued`||e.status===`running`||e.status===`waiting`&&o.bucket===`none`&&!m,stopping:p.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:_?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:_?f.pills:void 0,sessionModel:_?f.modelPicker:void 0,onSubmit:_?(e,t)=>f.continueWith(e,t):d?(e,t)=>E.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await D.send(e,t);if(n!==void 0)throw Error(n)},disabled:M||!c&&!d&&!_,disabledReason:M?ee:`Session closed — no session to resume.`,footerEnd:M&&!f.providerPending?(0,Z.jsx)(U,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:_&&!m,emptySubmitLabel:_&&!m?`Continue`:void 0,placeholder:d?`Add to the prompt — sent when the run starts…`:_?`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…`,autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>Nr(t)})]})]}),(0,Z.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function ai({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Z.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,Z.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Z.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,Z.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,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function oi({run:e}){let t=He(P().data??[],e.id);return(0,Z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Z.jsx)(Le,{tone:`pending`,pulse:!0}),(0,Z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{ri as TaskThreadRoute};
@@ -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{Aa as r,At as i,G as a,Gt as o,Pt as s,X as ee,Y as te,_ as c,d as l,f as u,fr as ne,g as re,h as ie,hr as ae,in as oe,l as se,m as ce,p as d,qi as le,qt as ue,sa as f,tn as de,v as p,y as fe}from"./alert-dialog-BOp2HnnL.js";import{_ as pe,b as me,t as m,v as h}from"./utils-GZNjgma4.js";import{a as he,i as ge,r as _e}from"./agent-accounts-BxBsIXGa.js";import{E as ve,F as ye,M as be,j as xe,r as Se}from"./prompt-templates-BGGpAIzb.js";import{u as Ce}from"./project-router-CvFAMDcP.js";import{i as we,n as Te,r as Ee,t as De}from"./skills-DFBiAuJG.js";import{t as Oe}from"./use-submit-shortcut-KWJsC906.js";var g=n(),_=e(t(),1);function v(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function ke(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function y(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||v(e.target)&&!ke(e.target))}function b(e,t){let n=_.useRef(t);_.useLayoutEffect(()=>{n.current=t}),_.useEffect(()=>{let t=t=>{y(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Ae(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||v(e.target))}function x(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function je(e,t){let n=_.useRef(t);_.useLayoutEffect(()=>{n.current=t}),_.useEffect(()=>{let t=t=>{Ae(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Me({...e}){return(0,g.jsx)(u,{"data-slot":`sheet`,...e})}function S({...e}){return(0,g.jsx)(fe,{"data-slot":`sheet-trigger`,...e})}function Ne({...e}){return(0,g.jsx)(d,{"data-slot":`sheet-close`,...e})}function C({...e}){return(0,g.jsx)(c,{"data-slot":`sheet-portal`,...e})}function Pe({className:e,...t}){return(0,g.jsx)(re,{"data-slot":`sheet-overlay`,className:m(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Fe({className:e,children:t,side:n=`right`,showCloseButton:r=!0,overlayClassName:i,...a}){return(0,g.jsxs)(C,{children:[(0,g.jsx)(Pe,{className:i}),(0,g.jsxs)(ce,{"data-slot":`sheet-content`,className:m(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...a,children:[t,r&&(0,g.jsxs)(d,{className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,g.jsx)(de,{className:`size-4`}),(0,g.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function w({className:e,...t}){return(0,g.jsx)(`div`,{"data-slot":`sheet-header`,className:m(`flex flex-col gap-1.5 p-4`,e),...t})}function Ie({className:e,...t}){return(0,g.jsx)(p,{"data-slot":`sheet-title`,className:m(`font-semibold text-foreground`,e),...t})}function T({className:e,...t}){return(0,g.jsx)(ie,{"data-slot":`sheet-description`,className:m(`text-sm text-muted-foreground`,e),...t})}function Le(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Re={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,avif:`image/avif`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,log:`text/plain`,pdf:`application/pdf`};function ze(e){return h(e.type)?e.type:Re[e.name.split(`.`).pop()?.toLowerCase()??``]??null}async function Be(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));let r=btoa(n),i=ze(e)??`application/octet-stream`,a=me(i);return{mediaType:i,data:r,...a?{preview:`data:${i};base64,${r}`}:{},name:e.name||(a?`pasted image`:`pasted.${pe(i)}`),isImage:a}}function Ve(e,t){let n=[],r=[],i=t;for(let t of e){let e=t.name||`attachment`;if(ze(t)===null){r.push(`${e} is not a supported attachment (images, PDF and plain-text files such as TXT or MD)`);continue}if(t.size>5242880){r.push(`${e} is too large (max 5 MB)`);continue}if(i>=4){r.push(`${e} skipped — max 4 attachments per message`);continue}n.push(t),i+=1}return{accepted:n,rejected:r}}var E=new Set([`/`,`@`]);function He(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(E.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function Ue(e,t,n,r){let i=`${t.trigger}${r} `;return{text:e.slice(0,t.start)+i+e.slice(n),caret:t.start+i.length}}function D(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function We(e,t){let n=e,r=``;for(let e=t.resultIndex;e<t.results.length;e+=1){let i=t.results[e],a=i[0]?.transcript??``;i.isFinal?n+=a:r+=a}return{finalText:n,interim:r}}function Ge(e){let[t,n]=_.useState(null),r=_.useRef(null),i=_.useRef(``),[a]=_.useState(()=>D()!==void 0),o=_.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);return _.useEffect(()=>o,[o]),{supported:a,recording:t,start:_.useCallback(()=>{if(r.current)return;let t=D();if(!t)return;let a;try{a=new t,a.lang=navigator.language||`en-US`,a.continuous=!0,a.interimResults=!0;let s=Date.now();a.onresult=e=>{let t=We(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:s})},a.onerror=t=>{e(`Dictation failed${t.error?` — ${t.error}`:``}`),o()},a.start(),r.current=a,n({transcript:``,startedAt:s})}catch{e(`Dictation failed — the microphone could not be started`),o()}},[e,o]),cancel:_.useCallback(()=>o(),[o]),finish:_.useCallback(()=>{let e=r.current,a=(i.current+``).trim()===``?``:i.current,o=t?.transcript??a;return e&&(e.onresult=null,e.onerror=null,e.onend=null,e.stop()),r.current=null,i.current=``,n(null),o.trim()},[t])}}function O(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}var Ke=new Map,qe={KeyA:`Yes, approved.`,KeyC:`Continue.`};function k({onSubmit:e,retainDraftUntilSuccess:t=!1,onStop:n,stopOnEmpty:te=!1,stopping:c=!1,emptySubmitLabel:u,compactFeedback:re=!1,idleFeedback:ie,pendingLabel:se=`Starting task…`,failureHint:ce=`Could not confirm submission. Check Tasks before you retry. Your draft is kept.`,clearOnSuccess:d=!0,onPendingChange:p,value:fe,onValueChange:pe,autoFocus:me=!1,mobileCollapsible:h=!1,mobileDisclosureKey:Ce,footerStart:ke,footerEnd:y,sessionControls:b,sessionModel:Ae,executionOptions:x,agentOptions:je,sendAriaLabel:Me=`Send`,disabled:S=!1,disabledReason:Ne=`Session closed — Continue to reopen.`,allowEmptySubmit:C=!1,placeholder:Pe=`Reply — / for skills, @ for files…`,ariaLabel:Fe=`Reply to the agent`,autocompleteSkills:w=!0,quickReplies:Ie=!1,getMentionCandidates:T,ref:Le}){let[Re,ze]=(0,_.useState)(``),E=fe??Re,D=(0,_.useRef)(E);D.current=E;let We=(0,_.useRef)(pe);We.current=pe;let O=(0,_.useCallback)(e=>{let t=typeof e==`function`?e(D.current):e;ze(t),We.current?.(t)},[]),[k,A]=(0,_.useState)([]),j=(0,_.useRef)(k);j.current=k;let[Xe,Ze]=(0,_.useState)(!1),M=c||Xe,N=(0,_.useRef)(M);N.current=M;let P=E.trim()!==``||k.length>0,Qe=!P&&(n!==void 0&&te||M),$e=!P&&u?u:Me,[F,I]=(0,_.useState)(!1),L=(0,_.useRef)(!1),et=(0,_.useRef)(0),R=(0,_.useRef)(!0);(0,_.useEffect)(()=>(R.current=!0,()=>{R.current=!1}),[]);let[z,B]=(0,_.useState)(null),V=M||t&&F,H=()=>N.current||t&&L.current,[U,W]=(0,_.useState)(null),[tt,nt]=(0,_.useState)(``),[rt,it]=(0,_.useState)(!1),G=(0,_.useRef)(null),K=(0,_.useId)(),at=(0,_.useId)(),ot=(0,_.useRef)(new Map),st=Ce===void 0?ot.current:Ke,ct=Ce??`default`,[,lt]=(0,_.useReducer)(e=>e+1,0),q=st.get(ct)??!1,ut=h&&!q,dt=(0,_.useRef)(null),J=(0,_.useRef)(null),ft=ne(w&&rt),Y=ae(),pt=r(),X=Ge(e=>f(e,{tone:`danger`}));(0,_.useEffect)(()=>{me&&G.current?.focus()},[]),(0,_.useImperativeHandle)(Le,()=>({insertAtCaret:e=>{if(H())return;let t=G.current,n=Se(D.current,t?.selectionStart??D.current.length,e);O(n.text),J.current=n.caret,t?.focus()}}),[O,t]);let mt=(0,_.useCallback)(()=>{let e=G.current;if(!e||S||H()){W(null);return}let t=He(e.value,e.selectionStart??e.value.length);if(t?.trigger===`/`&&!w||t?.trigger===`@`&&T===void 0)return W(null);t?.trigger===`/`&&it(!0),W(t)},[w,S,T,t]),Z=(0,_.useMemo)(()=>U===null?[]:U.trigger===`/`?Te(ft.data??[],U.query,Y.data?.skillUsage).map(e=>({value:`${e.name} ${e.path}`,insert:e.name,label:e.name,description:e.description,emphasized:we(e)})):(T?.()??[]).filter(e=>Ee(e,U.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1})),[T,ft.data,U,Y.data?.skillUsage]),ht=Z.some(e=>e.value===tt)?tt:Z[0]?.value,gt=U!==null,_t=(0,_.useCallback)(()=>W(null),[]),vt=e=>{let t=G.current;if(!t||U===null||H())return;let n=t.selectionStart??t.value.length,r=Ue(t.value,U,n,e.insert);U.trigger===`/`&&Y.data!==void 0&&le({skillUsage:De(Y.data.skillUsage,e.insert)}).then(()=>pt.invalidateQueries({queryKey:oe.uiState})).catch(()=>{}),O(r.text),J.current=r.caret,W(null),t.focus()};(0,_.useLayoutEffect)(()=>{let e=J.current,t=G.current;e!==null&&t&&(t.setSelectionRange(e,e),J.current=null)},[E]),(0,_.useLayoutEffect)(()=>{let e=G.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)},[E,q]);let yt=(0,_.useCallback)(e=>{if(S||H())return;let n=et.current,r=Ve(e,j.current.length);for(let e of r.rejected)f(e,{tone:`danger`});for(let e of r.accepted)Be(e).then(e=>{!R.current||t&&L.current&&!N.current||n!==et.current||A(t=>t.length>=4?t:[...t,e])},()=>f(`${e.name||`Attachment`} could not be read — try attaching it again`,{tone:`danger`}))},[S,t]),bt=e=>{let t=[...e.clipboardData?.items??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),yt(t))},xt=e=>{let t=[...e.dataTransfer?.files??[]];t.length!==0&&(e.preventDefault(),yt(t))},Q=(0,_.useCallback)(async(n,r,i)=>{let a=n.trim();if(!(S||c||L.current)&&!(a===``&&r.length===0&&!C)){L.current=!0,t&&(et.current+=1),I(!0),B(null),p?.(!0),W(null),i&&!t&&(O(``),A([]));try{await e(a,r.map(({mediaType:e,data:t})=>({mediaType:e,data:t}))),R.current&&t&&d&&(D.current===n&&O(``),j.current===r&&A([]))}catch(e){if(!R.current&&t)return;let a=e instanceof Error?e.message:String(e);t?B(a):(f(a,{tone:`danger`}),i&&(O(e=>e===``?n:`${n}\n${e}`),A(e=>[...r,...e].slice(0,4))))}finally{L.current=!1,R.current&&(p?.(!1),I(!1))}}},[C,S,c,e,t,d,p,O]),St=(0,_.useCallback)(()=>{S||c||L.current||Q(D.current,j.current,!0)},[S,c,Q]),Ct=async()=>{if(!(!n||c||L.current)){L.current=!0,I(!0),Ze(!0),B(null);try{await n()}catch(e){R.current&&B(e instanceof Error?e.message:String(e))}finally{L.current=!1,R.current&&(I(!1),Ze(!1))}}},wt=e=>{if(gt){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),Z.length===0)return;let t=Z.findIndex(e=>e.value===ht),n=e.key===`ArrowDown`?1:-1,r=Z[(t+n+Z.length)%Z.length];nt(r.value);return}if(e.key===`Escape`){e.preventDefault(),_t();return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=Z.find(e=>e.value===ht);if(t){e.preventDefault(),vt(t);return}_t()}}Oe({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),St())};(0,_.useEffect)(()=>{if(!Ie||S)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||v(e.target))return;let t=qe[e.code];t!==void 0&&(e.preventDefault(),Q(t,[],!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,Ie,Q]);let Tt=e=>{if(S||N.current||L.current&&(e||t))return;let n=X.finish();if(n===``)return;let r=E.trim()===``?n:`${E.replace(/\s*$/,``)} ${n}`;if(e){t&&O(r),Q(r,k,!0);return}O(r),J.current=r.length,G.current?.focus()},$=X.recording,Et=X.supported?(0,g.jsxs)(l,{type:`button`,variant:`ghost`,size:`sm`,disabled:S||V,"aria-label":`Start dictation`,title:`Dictation`,className:m(`h-11 gap-1.5 px-2.5 text-xs font-medium text-muted-foreground md:h-8`,ut&&`hidden md:inline-flex`),onClick:()=>{H()||X.start()},children:[(0,g.jsx)(i,{"aria-hidden":`true`,className:`size-3.5`}),x||b?null:`Dictation`]}):null,Dt=n||M?(0,g.jsxs)(l,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":M?`Stopping…`:`Stop`,"aria-busy":M||void 0,title:M?`Waiting for execution to stop`:`Stop execution; keep existing work`,disabled:F||M,className:m(`h-11 min-w-11 active:opacity-80`,Qe?`w-auto px-3`:`w-11`),onClick:()=>void Ct(),children:[(0,g.jsx)(o,{"aria-hidden":`true`,className:`size-3 fill-current`}),Qe?M?`Stopping…`:`Stop`:null]}):null,Ot=(0,g.jsx)(g.Fragment,{children:t||n||c?(0,g.jsx)(`div`,{className:m(`overflow-y-auto px-3 pb-2 text-xs leading-5 text-muted-foreground md:px-4`,re?`min-h-6`:`h-24 md:h-20`),children:(0,g.jsx)(`div`,{id:`${K}-submission`,role:z===null?`status`:`alert`,"aria-atomic":`true`,tabIndex:z===null?void 0:0,className:`break-words`,children:M?`Stopping execution. Your draft is kept.`:F?se:z===null?ie??null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{className:`font-medium text-foreground`,children:z}),(0,g.jsx)(`p`,{children:ce})]})})}):null}),kt=(0,g.jsxs)(`div`,{"data-slot":`composer-submit-row`,className:m(`ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1 md:flex-nowrap`,x&&`new-task-submission`),children:[x||b?null:Et,y?(0,g.jsx)(`div`,{id:at,"data-slot":`composer-footer-end`,className:m(`min-w-0 flex-wrap items-center gap-1.5 md:flex-nowrap`,x&&`mr-auto`,h&&`max-md:[&_button]:min-h-11 max-md:[&_button]:min-w-11`,ut?`hidden md:flex`:`flex`),children:(0,g.jsx)(`div`,{className:`contents`,inert:V||void 0,children:y})}):null,(0,g.jsxs)(`div`,{className:`flex min-w-[100px] items-center justify-end gap-1`,"data-slot":`composer-actions`,children:[Dt,Qe?null:(0,g.jsxs)(l,{type:`button`,size:`icon-sm`,"aria-label":$e,"aria-busy":F&&!M||void 0,disabled:S||F||M||!P&&!C,className:m(x?`h-12 w-full gap-2 px-6`:b?`h-11 w-auto gap-2 px-5`:`size-11`,!P&&u&&`w-auto px-3`,`active:opacity-80`),onClick:St,children:[!b&&!P&&u?(0,g.jsx)(ye,{"aria-hidden":`true`}):null,x||b||!P&&u?$e:null,b||P||!u?(0,g.jsx)(a,{"aria-hidden":`true`}):null]})]})]});return(0,g.jsxs)(_e,{open:gt,onOpenChange:e=>e?void 0:_t(),children:[(0,g.jsx)(ge,{asChild:!0,children:(0,g.jsxs)(`div`,{ref:dt,"data-slot":`composer`,"data-disabled":S||void 0,onDrop:xt,onDragOver:e=>e.preventDefault(),className:m(x&&`new-task-composer`,b&&`session-composer`,S&&`opacity-80`),children:[(0,g.jsxs)(`div`,{"data-slot":`composer-editor`,className:m(`rounded-xl border border-[var(--composer-border)] bg-card shadow-none transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,x&&`new-task-editor`),children:[k.length>0?(0,g.jsx)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-nowrap items-center gap-2 overflow-x-auto px-4 pt-3 md:flex-wrap md:overflow-visible`,children:k.map((e,t)=>(0,g.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:V?`Attachment submitted`:`Click to remove`,disabled:V,className:m(`group relative shrink-0 overflow-hidden rounded-md border border-border`,e.isImage?`size-12`:`flex h-12 min-w-11 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`),onClick:()=>{H()||A(e=>e.filter((e,n)=>n!==t))},children:[e.isImage?(0,g.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,g.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,g.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,g.jsx)(de,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${t}`))}):null,(0,g.jsx)(`label`,{htmlFor:K,className:x?`hidden px-5 pt-5 text-xs text-muted-foreground md:block`:`sr-only`,children:x?`Task description`:Fe}),(0,g.jsx)(`textarea`,{ref:G,id:K,autoComplete:`off`,rows:1,value:E,disabled:S,readOnly:V,"aria-busy":V||void 0,"aria-describedby":t?`${K}-submission`:void 0,"aria-label":Fe,placeholder:S?Ne:Pe,className:m(`block min-h-11 w-full resize-none bg-transparent px-3 pt-2.5 pb-1 text-base leading-normal outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pt-3 md:text-sm`,ut?`max-h-11 md:max-h-[220px]`:`max-h-[220px]`),onChange:e=>{H()||(O(e.target.value),mt())},onKeyDown:wt,onSelect:mt,onPaste:bt}),x?(0,g.jsxs)(`p`,{"data-slot":`composer-skill-hint`,className:`flex items-center gap-2 px-5 pt-3 pb-2 text-xs text-muted-foreground`,children:[(0,g.jsx)(ue,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),`Type / for a skill or workflow`]}):null,b&&$?(0,g.jsx)(`div`,{"data-slot":`session-controls`,inert:V||void 0,children:b}):null,$?(0,g.jsxs)(`div`,{children:[(0,g.jsx)(Ye,{transcript:$.transcript,startedAt:$.startedAt,insertionDisabled:V,onCancel:X.cancel,onInsert:()=>Tt(!1),onInsertAndSend:()=>Tt(!0)}),Dt?(0,g.jsx)(`div`,{className:`flex justify-end px-2 pb-2`,children:Dt}):null]}):(0,g.jsxs)(`div`,{"data-slot":`composer-toolbar`,className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pt-1 pb-1.5 md:gap-y-1.5 md:px-2 md:pt-1.5 md:pb-2`,children:[b?(0,g.jsx)(`div`,{"data-slot":`session-controls`,inert:V||void 0,children:b}):null,(0,g.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:m(`flex min-w-0 flex-wrap items-center gap-1`,x&&`w-full`),children:[(0,g.jsx)(Je,{disabled:S||V,onFiles:yt}),h?(0,g.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`size-11 md:hidden`,"aria-label":q?`Collapse composer`:`Expand composer`,"aria-expanded":q,"aria-controls":y?`${K} ${at}`:K,onClick:()=>{st.set(ct,!q),lt()},children:(0,g.jsx)(ee,{"aria-hidden":`true`,className:m(`transition-transform motion-reduce:transition-none`,!q&&`rotate-180`)})}):null,(0,g.jsx)(`div`,{className:`contents`,inert:V||void 0,children:ke}),x||b?(0,g.jsx)(`div`,{children:Et}):null]}),Ae?(0,g.jsx)(`div`,{"data-slot":`session-model`,inert:V||void 0,children:Ae}):null,x?null:kt]}),x?null:Ot]}),x?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{"data-slot":`composer-agent-options`,inert:V||void 0,children:je}),(0,g.jsx)(`div`,{"data-slot":`composer-execution-panel`,inert:V||void 0,children:x}),kt,(0,g.jsx)(`div`,{"data-slot":`composer-feedback`,children:Ot})]}):null]})}),(0,g.jsx)(he,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{dt.current?.contains(e.target)&&e.preventDefault()},children:(0,g.jsx)(ve,{shouldFilter:!1,value:ht??``,onValueChange:nt,children:(0,g.jsx)(be,{"data-slot":`composer-menu`,"data-trigger":U?.trigger,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:Z.length===0?(0,g.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:U?.trigger===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:ft.isPending?`Loading skills…`:`No matching skills.`}):Z.map(e=>(0,g.jsxs)(xe,{value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>vt(e),children:[(0,g.jsx)(`span`,{className:m(`shrink-0 truncate`,e.emphasized&&`font-semibold`,U?.trigger===`@`&&`font-mono text-xs`),children:e.label}),e.description?(0,g.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})})]})}function Je({disabled:e,onFiles:t}){let n=(0,_.useRef)(null);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:`size-11 text-muted-foreground`,onClick:()=>n.current?.click(),children:(0,g.jsx)(s,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,g.jsx)(`input`,{ref:n,type:`file`,accept:`image/*,application/pdf,text/plain,text/markdown,.pdf,.txt,.md,.markdown,.log`,multiple:!0,className:`hidden`,"aria-hidden":`true`,tabIndex:-1,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}function Ye({transcript:e,startedAt:t,insertionDisabled:n,onCancel:r,onInsert:i,onInsertAndSend:o}){let s=Le(1e3);return(0,g.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-t border-border bg-muted/60 px-3 py-2`,children:[(0,g.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,g.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:O(t,s)}),(0,g.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e===``?(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e}),(0,g.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`size-11 text-muted-foreground md:size-8`,onClick:r,children:(0,g.jsx)(de,{"aria-hidden":`true`})}),(0,g.jsx)(l,{type:`button`,variant:`outline`,size:`icon-sm`,disabled:n,"aria-label":`Insert transcription`,className:`size-11 md:size-8`,onClick:i,children:(0,g.jsx)(te,{"aria-hidden":`true`})}),(0,g.jsx)(l,{type:`button`,size:`icon-sm`,disabled:n,"aria-label":`Insert transcription and send`,className:`size-11 md:size-8`,onClick:o,children:(0,g.jsx)(a,{"aria-hidden":`true`})})]})}function A(){return(0,g.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,g.jsx)(se,{icon:(0,g.jsx)(Ce,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}export{Ne as a,w as c,x as d,b as f,Me as i,Ie as l,k as n,Fe as o,je as p,Le as r,T as s,A as t,S as u};