@hearsay-tools/squawk 0.17.0-dev.5736 → 0.17.0-dev.5739
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/discovery.d.ts +1 -32
- package/dist/contract/health.d.ts +2 -17
- package/dist/contract/index.js +2573 -2565
- package/dist/contract/repo-info.d.ts +12 -0
- package/dist/contract/repo.d.ts +1 -2
- package/dist/contract/runner.d.ts +15 -0
- package/dist/contract/usage-limit-hold.d.ts +15 -0
- package/dist/contract/waits.d.ts +2 -11
- package/dist/contract/workflows.d.ts +1 -1
- package/dist/contract/workspace.d.ts +36 -1
- package/dist/delegation/routes.d.ts +66 -66
- package/dist/delegation/transport.d.ts +71 -71
- package/dist/runs/run-exits.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/server.d.ts +1571 -1571
- package/dist/voice/routes.d.ts +19 -19
- package/dist/workflows/run/wait-engine.d.ts +72 -72
- package/package.json +4 -4
- package/web/dist/assets/activity-motion-Deqj_hcK.js +2 -0
- package/web/dist/assets/{activity-route-De0BnSrc.js → activity-route-Z8SMpPLm.js} +1 -1
- package/web/dist/assets/{agent-accounts-BCg-578Q.js → agent-accounts-f1cxwgfz.js} +2 -2
- package/web/dist/assets/{cez-idle-BT0U4GN_.js → cez-idle-EVoUsgU3.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-DYtYc_dH.js → commit-diff-panel-DZutYRbq.js} +1 -1
- package/web/dist/assets/{control-locations-CA9TMupq.js → control-locations-C9II3kPz.js} +1 -1
- package/web/dist/assets/{diff-tVGVhYyc.js → diff-DNAtaTLC.js} +2 -2
- package/web/dist/assets/{diff-view-CNM3u77o.js → diff-view---8Bt-0a.js} +1 -1
- package/web/dist/assets/{file-preview-C1eTdJLJ.js → file-preview-D08Kq15E.js} +1 -1
- package/web/dist/assets/{git-toolbar-Dwz8p8GW.js → git-toolbar-DMDmGits.js} +1 -1
- package/web/dist/assets/{github-BSezqH6f.js → github-DlMu4p0I.js} +1 -1
- package/web/dist/assets/{github-sidebar-model-Ct0DltOv.js → github-sidebar-model-B0Ufci5S.js} +1 -1
- package/web/dist/assets/{global-activity-route-BZiYz-B0.js → global-activity-route-mJrrP9I0.js} +1 -1
- package/web/dist/assets/{index-D489J7QW.js → index-FoxgrgAH.js} +8 -8
- package/web/dist/assets/{live-protocol-BDY7JJpT.js → live-protocol-BVn0UA_g.js} +1 -1
- package/web/dist/assets/{live-refetch-C0kQc3-z.js → live-refetch-BdnmTJ_8.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-DGkEs_L3.js → preview-pane-connected-KzJn9jAG.js} +1 -1
- package/web/dist/assets/{project-router-1m_VlC22.js → project-router-MMOk9VbW.js} +1 -1
- package/web/dist/assets/project-scope-context-B3M-u8R0.js +4 -0
- package/web/dist/assets/{queries-DYfIpJ-d.js → queries-DORTKwyN.js} +1 -1
- package/web/dist/assets/{repo-git-CU1S5P-y.js → repo-git-Bf_EfIHt.js} +1 -1
- package/web/dist/assets/{report-reader-DlZol2Ux.js → report-reader-ztLhC9gp.js} +1 -1
- package/web/dist/assets/reports-BxGqf1aC.js +1 -0
- package/web/dist/assets/{run-header-DPjiPKRe.js → run-header-CDMGqoPE.js} +1 -1
- package/web/dist/assets/skills-D2r8n5IP.js +1 -0
- package/web/dist/assets/{tab-link-DCUifQ46.js → tab-link-BvoGfK8S.js} +1 -1
- package/web/dist/assets/{task-changes-BZXWvQN3.js → task-changes-CfUCDwcL.js} +1 -1
- package/web/dist/assets/{task-commits-ByI9MSfc.js → task-commits-IOjoz_mL.js} +1 -1
- package/web/dist/assets/{task-files-LJbenpiH.js → task-files-CpUYhIpd.js} +1 -1
- package/web/dist/assets/{task-github-item-B0CU9lGR.js → task-github-item-B8YPhQDV.js} +1 -1
- package/web/dist/assets/task-thread-2Kme3Fc0.js +9 -0
- package/web/dist/assets/{thread-state-BLaCzqeX.js → thread-state-C136Em0C.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BkmKad8x.js → use-hand-to-agent-state-C6u70P2A.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-qEY8OhKb.js → useInfiniteQuery-BbYMWe23.js} +1 -1
- package/web/dist/assets/useQuery-CqqnAJvu.js +1 -0
- package/web/dist/assets/{workflows-Dbxb-d-6.js → workflows-CWrdqLII.js} +1 -1
- package/web/dist/assets/{ws-DvGmrP4z.js → ws-BtSVmivO.js} +1 -1
- package/web/dist/index.html +13 -13
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/activity-motion-hhx0e841.js +0 -2
- package/web/dist/assets/project-scope-context-CaUqlAd7.js +0 -4
- package/web/dist/assets/reports-DIGGjk7C.js +0 -1
- package/web/dist/assets/skills-BMwanop_.js +0 -1
- package/web/dist/assets/task-thread-CXCN__1a.js +0 -9
- package/web/dist/assets/useQuery-DOJQOEBO.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-CHUAMTHK.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{P as l,c as u,i as d}from"./project-scope-context-CaUqlAd7.js";import{C as f,f as p,gt as m,u as h,xt as g}from"./queries-DYfIpJ-d.js";import{C as _,E as v,Q as y,ct as b,d as x}from"./design-icons-DmYTv2r1.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as C,t as w}from"./run-header-DPjiPKRe.js";import{a as T,i as E,n as D,r as O}from"./file-preview-C1eTdJLJ.js";import{t as k}from"./centered-state-DGyy0SuA.js";import{r as A}from"./markdown-D7DUNWcJ.js";import{Ct as j,St as M,rn as N}from"./index-D489J7QW.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=h(e,r),s=r?o:i,c=(0,I.useContext)(A),d=t(),p=d.pathname.replace(/\/files\/?$/,`/report`)+d.search,m=s.data,g=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(A.Provider,{value:g,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?u(e,_.id,`image`):l(e,n),..._?{downloadUrl:u(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=g(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=m(e),n=H();return t.isPending?(0,L.jsx)(j,{tab:`files`}):t.isError?(0,L.jsx)(M,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=h(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=g(e.id,``),r=p(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[u,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let m=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},h=t.isError&&t.error instanceof d&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),u.trim()&&m(`path`,u.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(N,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:u,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!u.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(k,{icon:h?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>m(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>m(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-CHUAMTHK.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{P as l,c as u,i as d}from"./project-scope-context-B3M-u8R0.js";import{C as f,f as p,gt as m,u as h,xt as g}from"./queries-DORTKwyN.js";import{C as _,E as v,Q as y,ct as b,d as x}from"./design-icons-DmYTv2r1.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as C,t as w}from"./run-header-CDMGqoPE.js";import{a as T,i as E,n as D,r as O}from"./file-preview-D08Kq15E.js";import{t as k}from"./centered-state-DGyy0SuA.js";import{r as A}from"./markdown-D7DUNWcJ.js";import{Ct as j,St as M,rn as N}from"./index-FoxgrgAH.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=h(e,r),s=r?o:i,c=(0,I.useContext)(A),d=t(),p=d.pathname.replace(/\/files\/?$/,`/report`)+d.search,m=s.data,g=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(A.Provider,{value:g,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?u(e,_.id,`image`):l(e,n),..._?{downloadUrl:u(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=g(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=m(e),n=H();return t.isPending?(0,L.jsx)(j,{tab:`files`}):t.isError?(0,L.jsx)(M,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=h(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=g(e.id,``),r=p(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[u,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let m=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},h=t.isError&&t.error instanceof d&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),u.trim()&&m(`path`,u.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(N,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:u,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!u.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(k,{icon:h?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>m(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>m(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e,d as t,t as n}from"./button-CHUAMTHK.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{Jr as i,tt as a}from"./project-scope-context-
|
|
1
|
+
import{E as e,d as t,t as n}from"./button-CHUAMTHK.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{Jr as i,tt as a}from"./project-scope-context-B3M-u8R0.js";import{$ as o,E as s,J as c,P as l,Un as u,an as d,cn as f,gt as p,k as m,n as h}from"./queries-DORTKwyN.js";import{s as g}from"./popover-DRcRI46x.js";import{I as _,ct as v,m as y}from"./design-icons-DmYTv2r1.js";import{t as b}from"./run-header-CDMGqoPE.js";import{u as x}from"./control-locations-C9II3kPz.js";import{t as S}from"./project-router-MMOk9VbW.js";import{t as C}from"./centered-state-DGyy0SuA.js";import{St as w,Wt as T,xt as E}from"./index-FoxgrgAH.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-C6u70P2A.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=p(n);return r.isPending?(0,A.jsx)(E,{kind:t}):r.isError?(0,A.jsx)(w,{tab:`github-item`,error:r.error}):(0,A.jsx)(N,{run:r.data,kind:t})}function N({run:t,kind:r}){let{n:i}=e(),a=Number(i),s=c(),u=o(),f=l(),p=u.isPending||f.isPending,h=d(t,s).some(e=>e.kind===r&&e.number===a),g=m(r,a,h);return(0,A.jsxs)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:[(0,A.jsx)(b,{run:t,tab:{kind:r,number:a}}),h?(0,A.jsx)(V,{run:t,kind:r,number:a,repoBase:s,item:g}):p?(0,A.jsx)(E,{kind:r,number:a,heading:`h2`}):(0,A.jsx)(C,{icon:(0,A.jsx)(T,{size:16}),tone:`neutral`,heading:`h2`,title:`#${i} is not linked to this task`,subtitle:`Only the issues and pull requests this task references open here.`,actions:(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsx)(S,{to:`/tasks/${t.id}`,children:`Back to the session`})})})]})}function P(e,t){return e===`pr`&&t.data?.available===!0&&t.data.item!==null}function F(e,t,n,r){return e===`pr`?n?.[t]??r:r}function I({retry:e,kind:t,number:r}){return(0,A.jsx)(n,{variant:`outline`,disabled:e.isPending,onClick:()=>e.mutate(h.githubItem(t,r)),children:`Retry`})}function L({kind:e,number:t,error:n,retryButton:r}){return(0,A.jsx)(C,{icon:(0,A.jsx)(v,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load ${j[e].toLowerCase()} #${t}`,subtitle:n.message,actions:r})}function R({run:e,kind:r,number:i,repoBase:a,reason:o,retryError:s,retryButton:c}){let l=r===`pr`?_:y,u=f(e,a).find(e=>e.kind===`PR`==(r===`pr`)&&e.number===i)?.url;return(0,A.jsx)(C,{icon:(0,A.jsx)(l,{size:16}),tone:`neutral`,heading:`h2`,title:`GitHub is unavailable`,subtitle:s?.message??o,actions:(0,A.jsxs)(A.Fragment,{children:[c,u&&t(u)?(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,children:[`open on GitHub`,(0,A.jsx)(g,{"aria-hidden":`true`})]})}):null]})})}function z({label:e,repoBase:t}){return(0,A.jsx)(C,{icon:(0,A.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`${e} was not found in ${H(t)}`,subtitle:`It may have been deleted, or the number points at a different repository.`})}function B({kind:e,item:t,labelColors:n,checks:r}){return(0,A.jsx)(`div`,{className:`min-w-0 px-0.5 md:px-2`,children:(0,A.jsx)(O,{item:t,colors:n??{},checks:r,backLink:null,subNav:null,children:e===`issue`?(0,A.jsx)(U,{item:t},t.url):null})})}function V({run:e,kind:t,number:n,repoBase:r,item:o}){let c=i(),l=u({mutationFn:e=>a(t,n,{refresh:!0}),onSuccess:(e,t)=>c.setQueryData(t,e)}),d=P(t,o),f=s(d?[n]:[],d),p=f.data?.available?f.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:l,kind:t,number:n});if(o.isPending)return(0,A.jsx)(E,{kind:t,number:n,heading:`h2`});if(o.isError)return(0,A.jsx)(L,{kind:t,number:n,error:l.error??o.error,retryButton:h});let g=o.data;return g.available?g.item?(0,A.jsx)(B,{kind:t,item:g.item,labelColors:g.labelColors,checks:F(t,n,p,g.item.checks)}):(0,A.jsx)(z,{label:m,repoBase:r}):(0,A.jsx)(R,{run:e,kind:t,number:n,repoBase:r,reason:g.reason,retryError:l.error,retryButton:h})}function H(e){if(!e)return`this repository`;try{return new URL(e).pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`)||`this repository`}catch{return`this repository`}}function U({item:e}){let t=k();return(0,A.jsx)(D,{item:e,workflows:t.workflows.data?.workflows??[],skills:t.skillList,workflow:t.workflow,onWorkflowChange:t.setWorkflow,selectedSkills:t.selectedSkills,onSkillsChange:t.setSelectedSkills,engine:t.engine,onEngineChange:t.setEngine,queuedRunId:t.queued.get(e.url)??null,onQueued:t.onQueued},e.url)}export{M as TaskGithubItemRoute};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,L as i,N as a,d as o,p as s,t as c,u as l,w as u}from"./button-CHUAMTHK.js";import{i as d,r as f,t as p}from"./react-runtime-CCIEwYL0.js";import{r as m}from"./live-refetch-BdnmTJ_8.js";import{D as h,F as g,Hn as _,Jr as v,T as y,Un as b,Wn as x,ar as S,cr as C,f as w,i as T,ir as E,pr as D,rr as ee,sr as O,u as k,ur as A,v as te,wr as ne}from"./project-scope-context-B3M-u8R0.js";import{$t as j,At as M,Bn as N,Cn as P,Ct as F,Et as I,Hn as L,In as R,J as z,Jt as re,Nn as B,P as ie,Pn as ae,R as oe,S as se,Tt as V,U as ce,Un as H,bt as le,c as ue,d as de,et as fe,gt as pe,h as me,n as U,on as he,rn as ge,un as W,ut as _e,x as ve,xn as ye}from"./queries-DORTKwyN.js";import{n as G}from"./toaster-B1MyeHiE.js";import{a as be,s as xe}from"./popover-DRcRI46x.js";import{A as Se,B as Ce,I as we,J as Te,Q as Ee,V as De,_ as Oe,b as ke,c as Ae,ct as je,d as K,ft as Me,g as Ne,h as Pe,j as Fe,l as Ie,n as Le,o as Re,ot as ze,p as Be,pt as Ve,st as He,u as Ue,y as We}from"./design-icons-DmYTv2r1.js";import{t as Ge}from"./textarea-DlVUfdWG.js";import{t as Ke}from"./loader-circle-CZkGEdoI.js";import{t as q}from"./createLucideIcon-BHp8sXmF.js";import{a as qe,c as Je,i as Ye,l as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./run-header-CDMGqoPE.js";import{t as nt}from"./eye-B8okNWXU.js";import{t as rt}from"./message-square-B-MD-8rD.js";import{a as it,i as at,n as ot,o as st,r as ct,t as lt}from"./thread-state-C136Em0C.js";import{a as ut,n as dt,s as ft,u as pt}from"./control-locations-C9II3kPz.js";import{s as mt,t as J}from"./project-router-MMOk9VbW.js";import{n as ht,t as gt}from"./centered-state-DGyy0SuA.js";import{_ as _t,a as vt,f as yt,g as bt,i as xt,m as St,n as Ct,p as wt,r as Tt,t as Et,v as Dt}from"./agent-accounts-f1cxwgfz.js";import{i as Ot,m as kt,p as At,r as jt,s as Mt,t as Nt}from"./markdown-D7DUNWcJ.js";import{$ as Y,At as Pt,B as Ft,C as It,E as Lt,F as Rt,G as zt,Gt as Bt,H as Vt,I as Ht,Lt as Ut,M as Wt,Mt as Gt,N as Kt,Q as X,S as qt,T as Jt,U as Yt,V as Xt,X as Zt,Xt as Qt,Z,b as $t,bt as en,ct as tn,jt as nn,ot as rn,pt as an,q as on,qt as sn,v as cn,vt as ln,w as un,x as dn,y as fn,z as pn,zt as mn}from"./index-FoxgrgAH.js";import{t as hn}from"./zoomable-image-5pOUaPEg.js";import{t as gn}from"./report-title-D4Mbu2Er.js";var _n=q(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),vn=q(`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`}]]),yn=q(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),bn=q(`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`}]]),xn=q(`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`}]]),Sn=q(`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`}]]),Cn=q(`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`}]]),Q=e(d(),1),$=p();function wn({run:e}){let t=v(),n=H({mutationFn:()=>k(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:U.runs.detail(e.id)}),t.invalidateQueries({queryKey:U.runs.list()}),G(`This task will not resume itself`)},onError:e=>G(e.message,{tone:`danger`})});if(!C(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,$.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,$.jsx)(rn,{tone:`neutral`,shape:`ring`}),(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.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,$.jsx)(s,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Tn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var En=/^[A-Za-z0-9_./:=+,@%-]+$/;function Dn(e){return e.replaceAll(`'`,`'\\''`)}function On(e){return e===``?`''`:En.test(e)?e:`\u0027${Dn(e)}\u0027`}function kn(e){if(!Tn(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(On).join(` `)}}function An(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function jn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Mn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Nn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Pn(e){let t=An(jn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Nn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Nn(e[2])&&i.push({label:Mn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Mn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Nn(t)&&i.push({label:t,href:t})}return i}var Fn=(0,Q.createContext)(void 0),In=(0,Q.createContext)(void 0);function Ln(e,t){let n=new Map;for(let r of Pn(e)){let e=Ot(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function Rn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function zn({text:e,messageKey:t}){let n=(0,Q.useContext)(jt),r=(0,Q.useContext)(In),i=t??r;if(!n||i===void 0)return null;let a=Ln(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(Bn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Bn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:o}=e,c=(0,Q.useContext)(Fn),l=(0,Q.useContext)(ln);(0,Q.useLayoutEffect)(()=>l?.register(r,i),[l,r,i]);let d=de(i,r),f=t(),p=u();if(d.isError)return(0,$.jsx)(s,{id:Rn(n,r),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!Mt(m.name))return null;let h=new URLSearchParams(f.search);h.set(`report`,r),h.set(`card`,n);let g=new URLSearchParams(f.search).has(`report`)?f.state:null,_=new URLSearchParams(f.search);_.delete(`report`),_.delete(`card`);let v=`${f.pathname}${_.size?`?${_}`:``}`,y=window.navigation,b={reportCardEntry:!0,reportReturnTo:g?.reportReturnTo??v,reportReturnKey:g?.reportReturnKey??y?.currentEntry?.key,reportScrollTop:g?.reportScrollTop},x={pathname:f.pathname,search:`?${h}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,$.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":r,"data-report-run-id":i,"aria-busy":d.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:m?gn(m):a}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(s,{id:Rn(n,r),to:x,state:b,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),c?.(n);let t=b.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;p(x,{state:{...b,reportScrollTop:t}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${d.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Vn={message:!0,reasoning:!0,tool:!0,hook:!0};function Hn(e){return Object.hasOwn(Vn,e)&&Vn[e]}var Un=e=>e.kind===`tool`,Wn=e=>e.kind===`conversation`,Gn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Kn=(e,t,n)=>`${e} ${e===1?t:n}`;function qn(e,t){let n=[];return e>0&&n.push(Kn(e,`file`,`files`)),t>0&&n.push(Kn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Jn(e){return`${e} earlier tool call${e===1?``:`s`}`}var Yn=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Xn(e){for(let t of Yn)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 Zn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Un).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Hn(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:qn(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of Qn(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Wn(e)){s(),c.push(e);continue}l(),Un(e)&&Gn(e)&&!r.has(e.id)?o.push(e):(s(),Un(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function Qn(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var $n=new Map,er=(0,Q.createContext)(null);function tr(){return(0,Q.useContext)(er)}function nr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>$n.get(e)?.get(t),set:(t,n)=>{let r=$n.get(e)??new Map;r.set(t,n),$n.set(e,r)}}),[e]);return(0,$.jsx)(er.Provider,{value:n,children:t})}function rr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function ir(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function ar(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 or(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function sr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var cr=new Map;function lr(e,t){cr.set(e,t)}function ur(e){return cr.get(e)}var dr=new Map;function fr(e,t){dr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function pr(e){return dr.get(e)}function mr(e,t,n){let r=dr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var hr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),gr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),_r=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),vr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),yr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function br(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function xr(e){let t=br(e);return t===void 0?void 0:hr.format(t)}function Sr(e){let t=br(e);return t===void 0?void 0:gr.format(t)}var Cr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function wr(e){let t=br(e);return t===void 0?void 0:Cr(t)}function Tr(e,t=new Date){let n=br(e);if(n===void 0)return;let r=Cr(n);return r===Cr(t)?`Today`:r===Cr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?_r:vr).format(n)}function Er(e,t){let n=br(e),r=br(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Dr({ts:e}){let t=xr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Sr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Or({startedAt:e,completedAt:t}){let n=xr(t);if(n===void 0)return null;let r=Er(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:Sr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function kr({ts:e}){let t=Tr(e),n=br(e);if(t===void 0||n===void 0)return null;let r=yr.format(n);return(0,$.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:wr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Ar={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function jr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Ar[e],s=r===void 0?void 0:xr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:l(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,$.jsxs)(`p`,{className:l(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(rt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(Dr,{ts:r})})]}),(0,$.jsx)(`div`,{className:l(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function Mr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await i?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,$.jsxs)(jr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,$.jsx)(Ke,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(jr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||o?(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,$.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Cn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(He,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(Nt,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>D(e.split(`/`).pop()??``)?(0,$.jsx)(hn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:a(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,$.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}var Nr=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Pr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Fr(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Pr).forEach(e=>e.remove());let r=Pn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Nn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Ir(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Fr(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}function Lr({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Ir(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(jr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Nr,children:[(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Nr,children:[(0,$.jsx)(sn,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(Nt,{breaks:!0,children:e})}),(0,$.jsx)(zn,{text:e,messageKey:n})]})}function Rr({note:e}){return e.icon===`handoff`?(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,$.jsx)(mn,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:l(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var zr={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`};function Br({incident:e}){let t=zr[e.provider];return(0,$.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,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,$.jsx)(J,{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 Vr({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
|
+
`,1)[0]??``,r=n.length<e.length;return(0,$.jsxs)(Z,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,$.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,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,$.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,$.jsx)(Nt,{inline:!0,children:n})}),r?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,$.jsx)(Y,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,$.jsx)(Nt,{children:e})})})]})}function Hr(){return(0,$.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,$.jsx)(Ke,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Ur={read:sn,edit:Cn,delete:He,move:xn,search:Ee,execute:Ut,think:vn,fetch:Bt,task:Ae,plan:De,other:Ve},Wr=e=>e.split(`
|
|
3
|
+
`).length;function Gr({text:e,streaming:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Wr(e),s=!t&&!n&&o>12;return(0,$.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=or(e.currentTarget)}:void 0,className:l(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,$.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,$.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,$.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 Kr({diffs:e}){return(0,$.jsx)($.Fragment,{children:e.map((e,t)=>(0,$.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,$.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...qr(e.oldText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...qr(e.newText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
|
+
`).map((e,t)=>(0,$.jsx)(Jr,{text:e},t))})]},`${e.path}:${t}`))})}function qr(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
+
`)}function Jr({text:e}){return(0,$.jsx)(`span`,{className:l(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function Yr(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function Xr(e){let t=e.status===`running`||e.status===`pending`,n=Xn(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:e.toolKind===`execute`?kn(e.input)??i:i,Icon:Ur[e.toolKind]??Ve}}function Zr(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function Qr({item:e,busy:t}){return(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,$.jsx)(Ke,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,$.jsx)(`span`,{"data-slot":`tool-exit`,className:l(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function $r({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,$.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,$.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,$.jsx)(Kr,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,$.jsx)(Gr,{text:e.output,streaming:n}):null,r.length>0?(0,$.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function ei({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=tr(),[a,o]=(0,Q.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:c,verb:u,detail:d,expandedCommand:f,Icon:p}=Xr(e),m=Zr(e,t.length),h=f!==void 0||m,g=h&&(a??(m&&Yr(e)));return(0,$.jsxs)(Z,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:s,className:l(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(Y,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:l(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,$.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:l(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,$.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,$.jsx)(Qr,{item:e,busy:c})]}),(0,$.jsx)(X,{children:(0,$.jsx)($r,{item:e,command:f,busy:c,nested:t,cacheKey:n,renderNested:r})})]})}function ti(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function ni({item:e,cacheKey:t}){let n=tr(),[r,i]=(0,Q.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),c=(e.stdout??``)!==``||(e.stderr??``)!==``,u=ti(e);return(0,$.jsxs)(Z,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:l(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(Y,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,$.jsx)(_n,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,$.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,$.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,$.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:l(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,$.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),c?(0,$.jsxs)(Z,{className:`border-t border-border`,children:[(0,$.jsxs)(Y,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,$.jsxs)(X,{children:[e.stdout?(0,$.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,$.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function ri({group:e,scope:t}){return(0,$.jsxs)(Z,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,$.jsxs)(Y,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,$.jsx)(ei,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function ii({count:e,children:t}){return(0,$.jsxs)(Z,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,$.jsxs)(Y,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Jn(e)]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function ai({image:e}){return(0,$.jsx)(hn,{"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 oi(e){return e.needsConfig&&e.configPending?`Checking task settings…`:e.needsConfig&&e.configError?`Task settings could not be loaded.`:e.providersPending?`Checking agent providers…`:e.providersError?`Provider authentication could not be verified.`:e.canContinue?void 0:e.untouched?`Connect the required workflow providers (${e.missing.join(`, `)}) to continue.`:`Connect an agent provider to continue.`}function si(e,t=null){let n=fe(),r=me(),i=Ht(e),a=i&&!e.runner,o=ne(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=Dt(t,o,s),l=o.includes(s),u=(i?A(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=oi({needsConfig:a,configPending:r.isPending,configError:r.isError,providersPending:n.isPending,providersError:n.isError,canContinue:d,untouched:i,missing:u});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 ci(e,t,n,r,i,a,o,s){let c=!r&&!n&&e.model?{...i?.defaultModels,[t]:e.model}:i?.defaultModels,l=r?null:o,u=St(t,a,[l,c?.[t]]),d=_t(l,t,c,a),f=yt(t,d,a),p=r?``:s??e.effort??``,m=bt(p,f);return{models:u,model:d,effortOptions:f,effort:m,mustClearStoredEffort:!r&&s===null&&p!==``&&m===``}}function li(e,t,n,r,{accounts:i,repoAccount:a},o){let s=[...e.steps].reverse().find(e=>e.sessionId),c=s?.profileId??e.agentProfile??`default`;return{sessionStep:s,accountDefaults:r?a:{...a,[n]:c},account:i.some(e=>e.provider===t&&e.id===o)?o:null}}function ui(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l},u){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0,agentProfile:u??void 0}}function di(e,t,n,r,i){return!!t&&(n!==(t.backend??r)||(i??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function fi({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function pi(e){let t=N(),n=Vt(e).continueRun,r=me(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(e.id);f!==e.id&&(p(e.id),a(null),s(null),l(null),d(null));let m=si(e,i),{runners:h,canContinue:g,currentRunner:_,runner:v}=m,y=V(v,n),b=r.data?.modelsLocked===!0,x=v!==_,S=ci(e,v,x,b,r.data,y.data,o,c),{models:C,model:w,effortOptions:E,effort:D}=S,{modelLabel:ee,effortLabel:O}=fi(S),k=Ct(),{accounts:A}=k,{sessionStep:ne,accountDefaults:j,account:M}=li(e,v,_,x,k,u),P=H({mutationFn:({text:t,images:n})=>g?te(L(e.id),ui(t,n,m.runnerOverride,b,x,o,c,S,M)):Promise.reject(Error(m.reason??`Connect an agent provider to continue.`)),onMutate:()=>L(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof T&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}});return{available:n,canContinue:g,startsNewConversation:di(e,ne,v,_,M),reason:m.reason,providerPending:m.providerPending,pills:(0,$.jsx)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:(0,$.jsxs)(xt,{children:[h.length>1||h.some(e=>Et(A,e))?(0,$.jsx)(vt,{icon:(0,$.jsx)(ze,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:h,value:v,accounts:A,account:M,repoAccount:j,onPick:(e,t)=>{d(t),e!==v&&(a(e),s(null))}}):(0,$.jsx)(Tt,{icon:(0,$.jsx)(ze,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:v,value:v,onPick:()=>{},options:[{value:v,label:v}]}),(0,$.jsx)(Tt,{icon:(0,$.jsx)(ke,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:ee,value:w,readOnly:b,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=yt(v,e,y.data);D!==``&&bt(D,t)===``&&l(``)},options:C.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:wt(v,y.data,y.isError,y.isFetching)}),(0,$.jsx)(Tt,{icon:(0,$.jsx)(Se,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:O,value:D,readOnly:b,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:E.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})}),continueWith:(e,t)=>P.mutateAsync({text:e,images:t})}}var mi=120,hi=e=>e!==`pending`&&e!==`running`,gi=e=>e.kind===`tool`&&e.toolKind===`task`,_i=e=>gi(e)&&e.parentItemId===void 0,vi=e=>Hn(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function yi(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>_i(e)&&t.has(e.id)))return n;return 0}function bi(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 xi(e){if(e.kind===`tool`)return Si(e.title);if(e.kind===`hook`)return Si(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
|
+
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Si(n)}}}function Si(e){return e.length>mi?`${e.slice(0,mi-1).trimEnd()}…`:e}function Ci(e,t=!1){let n=Di(e,e=>e.items.some(_i));if(n===-1)return[];let r=e=>!t&&!hi(e.status),i=e=>r(e)&&e.background===!0,a=[],o=!1;for(let t=n-1;t>=0;--t){let n=e[t].items.filter(_i);n.length!==0&&(!o&&!n.some(r)&&(o=!0),(!o||n.some(i))&&a.unshift(...n))}let s=[...a,...e[n].items.filter(_i)];if(n!==e.length-1&&!s.some(r))return[];let c=new Set(s.map(e=>e.id)),l=a.length>0?yi(e,c):n,u=new Map;for(let t=l;t<e.length;t+=1)for(let n of e[t].items){if(!vi(n))continue;let e=n.parentItemId;if(e===void 0||!c.has(e))continue;let t=u.get(e);t?t.push(n):u.set(e,[n])}return s.map(e=>wi(e,u.get(e.id)??[],t))}function wi(e,t,n){let r={id:e.id,title:Xn(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=bi(e);i!==void 0&&(r.agentType=i),n&&!hi(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=xi(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Ti(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Ei(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Di(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Oi(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&_i(e));if(i!==void 0)return wi(i,ki(e,t),n)}}function ki(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&_i(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)vi(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}function Ai(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?Zn(e.children).flatMap(n=>Ai(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Ai(e,t)):[]}function ji(e){return e.flatMap((e,t)=>e.content.kind===`block`?Ai(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Mi(e,t,r,i){let a=(0,Q.useContext)(ln),{projectId:o}=n(),s=(0,Q.useMemo)(()=>ji(t),[t]);(0,Q.useLayoutEffect)(()=>{if(!a)return;let t=[],n={runId:e,...o?{projectId:o}:{}};for(let e of s){let o=Ln(e.text,n);for(let e of o)t.push(a.register(e.artifactId,e.runId));i===`document`&&o.length>0&&t.push(a.registerOpener(e.messageKey,(t,n)=>{let i=Rn(e.messageKey,t);r.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,n)}))}return()=>{for(let e of t)e()}},[a,s,e,o,i,r.jumpToRow])}function Ni(e){let t=v();return H({mutationFn:t=>h(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:U.runs.all})}})}var Pi=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Fi=()=>navigator.onLine;function Ii({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,$.jsx)(Ri,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,$.jsx)(Li,{permission:e,runId:t},e.requestId)}function Li({permission:e,runId:t}){let n=Ni(t),r=(0,Q.useSyncExternalStore)(Pi,Fi,()=>!1),i=(0,Q.useRef)(!1),[a,o]=(0,Q.useState)(`pending`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof T&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,$.jsx)(Ri,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Ri({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Q.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,l=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,$.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,$.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,$.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,$.jsx)(c,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,$.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[l,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}function zi(e,t){if(e.length===1)return[t.replace(RegExp(`^${Bi(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Vi(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}function Hi({ask:e}){let t=e.answer===void 0?void 0:zi(e.questions,e.answer);return(0,$.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=Vi(n,i),o=i!==void 0&&a.length===0;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,$.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,$.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,$.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,$.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,$.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,$.jsx)(Ui,{text:i}):null]})]}):i===void 0?null:(0,$.jsx)(Ui,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,$.jsx)(Ui,{text:e.answer}):null]})}function Ui({text:e}){return(0,$.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}var Wi=(0,Q.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Gi(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function Ki(e,t,n=[]){let r={};for(let e of n)r[e.id]=P(e);for(let e of t??[])r[e.id]=P(e);return r[e.id]=P(e),r}function qi(e,t){return t?.[e]??`Task`}function Ji(e,t,n){return t?n?.[e]??`peer task`:qi(e,n)}function Yi(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Xi(e){return e?.relationship===`peer`}function Zi(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Qi(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function $i(e){if(e.outcome)return Qi(e.outcome.status);if(e.delivery===`not-delivered`)return ea(`not-delivered`)}function ea(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function ta(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t===`cursor`?`Queued for delivery. If Cursor is in a turn, delivery waits for that turn to end.`:t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Xi(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${r()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function na({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:qi(e,n),linkable:!0}):(0,$.jsx)(ra,{id:e,children:r})}function ra({id:e,children:t}){let n=pe(e);return n.data?t({title:P(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof T&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var ia={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},aa=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function oa({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,$.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,$.jsx)(sa,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function sa({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Yi(e.messages[0]??{senderRunId:e.senderRunId},t),a=Xi(e.messages[0]),o=ia[a?`peer`:i],s=ga(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),c=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${c} ${s.map(e=>Ji(e,a,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,$.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:l(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes),children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:l(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,$.jsx)(`span`,{children:c}),s.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,$.jsx)(na,{id:e,peer:a,taskTitles:n,children:t=>(0,$.jsx)(fa,{view:t,to:`/tasks/${e}`,label:`${c} ${t.title}`})})]},e))]}),a?(0,$.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,$.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:Zi(e.kind)}),e.messages.length===1&&d?(0,$.jsx)(la,{message:d}):null]}),(0,$.jsx)(ca,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,$.jsx)(da,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>ta(e,r?.[e.recipientRunId])))].map(e=>e?(0,$.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,$.jsx)(ua,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,$.jsx)(pa,{message:d,runId:t,taskTitles:n}):null,(0,$.jsx)(ma,{batch:e,heading:u})]})}function ca({at:e,className:t,children:n}){return e===void 0||xr(e)===void 0?null:(0,$.jsxs)(`span`,{className:t,children:[n,(0,$.jsx)(Dr,{ts:e})]})}function la({message:e}){let t=$i(e),n=ea(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function ua({messages:e,peer:t,runId:n,taskTitles:r}){return(0,$.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=$i(e),a=e.createdAt??e.recordedAt;return(0,$.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(na,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,$.jsx)(fa,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,ea(e.delivery)===i?null:(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,children:ea(e.delivery)}),(0,$.jsx)(pa,{message:e,runId:n,taskTitles:r}),(0,$.jsx)(ca,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function da({batch:e}){let t=tr(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Q.useState)(()=>t?.get(n)??!1),a=(0,$.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,$.jsx)(Nt,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,$.jsxs)(Z,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,$.jsxs)(Y,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,$.jsx)(X,{children:a})]})}function fa({view:e,to:t,label:n}){return e.linkable?(0,$.jsx)(J,{className:aa,to:t,"aria-label":n,children:e.title}):(0,$.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function pa({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Q.useContext)(Wi),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,$.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Yi(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:l(aa,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,$.jsx)(na,{id:i,peer:Xi(e.message),taskTitles:n,children:e=>(0,$.jsxs)($.Fragment,{children:[`View `,c,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function ma({batch:e,heading:t}){return(0,$.jsxs)(Z,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,$.jsxs)(Y,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,$.jsx)(K,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,$.jsx)(X,{children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>ha(e)).map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,$.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function ha(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Xi(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:ea(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function ga(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var _a=e(f(),1);function va(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function ya(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?va(t):null}function ba(e,t){let n=`${Na}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?ya(r):null}}function xa(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function Sa({onGoToQuestion:e}){return(0,$.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}var Ca={viewKey:void 0,generation:0},wa=600,Ta=24;function Ea(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Q.useRef)(e);o.current=e;let s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(!0),p=(0,Q.useRef)(0),h=(0,Q.useRef)(0),g=(0,Q.useRef)(new Set),_=(0,Q.useCallback)(e=>{for(let t of[...g.current])t(e)},[]),v=(0,Q.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useCallback)(e=>{let t=s.current;if(!t)return;let n=S.current;n?n.scrollTo(e):t.scrollTop=e},[]),w=(0,Q.useCallback)(()=>{let e=s.current;e&&C(e.scrollHeight-e.clientHeight)},[C]),T=(0,Q.useCallback)(()=>{if(s.current){if(x.current!==e){x.current=e;let t=ur(e);t&&!t.atBottom?(f.current=!1,y.current=t.top,b.current=pr(e)?.rowKeys?{viewKey:e,top:t.top}:null):(f.current=!0,y.current=null,b.current=null)}y.current===null?f.current&&w():C(y.current)}},[e,C,w]),E=(0,Q.useCallback)(e=>b.current?.viewKey===e,[]),D=(0,Q.useCallback)(e=>{let t=b.current;return!t||!E(e)||e!==o.current?!1:(y.current=t.top,f.current=!1,b.current=null,!0)},[E]),ee=(0,Q.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),T())},[n,T]),O=(0,Q.useCallback)(()=>{f.current&&w()},[w]),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(0),te=(0,Q.useRef)(!1),ne=(0,Q.useRef)(void 0),j=(0,Q.useRef)(!1),M=(0,Q.useRef)(!1),N=(0,Q.useRef)(a);N.current=a;let P=(0,Q.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}}),[]),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!m())return;let e=e=>{y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,C(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[C]);let L=(0,Q.useCallback)(()=>{let e=F.current,t=s.current;if(!e||!t)return;F.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:N.current.indexOf(e.anchor.key),a=S.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):C(ar(t.scrollTop,r,e.anchor,P(t),n))},[P,C]),R=(0,Q.useCallback)(()=>{let e=s.current;if(!e||!r||k.current)return;y.current=null,b.current=null,f.current=!1,k.current=!0;let t=A.current+1;A.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=ir(a,P(e)),l=c===void 0?-1:N.current.indexOf(c.key),u=o.current,d=I.current;r().then(()=>{o.current===u&&I.current===d&&(F.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{A.current===t&&(k.current=!1)})},[P,r]);(0,Q.useEffect)(()=>()=>clearTimeout(ne.current),[]);let z=(0,Q.useRef)(null),re=(0,Q.useRef)(0),B=(0,Q.useCallback)(()=>n===`document`?++Ca.generation:++re.current,[n]),ie=(0,Q.useCallback)((e,t)=>n===`document`?Ca.viewKey===e&&Ca.generation===t:o.current===e&&re.current===t,[n]);(0,Q.useEffect)(()=>()=>z.current?.disconnect(),[e,c]);let ae=(0,Q.useCallback)((t,n,r,i)=>{let a=s.current;if(!a||!c)return;y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,p.current=0,d(!0),B(),z.current?.disconnect();let o=()=>[...c.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),l=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(z.current?.disconnect(),!0):!1},u=a.querySelector(`[data-slot="run-header"]`),m=u&&getComputedStyle(u).position===`sticky`?u.getBoundingClientRect().height:0,h=S.current;if(i!==void 0)C(i);else if(h)h.scrollToIndex(n,{align:`start`,...m>0?{offset:-m}:{}});else{let e=o();e&&C(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-m)}l()||(z.current=new MutationObserver(()=>{l()}),z.current.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),lr(e,{top:i??a.scrollTop,atBottom:!1})},[c,C,e,B]),oe=(0,Q.useCallback)(t=>{let n=B(),r=o.current;z.current?.disconnect();let a=s.current;if(!a)return;y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!0,h.current=0,_({direction:`tail`}),lr(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let c=()=>{f.current&&w()},l=()=>ie(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>{if(c(),!t||!l()||u())return;z.current?.disconnect();let e=new MutationObserver(()=>{l()?u()&&e.disconnect():e.disconnect()});z.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,w,B,ie,_]),se=a.at(-1),V=a.length;return(0,Q.useLayoutEffect)(()=>{I.current+=1,F.current=null,k.current=!1,n===`document`?Ca.viewKey!==e&&(Ca.viewKey=e,Ca.generation+=1):re.current+=1},[e,n]),(0,Q.useLayoutEffect)(()=>{let e=F.current;e?(e.anchor===void 0?-1:N.current.indexOf(e.anchor.key))>e.anchorIndex?L():F.current=null:f.current&&w()},[se,V,L,w]),(0,Q.useLayoutEffect)(()=>{!s.current||!c||T()},[c,T]),(0,Q.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;p.current=0;let r=null,i=!1,a=t.scrollTop,o,l=0,u,m=e=>{h.current=Date.now(),u=e},g=()=>{B(),z.current?.disconnect(),y.current=null,b.current=null,I.current+=1,F.current=null,f.current=!1,p.current=0},v=()=>{y.current=null,b.current=null,I.current+=1,F.current=null,p.current=Date.now()},x=e=>{if(e.deltaY!==0)if(m(e.deltaY<0?`up`:`down`),e.deltaY<0){g();let e=!te.current;te.current=!0,clearTimeout(ne.current),ne.current=setTimeout(()=>{te.current=!1},180),e&&rr(t)&&R()}else v()},S=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(m(`up`),g(),!e.repeat&&rr(t)&&R()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(m(`down`),v())},T=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,M.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(y.current=null,b.current=null,or(t,80)||(g(),v()))},D=()=>{i=!1},ee=e=>{j.current=!1,r=e.touches[0]?.clientY??null},O=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(m(`up`),g(),!j.current&&rr(t)&&(j.current=!0,R())):r!==null&&n<r-1&&(m(`down`),v()),r=n)},k=e=>{if(e===0||!i&&Date.now()-h.current>=wa)return;let n=e<0?`up`:`down`;!i&&n!==u||(n!==o&&(o=n,l=0),l+=Math.abs(e),l>=Ta&&(0,_a.flushSync)(()=>_({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},A=()=>{let n=f.current;k(t.scrollTop-a),i&&t.scrollTop!==a&&(t.scrollTop<a?g():v()),i&&!M.current&&t.scrollTop<a&&rr(t)&&(M.current=!0,R()),a=t.scrollTop;let r=or(t,80);r&&y.current===null&&(f.current||Date.now()-p.current<2e3)&&(f.current=!0),!n&&f.current&&_({direction:`tail`}),d(!r),y.current===null&&!E(e)&&lr(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,A,{passive:!0}),t.addEventListener(`wheel`,x,{passive:!0}),t.addEventListener(`touchstart`,ee,{passive:!0}),t.addEventListener(`touchmove`,O,{passive:!0}),t.addEventListener(`pointerdown`,T,{passive:!0}),window.addEventListener(`pointerup`,D,{passive:!0}),window.addEventListener(`pointercancel`,D,{passive:!0}),t.addEventListener(`keydown`,S);let N;if(typeof ResizeObserver<`u`){N=new ResizeObserver(()=>{let e=y.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;C(Math.min(e,n)),n>=e&&(y.current=null)}else f.current&&w()}),N.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&&N.observe(r),i&&N.observe(i)}return()=>{t.removeEventListener(`scroll`,A),t.removeEventListener(`wheel`,x),t.removeEventListener(`touchstart`,ee),t.removeEventListener(`touchmove`,O),t.removeEventListener(`pointerdown`,T),window.removeEventListener(`pointerup`,D),window.removeEventListener(`pointercancel`,D),t.removeEventListener(`keydown`,S),N?.disconnect()}},[e,c,R,C,w,E,B,_]),{attachContent:ee,scrollElRef:s,virtualizerRef:S,restoreMeasurements:D,ownsMeasurementRestore:E,pillVisible:u,jumpToLatest:oe,jumpToRow:ae,loadOlder:R,restickIfStuck:O,subscribeReaderScroll:v}}function Da({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,$.jsx)(Oa,{runId:e,rows:t,controls:r}):(0,$.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,$.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 Oa({runId:e,rows:t,controls:n}){return(0,$.jsx)(ka,{runId:e,rows:t,controls:n},e)}function ka({runId:e,rows:t,controls:n}){let r=(0,Q.useRef)(null),i=(0,Q.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,Q.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Q.useState)(()=>pr(e)),[l,u]=(0,Q.useState)(()=>({cache:mr(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Q.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Q.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Q.useRef)(t.length);f.current=t.length;let p=(0,Q.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Q.useRef)(null),h=(0,Q.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||fr(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Q.useState)(0);return(0,Q.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,$.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,$.jsx)(Zt,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function Aa({onJump:e,pendingQuestions:t=0}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,$.jsx)(Le,{"aria-hidden":!0,className:`size-3.5`}),xa(t)]})}function ja(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function Ma(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,ja(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}var Na=`pending-ask`;function Pa(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}function Fa(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let n of t.turns)c.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:Ma(e,n.items.map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Pa(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e))});let l=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return l.length>0&&c.push({id:`pending-permissions`,entries:l,inDaySequence:!1}),i!==void 0&&c.push({id:Na,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}function Ia(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function La(e,t){return[{id:`agent:${e}`,entries:t}]}function Ra(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function za(e,t){let n=[],r;for(let t of e){let e=Ra(t),i=wr(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of Zn([...t.entries]))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Ba({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Q.useMemo)(()=>za(n,e),[n,e]),p=Ea(`${e}:${t}`,{surface:r}),m=c??p;Mi(e,f,m,r);let h=(0,Q.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Q.useMemo)(()=>f.map(t=>({key:t.key,node:Va(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??sr(``,g.length),v=g.length===0?i??null:(0,$.jsx)(Da,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,$.jsx)(Ze,{runId:e,children:(0,$.jsx)(nr,{runId:e,children:(0,$.jsx)(Wi.Provider,{value:h,children:r===`panel`?(0,$.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,$.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,$.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,$.jsx)(Aa,{onJump:m.jumpToLatest})}):null]}):v})})})}function Va(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,$.jsx)(Ha,{message:e.content.message,actions:t});case`day-separator`:return(0,$.jsx)(kr,{ts:e.content.ts});case`turn-time`:return(0,$.jsx)(Or,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,$.jsx)(Ua,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return qa(e.content)}}function Ha({message:e,actions:t}){return(0,$.jsx)(Mr,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,$.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,$.jsx)(Hi,{ask:e.ask})}):void 0})}function Ua({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,$.jsx)(In.Provider,{value:`${t}:${e.entry.id}`,children:(0,$.jsx)(Ga,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,$.jsx)(ei,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,$.jsx)(Wa,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,$.jsx)(ri,{group:e,scope:t});case`streak`:return(0,$.jsx)(ii,{count:e.count,children:e.blocks.map(e=>(0,$.jsx)(Ua,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,$.jsx)(oa,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return qa(e)}}function Wa({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return Zn([...e]).map(e=>(0,$.jsx)(Ua,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Ga({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,$.jsx)(Lr,{text:e.text,ts:e.ts}):(0,$.jsx)(Mr,{text:e.text,ts:e.ts});case`reasoning`:return(0,$.jsx)(Vr,{text:e.text});case`tool`:return(0,$.jsx)(ei,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${ea(e.delivery)}`:``]}),(0,$.jsx)(Rr,{note:e})]}):(0,$.jsx)(Rr,{note:e});case`conversation`:return(0,$.jsx)(oa,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,$.jsx)(ai,{image:e});case`ask`:return n===void 0?(0,$.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,$.jsx)(Ii,{permission:e,runId:i});case`provider-auth-required`:return(0,$.jsx)(Br,{incident:e});case`preview-server`:return(0,$.jsx)(Ka,{entry:e});case`hook`:return(0,$.jsx)(ni,{item:e,cacheKey:`${t}:${e.id}`});default:return qa(e)}}function Ka({entry:e}){let t=an(),n=ie().data?.capabilities?.preview===!0;return(0,$.jsx)(st,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function qa(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Ja({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,Q.useContext)(ln),l=(0,Q.useRef)(void 0),u=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,$.jsx)(cn,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,$.jsx)(fn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,$.jsx)(Fn.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,$.jsx)(Ya,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function Ya({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(dn,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,$.jsxs)(qt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,$.jsxs)($t,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(Xa,{status:r.status}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,$.jsx)(Ba,{runId:e,viewId:`agent:${r.id}`,sections:La(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,$.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 Xa({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,$.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:l(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}var Za=/^diff --git /;function Qa(e){let t=e.replace(Za,``),n=t.lastIndexOf(` b/`);return $a(n>=0?t.slice(n+3):t)}function $a(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function eo(e){let t=$a(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function to(e){return{path:Qa(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function no(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=$a(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=$a(t.slice(10));else if(t.startsWith(`new file mode`))e.status=`added`;else if(t.startsWith(`deleted file mode`))e.status=`deleted`;else if(t.startsWith(`Binary files `)||t===`GIT binary patch`)e.binary=!0;else if(t.startsWith(`+++ `)){let n=eo(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=eo(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function ro(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function io(e){let t=[],n=null,r=!1;for(let i of e.split(`
|
|
7
|
+
`)){if(Za.test(i)){n=to(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):no(n,i);continue}ro(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function ao(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var oo=20,so=300;function co({runId:e}){let t=v(),n=le(e);(0,Q.useEffect)(()=>{t.invalidateQueries({queryKey:U.runs.diff(e)})},[t,e]);let r=(0,Q.useMemo)(()=>io(n.data??``),[n.data]),[i,a]=(0,Q.useState)(!1);if(n.isPending)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(r.length===0)return(0,$.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let o=ao(r),s=i?r:r.slice(0,oo);return(0,$.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[o.files,` `,o.files===1?`file`:`files`,` changed`]}),(0,$.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,o.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,o.deletions]})]})]}),s.map(e=>(0,$.jsx)(uo,{file:e},`${e.oldPath??``}→${e.path}`)),r.length>s.length?(0,$.jsxs)(c,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>a(!0),children:[`Show `,r.length-s.length,` more files`]}):null]})}var lo={added:`added`,deleted:`deleted`,renamed:`renamed`};function uo({file:e}){let[t,n]=(0,Q.useState)(!0),r=lo[e.status];return(0,$.jsxs)(Z,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,$.jsxs)(Y,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,$.jsx)(Qt,{className:l(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,$.jsx)(fo,{lines:e.lines})})})]})}function fo({lines:e}){let[t,n]=(0,Q.useState)(!1),r=t?e:e.slice(0,so),i=r.join(`
|
|
8
|
+
`),[a,o]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1;return At(i,`diff`).then(t=>{e||o({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let s=a?.text===i?a.tokens:kt(i,`diff`)?.tokens??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,$.jsxs)(`span`,{className:l(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[s?.[t]===void 0?e:s[t].map((e,t)=>(0,$.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>so?(0,$.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function po(e){let t=v();return H({mutationFn:()=>g(e),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all}),onError:e=>G(e.message,{tone:`danger`})})}function mo({run:e}){return(0,$.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,$.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,$.jsx)(nt,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,$.jsx)(co,{runId:e.id}),(0,$.jsx)(ho,{run:e})]})}function ho({run:e}){let t=N(),n=v(),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(``),[s,l]=(0,Q.useState)(null),u=po(e.id),d=si(e),f=()=>n.invalidateQueries({queryKey:U.runs.all}),p=H({mutationFn:async t=>d.canContinue?te(L(e.id),{text:`Review feedback:\n${t}`,runner:d.runnerOverride}):null,onMutate:()=>L(e.id),onSuccess:(e,n,r)=>{e!==null&&(a(``),t.invalidateAfter(`continue`,r))},onError:e=>G(e.message,{tone:`danger`})}),m=H({mutationFn:()=>y(e.id),onSuccess:e=>{G(`Draft PR created — ${e.url}`),f()},onError:e=>{e instanceof T&&e.manual!==void 0&&l(e.manual),G(e.message,{tone:`danger`})}}),h=()=>{let e=i.trim();if(e.length===0){G(`Write what to change first.`),r.current?.focus();return}p.mutate(e)};return(0,$.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,$.jsx)(Ge,{ref:r,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{Gt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},className:`min-h-[52px] text-[13px]`}),d.canContinue?null:(0,$.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:d.reason}),d.providerPending?null:(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(c,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:d.reason??`Send the notes back into the agent's session`,"aria-describedby":d.canContinue?void 0:`review-provider-guidance`,disabled:p.isPending||!d.canContinue,onClick:h,children:[(0,$.jsx)(bn,{"aria-hidden":`true`}),`Send back`]}),o(e.pullRequestUrl)?(0,$.jsx)(c,{asChild:!0,variant:`outline`,size:`sm`,children:(0,$.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,$.jsx)(xe,{"aria-hidden":`true`}),`PR ↗`]})}):(0,$.jsxs)(c,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:m.isPending,onClick:()=>m.mutate(),children:[(0,$.jsx)(we,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,$.jsxs)(c,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:Rt(`review`),disabled:u.isPending,onClick:()=>u.mutate(),children:[(0,$.jsx)(Ie,{"aria-hidden":`true`}),`Accept`]}):null]}),s===null?null:(0,$.jsx)(go,{command:s})]})}function go({command:e}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>G(`Command copied to clipboard.`)).catch(()=>G(`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,$.jsx)(We,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function _o(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var vo=1500;function yo({status:e}){let t=(0,Q.useRef)(e),[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||_o())return;r(!0);let i=setTimeout(()=>r(!1),vo);return()=>clearTimeout(i)},[e]),n?(0,$.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,$.jsx)(ht,{}),(0,$.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,$.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 bo(e){let t=v(),[n,r]=(0,Q.useState)(),i=B(e);(0,Q.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=H({mutationFn:async()=>{r(e.id);try{if(!(await w(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:U.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function xo({agents:e,onSelect:t}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,$.jsx)(So,{agent:e,onSelect:t},e.id))})}function So({agent:e,onSelect:t}){let n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Co,{status:e.status,stalled:e.stalled===!0}),(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,$.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Ei(e)}),(0,$.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,$.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,$.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,$.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Co({status:e,stalled:t=!1}){return t?(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,$.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,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function wo(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function To({entries:e}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,$.jsx)(Eo,{entry:e},`${t}:${e.content}`))})}function Eo({entry:e}){return(0,$.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:l(`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,$.jsx)(Do,{status:e.status}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,$.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function Do({status:e}){return e===`cancelled`?(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,$.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,$.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,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function Oo(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function ko(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function Ao({steps:e}){if(e.length===0)return null;let t=ko(e)*100;return(0,$.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,$.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Oo(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(jo,{visual:Oo(t.status)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,$.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,$.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function jo({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,$.jsx)(Be,{"aria-hidden":!0,className:l(t,`text-success`)});case`active`:return(0,$.jsx)(Ke,{role:`status`,"aria-label":`Step running`,className:l(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(Oe,{"aria-hidden":!0,className:l(t,`text-danger`)});case`pending`:return(0,$.jsx)(Pe,{"aria-hidden":!0,className:l(t,`text-soft-foreground`)})}}function Mo(e){let t=e.findIndex(e=>Oo(e.status)===`active`);if(t>=0)return t;let n=e.findIndex(e=>e.status===`pending`);return n>=0?n:Math.max(0,e.length-1)}function No(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function Po(e){return typeof e==`object`&&!!e&&!(0,Q.isValidElement)(e)&&`keep`in e}function Fo({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:o,onToggle:s,className:c,children:u}){let d=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,$.jsx)(`span`,{className:l(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(Po(r)?(0,$.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,$.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,$.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,$.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=s!==void 0;return(0,$.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&o?`open`:`collapsed`,className:l(`min-w-0 border-t border-border first:border-t-0`,c),children:[f?(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:s,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,a,(0,$.jsx)(Ue,{"aria-hidden":!0,className:l(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,o&&`rotate-180`)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,a]}),f&&o?(0,$.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function Io(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function Lo(e){let t=e.delegation,n=t?.role===`root`,r=F(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=Io(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function Ro({run:e,open:t,onToggle:n}){let r=F(e.id),i=I(),a=on(),o=e.delegation,s=new Map(r.data?.workers.map(e=>[e.workerId,e])),u=Io(o,r.data),d=E(e)??O(e),f=d?zo(e,d):void 0;return(0,$.jsx)(Fo,{slot:`workers`,icon:(0,$.jsx)(Fe,{className:`size-4`}),title:`Workers`,meta:Bo({ids:u,workers:s,desktop:a,query:r}),aside:r.data?.capacity?(0,$.jsx)(qo,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,$.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,d?(0,$.jsx)(Wo,{wait:d,dependencyLabel:f}):null,u.length>0?(0,$.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:u.map(t=>{let n=s.get(t),a=i.data?.find(e=>e.id===t)??r.data?.titles?.find(e=>e.id===t),o=n?Ho(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,$.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,$.jsxs)(J,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,$.jsx)(Vo,{status:n?.status}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a?P(a):`Worker ${t.slice(0,8)}`}),(0,$.jsx)(`span`,{className:l(`max-w-[45%] shrink-0 truncate text-xs`,Uo(n?.status)),children:o}),(0,$.jsx)(Re,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,$.jsx)(Yo,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,$.jsx)(Zo,{state:n.destroy}):null]},t)})}):o?.role===`root`&&r.isSuccess?(0,$.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,$.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,$.jsx)(c,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function zo(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return x(e)??b(n.role,t,`requestIds`in t&&S(n,t.requestIds))}function Bo({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function Vo({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,$.jsx)(Be,{"aria-hidden":!0,className:l(t,`text-success`)}):e===`failed`?(0,$.jsx)(Oe,{"aria-hidden":!0,className:l(t,`text-danger`)}):e===`cancelled`?(0,$.jsx)(Ne,{"aria-hidden":!0,className:l(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,$.jsx)(Ke,{role:`status`,"aria-label":`Worker running`,className:l(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,$.jsx)(Pe,{"aria-hidden":!0,className:l(t,`text-soft-foreground`)})}function Ho(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Uo(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Wo({wait:e,dependencyLabel:t}){return(0,$.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,$.jsxs)($.Fragment,{children:[` `,`Deadline: `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: ${i(`Cezar`)} wakes this task when they have all settled.`]})}function Go(e){return e.delegation?.role===`worker`&&O(e)?.phase===`wake-pending`}function Ko({run:e}){let t=O(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,$.jsx)(Wo,{wait:t,dependencyLabel:b(`worker`,t)}):null}function qo({capacity:e}){return(0,$.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Jo=new Set([`review`,`done`,`failed`,`cancelled`]);function Yo({parentRunId:e,worker:t}){let n=ve(e),[r,i]=(0,Q.useState)(!1);if(!Jo.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`;return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`break-words text-xs`,children:`Removes this worker's worktree and branch. Its result is saved first.`}),(0,$.jsx)(c,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate(t.workerId)},children:`Clean up`}),(0,$.jsx)(c,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,$.jsx)(c,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,$.jsxs)(`span`,{role:`status`,className:`break-words text-xs`,children:[`Cleanup did not finish: `,n.error.message]}):null]})}function Xo(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Zo({state:e}){if(!Xo(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,$.jsx)(Qo,{at:t.nextAt});return(0,$.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,$.jsxs)($.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,$.jsxs)($.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Qo({at:e}){let t=nn(3e4);return(0,$.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Jt(t,Date.parse(e))})}function $o({items:e,lead:t=0}){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(-1/0);return(0,Q.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,$.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,$.jsx)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:n.content},n.id)})})}function es({run:e,references:t}){return(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,$.jsx)(dt,{reference:t,taskTitle:P(e),inert:!0},j(t)))})}function ts(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?Et(e.accounts,e.accountBackend)?`default`:void 0:e.known?Et(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function ns(e){let t=me(),n=ue(),{accounts:r}=Ct(),i=e.runner??t.data?.defaultRunner??`claude`,a=e.model??`auto`,o=e.effort||`auto`,s=[...e.steps].reverse().find(e=>e.profileId),c=s?.profileId,l=s?.backend??i,u=n.data?.profiles.find(e=>e.id===c&&e.provider===l),d=ts({accountId:c,profilesPending:n.isPending,profilesError:n.isError,known:u,accounts:r,accountBackend:l}),f=e.modelIdentity&&e.modelIdentity!==a?e.modelIdentity:void 0;return{runner:i,...d?{account:d}:{},model:a,effort:o,...f?{identity:f}:{}}}var rs=[`running`,`queued`,`waiting`];function is(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`):[]}function as(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function os(e,t){return`${e} — ${t.status===`running`?`current turn still working`:`waiting for capacity`}`}function ss(e){let t=is(e.waits),n=rs.includes(e.status)?t.filter(e=>e.kind===`worker`||e.kind===`peer`||e.kind===`subagent`?e.phase===`open`:e.phase===`open`||e.phase===`resolved`):[],r=n.some(e=>e.kind===`pr`),i=[...is(e.lastWaits),...t.filter(e=>!n.includes(e)&&e.phase!==`open`)],a=r?void 0:i.filter(e=>e.kind===`pr`).at(-1),o=r?void 0:e.lastWaitsError,s=n.some(e=>e.kind===`process`)?void 0:i.filter(e=>e.kind===`process`).at(-1);return n.length||a||o||s?{open:n,lastCi:a,error:o,lastProcess:s}:void 0}function cs(e){return ss(e)!==void 0}function ls(e){return(ss(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function us({run:e}){let t=ss(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,$.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,$.jsx)(fs,{run:e,wait:t},t.id):t.kind===`worker`?(0,$.jsx)(ps,{wait:t},t.id):t.kind===`process`?(0,$.jsx)(vs,{run:e,wait:t},t.id):t.kind===`peer`?(0,$.jsx)(ms,{wait:t},t.id):t.kind===`subagent`?(0,$.jsx)(hs,{wait:t},t.id):(0,$.jsx)(gs,{run:e,wait:t},t.id)),i?(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,$.jsx)(fs,{run:e,wait:r,settled:!0}):null,a?(0,$.jsx)(vs,{run:e,wait:a,settled:!0}):null]})}function ds(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha.slice(0,7)} → ${r?.observedHeadSha?.slice(0,7)??`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?os(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function fs({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,a=n&&t.phase===`cancelled`,s=ds(e,t,n),c=n?a?t.cancelledAt:r?.observedAt:t.deadline,l=as(c),u=`${t.repository}#${t.prNumber}`;return(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,$.jsx)(`dd`,{children:s}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,$.jsx)(`dd`,{className:`min-w-0`,children:o(t.prUrl)?(0,$.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,$.jsx)(`span`,{children:u})}),l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?a?`Cancelled`:`Observed`:`Deadline`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,$.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function ps({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=as(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,$.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function ms({wait:e}){let t=e.peerIds.length,n=as(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function hs({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=as(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,$.jsxs)(`p`,{children:[`Check by`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function gs({run:e,wait:t}){let n=as(t.deadline);return(0,$.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,$.jsx)(`p`,{children:os(`Automatic check due`,e)}):n?(0,$.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,$.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,$.jsx)(`p`,{children:t.note}):null]})}function _s(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function vs({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?_s(t):t.phase===`resolved`?os(_s(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?as(t.deadline):void 0;return(0,$.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsx)(`p`,{children:r}),i?(0,$.jsxs)(`p`,{children:[`Until`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var ys=new Map,bs=new Map;function xs(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=et(e.run);return(0,$.jsx)(ut,{projectId:t,repoBase:n,requests:i,children:(0,$.jsx)(Ss,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!he(e.run)||!!ge(e.run,n)})})}function Ss({run:e,currentThread:t,currentComplete:n=!0,onOpenWorker:r,readerScroll:i,prNumbers:a,hasReferences:o,references:s}){let c=on(),l=ns(e),[u,d]=(0,Q.useState)(()=>ys.get(e.id)??!1),f=Rs(i,u),p=f.open,[m,h]=(0,Q.useState)({}),g=Cs(e,t,n,a),_=Qe(e),v=t=>m[t]??bs.get(`${e.id}:${t}`)??t===`workers`,y=t=>{let n=!v(t);bs.set(`${e.id}:${t}`,n),h(e=>({...e,[t]:n}))},b=e=>({open:v(e),onToggle:()=>y(e)});return(0,$.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:f.ref,"data-state":p?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,$.jsx)(Os,{run:e,identity:l,activity:g,references:s,open:p,onToggle:()=>{ys.set(e.id,!p),d(!p),f.chose(!p)}}),p?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,$.jsx)(js,{run:e,activity:g,...b(`status`)}),(0,$.jsx)(Ms,{run:e,desktop:c,automations:g.automations,...b(`workflow`)}),(0,$.jsx)(Ns,{activity:g,desktop:c,onOpenWorker:r,...b(`subagents`)}),(0,$.jsx)(Ps,{run:e,...b(`workers`)}),(0,$.jsx)(Fs,{activity:g,desktop:c,...b(`plan`)}),(0,$.jsx)(Is,{run:e,identity:l,activity:g,...b(`usage`)}),(0,$.jsx)(Ls,{run:e,references:s,conflicts:g.conflicts,hasReferences:o,onResume:()=>_.mutate(),...b(`workspace`)})]}):null]})}function Cs(e,t,n,r){let i=ie(),a=Lt(i.data),o=I(),s=Je(e,{queuePosition:e.status===`queued`?ye(o.data??[]).get(e.id):void 0}),c=ft(r),l=!ae(e)&&e.status!==`queued`,u=(0,Q.useMemo)(()=>n?Ci(t.turns,l):[],[n,t.turns,l]),d=lt(t)??[],f=Lo(e),p=Ti(u),m=wo(d);return{line:s,...ws(e,s,f,n?p:void 0,m),...Ts(e,a),conflicts:c,waitReferences:ls(e),agents:u,agentCounts:p,planEntries:d,planCounts:m,automations:i.data?.capabilities?.automations===!0}}function ws(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`||e.status===`cancelled`,glyph:o?(0,$.jsx)(Be,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,$.jsx)(rn,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function Ts(e,t){return{cost:t.cost&&e.costUsd!==void 0?re(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,$.jsx)(zt,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function Es(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function Ds(e){return e.length>0?e[Mo(e)]:void 0}function Os({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:o}=n,s=[...new Map([...r,...n.waitReferences].map(e=>[j(e),e])).values()];return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":ks(e,t,n,s,i),onClick:a,className:l(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,$.jsx)(Ce,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,$.jsx)(As,{run:e,identity:t,activity:n,summaryReferences:s}),i&&o?(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:o}):null,(0,$.jsx)(Ue,{"aria-hidden":!0,className:l(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!o&&`ms-auto`,i&&`rotate-180`)})]})}function ks(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=Ds(e.steps),u=l?Oo(l.status):void 0,d=l?`; step ${l.name}, ${u===`active`?`running`:u}`:``,f=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${d}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${f}`}function As({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:o}=n,s=Ds(e.steps),c=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||o.length?[{id:`chips`,priority:0,content:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(es,{run:e,references:r}),o.length>0?(0,$.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(je,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:l(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,Es(n)),children:[n.glyph,(0,$.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),s?(0,$.jsxs)(`span`,{"data-slot":`run-activity-step`,className:`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(Hs,{steps:e.steps,decorative:!0}),(0,$.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:s.name,className:`min-w-0 truncate`,children:s.name})]}):null,(0,$.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,$.jsx)($o,{items:c,lead:8})})]})}function js({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,o=Go(e);return(0,$.jsxs)(Fo,{slot:`status-row`,icon:t.glyph,title:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{"data-slot":`run-activity-status`,className:l(`truncate`,Es(t)),children:t.statusText}),i.nextCheck?(0,$.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,$.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,$.jsx)($o,{items:[{id:`chips`,priority:0,content:(0,$.jsx)(es,{run:e,references:a})}]}):void 0,open:n,onToggle:cs(e)||o?r:void 0,children:[(0,$.jsx)(us,{run:e}),o?(0,$.jsx)(Ko,{run:e}):null]})}function Ms({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=e.steps,o=W(e);if(!o&&a.length===0)return null;let s=Ds(a);return(0,$.jsxs)(Fo,{slot:`workflow`,icon:a.length>0?(0,$.jsx)(Hs,{steps:a}):(0,$.jsx)(Me,{className:`size-4`}),title:(0,$.jsxs)($.Fragment,{children:[`Workflow`,o?(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,o]}):null]}),meta:s?{drop:s.name,keep:No(Mo(a)+1,a.length,t,`step`)}:void 0,open:r,onToggle:i,children:[a.length>0?(0,$.jsx)(Ao,{steps:a}):null,(0,$.jsx)(Vs,{run:e,available:n})]})}function Ns({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,$.jsx)(Fo,{slot:`subagents`,icon:(0,$.jsx)(Ae,{className:`size-4`}),title:`Subagents`,meta:No(o.done,o.total,t),open:r,onToggle:i,children:(0,$.jsx)(xo,{agents:a,onSelect:n})})}function Ps({run:e,open:t,onToggle:n}){return e.delegation?.role===`root`?(0,$.jsx)(Ro,{run:e,open:t,onToggle:n}):null}function Fs({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,$.jsx)(Fo,{slot:`plan`,icon:(0,$.jsx)(De,{className:`size-4`}),title:`Plan`,meta:No(a.done,a.total,t),open:n,onToggle:r,children:(0,$.jsx)(To,{entries:i})})}function Is({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,$.jsx)(Fo,{slot:`usage`,icon:(0,$.jsx)(yn,{className:`size-4`}),title:`Usage & agent`,summary:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)($o,{items:c})}),open:r,onToggle:i,children:(0,$.jsx)(Bs,{run:e,tokens:o,cost:a})})}function Ls({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||Xt(e)||Xo(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,$.jsx)(Fo,{slot:`workspace`,icon:(0,$.jsx)(Fe,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)($o,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,$.jsx)(es,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,$.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(je,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,$.jsx)(Zo,{state:s}):null,(0,$.jsx)(Ye,{run:e}),e.branch?(0,$.jsx)(zs,{label:`Branch`,children:(0,$.jsx)($e,{branch:e.branch})}):null,e.worktreePath?(0,$.jsx)(zs,{label:`Worktree`,children:(0,$.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,$.jsx)(qe,{run:e,canResume:Vt(e).terminal,onResume:i})]})})}function Rs(e,t){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)({active:!1,override:!1});return(0,Q.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function zs({label:e,children:t}){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function Bs({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=ns(e);return(0,$.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,$.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,$.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Vs({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,$.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,$.jsx)(J,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:l(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,$.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Hs({steps:e,decorative:t=!1}){let n=Oo(e[Mo(e)].status),r=`size-4 shrink-0`;switch(n){case`active`:return(0,$.jsx)(Ke,{...t?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":n,className:l(r,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,$.jsx)(Oe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:l(r,`text-danger`)});case`pending`:return(0,$.jsx)(Pe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:l(r,`text-soft-foreground`)});case`done`:return(0,$.jsx)(Be,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":n,className:l(r,`text-success`)})}}var Us={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function Ws(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Gs({ask:e,run:t,onShowOrigin:n}){let r=e.context?(0,$.jsx)(qs,{text:e.context}):null;if(e.resolved)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(0,$.jsxs)(jr,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?Us[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,$.jsx)(Hi,{ask:e})]})]});let i=e.placement===`pinned`&&n?n:void 0;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,e.routedToParent?(0,$.jsx)(Js,{ask:e,onShowOrigin:i}):(0,$.jsx)(Ys,{ask:e,run:t,onShowOrigin:i})]})}function Ks({onShowOrigin:e}){return(0,$.jsx)(c,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,onClick:e,children:`Show where it was asked`})}function qs({text:e}){return(0,$.jsx)(jr,{role:`agent`,children:(0,$.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,$.jsx)(Nt,{breaks:!0,children:e})})})}function Js({ask:e,onShowOrigin:t}){return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,$.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,$.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,$.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,$.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,$.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,$.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,$.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,$.jsx)(J,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,$.jsx)(Ks,{onShowOrigin:t}):null]})}function Ys({ask:e,run:t,onShowOrigin:n}){let r=Wt(t),i=r.blockedBy!==void 0,a=e.questions,o=a.length===1&&a[0]?.options!==void 0&&a[0]?.multiSelect!==!0,[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)({}),d=(e,t)=>c(n=>({...n,[e]:t})),f=e=>u(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),p=e=>{d(e,[]),u(t=>({...t,[e]:t[e]??``}))},m=a.some((e,t)=>!e.options||l[t]!==void 0),h=a.every((e,t)=>(s[t]?.length??0)>0||!!l[t]?.trim()),g=()=>void r.send(a.map((e,t)=>Ws(e,s[t]??[],l[t])).join(`
|
|
9
|
+
`)),_=(0,Q.useRef)(null),v=(0,Q.useRef)({selections:s,otherAnswers:l,sendAll:g,canSend:!r.isPending&&!i});v.current={...v.current,selections:s,otherAnswers:l,sendAll:g,canSend:!r.isPending&&!i};let y=It(),b=y?.kind===`answer`&&y.runId===t.id&&y.askRequestId===e.id?y.answers:void 0;(0,Q.useEffect)(()=>{let n=(e,t)=>{v.current={...v.current,selections:e,otherAnswers:t},c(e),u(t)};return un.registerAskCard({runId:t.id,requestId:e.id,headers:a.map(e=>e.header),read:()=>({selections:v.current.selections,otherAnswers:v.current.otherAnswers}),apply:(e,t={reveal:!0})=>{let{selections:r,otherAnswers:i}=v.current,o={...r},s={...i};for(let t of e){let e=a[t.question];e&&(t.kind===`option`&&e.options?(o[t.question]=e.multiSelect===!0?t.labels:t.labels.slice(0,1),delete s[t.question]):t.kind===`other`&&(o[t.question]=[],s[t.question]=t.text))}n(o,s),t.reveal&&_.current?.scrollIntoView?.({block:`nearest`})},restore:e=>n(e.selections,e.otherAnswers),unanswered:()=>a.flatMap((e,t)=>(v.current.selections[t]?.length??0)>0||v.current.otherAnswers[t]?.trim()?[]:[t]),send:()=>v.current.canSend?(v.current.sendAll(),!0):!1})},[t.id,e.id]);let x=r.mode===`resume`;return(0,$.jsxs)(`div`,{ref:_,"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":r.mode,"data-voice-proposal":b?`true`:void 0,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-4 pt-3.5 pb-3.5`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.map((e,t)=>(0,$.jsx)(Zs,{question:e,disabled:r.isPending||i,selected:s[t]??[],isOther:l[t]!==void 0,otherAnswer:l[t]??``,voiceFilled:b?.some(e=>e.question===t)??!1,onSelect:n=>{i||(f(t),o&&!b?r.send(Ws(e,n)):d(t,n))},onOtherToggle:()=>{i||(l[t]===void 0?p(t):f(t))},onOtherChange:e=>u(n=>({...n,[t]:e}))},e.id??t))}),(0,$.jsx)(Xs,{oneTap:o,hasOtherAnswer:m,resuming:x,disabled:r.isPending||i||!h,questionCount:a.length,onSend:g}),r.blockedBy===`provider`?(0,$.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,$.jsx)(`span`,{children:r.reason}),(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,r.blockedBy===`no-session`?(0,$.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:r.reason}):null,r.error?(0,$.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:r.error}):null,n?(0,$.jsx)(Ks,{onShowOrigin:n}):null]})}function Xs({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return e&&!t?n?(0,$.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,$.jsxs)(`div`,{className:`mbs-3 flex items-center gap-2.5`,children:[(0,$.jsx)(c,{size:`sm`,className:`min-h-11`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),(0,$.jsx)(`span`,{"data-slot":n?`ask-resume-hint`:`ask-hint`,className:`text-[11px] text-soft-foreground`,children:n?`the session has ended — sending reopens it`:t?`${i>1?`answer each question above`:`enter your answer above`} — or type a reply below`:`${i>1?`answer each question`:`pick one or more`} — or type a reply below`})]})}function Zs({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,voiceFilled:a,onSelect:o,onOtherToggle:s,onOtherChange:u}){let d=(0,Q.useId)(),f=e.options,p=f!==void 0&&e.multiSelect===!0,m=e=>{if(!p){o([e]);return}o(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,$.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,"data-voice-filled":a?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[12px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),p?(0,$.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,$.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map(e=>{let r=n.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>m(e.label),className:l(`flex min-h-11 w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[14px] font-semibold text-foreground`,children:[p?(0,$.jsx)(`span`,{"aria-hidden":!0,className:l(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,$.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})}),(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(c,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?d:void 0,disabled:t,onClick:s,className:l(`w-full justify-start text-left`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`}),r?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsx)(`label`,{htmlFor:d,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Ge,{id:d,rows:2,value:i,disabled:t,onChange:e=>u(e.target.value),className:`bg-card`})]}):null]})]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:d,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Ge,{id:d,rows:2,value:i,disabled:t,onChange:e=>u(e.target.value),className:`bg-card`})]})]})}var Qs=2e3;function $s(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 ec(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 tc(e,t){let n=v(),r=(0,Q.useMemo)(()=>$s(t),[t]),i=(0,Q.useMemo)(()=>ec(t),[t]),a=e?.id,o=e?.status;(0,Q.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:U.runs.detail(a)}),n.invalidateQueries({queryKey:U.runs.list()})},Qs);return()=>clearTimeout(e)},[r,i,a,o,n])}function nc(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function rc({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Q.useState)(void 0),s=(0,Q.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Q.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Ia(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,nc);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}function ic(){let e=(0,Q.useRef)(null);return(0,Q.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`[data-slot="main"]`),r=t?.querySelector(`[data-slot="run-header"]`),i=t?.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${r.getBoundingClientRect().height}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function ac(){let{id:e}=n(),t=pe(e),r=tn(e),i=t.data?.status,a=(0,Q.useMemo)(()=>ot(r.visibleEvents,{activeTurn:i===`running`}),[r.visibleEvents,i]),o=(0,Q.useMemo)(()=>ot(r.currentEvents,{activeTurn:i===`running`}),[r.currentEvents,i]),s=(0,Q.useRef)(void 0),l=(0,Q.useCallback)(e=>{s.current=e},[]),{mutate:u}=oe();if((0,Q.useEffect)(()=>{t.data&&s.current!==t.data.id&&R(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),tc(t.data,r.visibleEvents),t.isPending)return(0,$.jsx)(en,{});if(t.isError){let e=t.error instanceof T&&t.error.status===404;return(0,$.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(gt,{icon:e?(0,$.jsx)(pt,{}):(0,$.jsx)(Sn,{}),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,$.jsx)(c,{asChild:!0,variant:`outline`,children:(0,$.jsx)(J,{to:`/`,children:`Back to tasks`})})})})}return r.isPending?(0,$.jsx)(en,{}):(0,$.jsx)(oc,{run:t.data,thread:a,currentThread:o,history:r,onMarkedUnread:l})}function oc({run:e,thread:n,currentThread:r=n,history:i,onMarkedUnread:a}){mt();let o=I(),s=(0,Q.useRef)(null),c=It(),l=c?.kind===`tell`&&c.runId===e.id;(0,Q.useEffect)(()=>un.registerComposer({runId:e.id,getDraft:()=>s.current?.getDraft()??``,setDraft:e=>s.current?.setDraft(e)??!1,clearVoiceDraft:e=>s.current?.clearVoiceDraft(e)??!0,submit:()=>s.current?.submit()??!1}),[e.id]);let{pendingAsk:u,transcriptAsk:d,pendingAskId:f,historyLoading:p}=sc(i,r);(0,Q.useEffect)(()=>{p||un.syncPendingAsk(e.id,f)},[e.id,f,p]),(0,Q.useEffect)(()=>()=>un.leaveTask(e.id),[e.id]);let m=_(e),h=at(e.status,e.error),g=ae(e),v=!g&&e.status!==`queued`,y=e.status===`queued`,b=pi(e),x=bo(e),S=po(e.id),C=d||ee(e),{hasContinuation:w,continuable:T}=cc(g,y,b),[E,D]=(0,Q.useState)(void 0),[O,k]=(0,Q.useState)(e.id);O!==e.id&&(k(e.id),D(void 0));let A=(0,Q.useMemo)(()=>E===void 0?void 0:Oi(r.turns,E,v),[r.turns,E,v]),te=(0,Q.useMemo)(()=>E===void 0?[]:ki(r.turns,E),[r.turns,E]),ne=M(e.id),j=Wt(e),{providerBlocked:N,providerReason:P}=lc(g,Yt(e),w,b),{mutateAsync:L}=ce(e.id),{mutateAsync:R}=se(e.id),{mutateAsync:re}=_e(e.id),B=(0,Q.useMemo)(()=>y?{onEditTask:async e=>{await L({task:e})},onEditMessage:(e,t)=>R({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>re(e).then(()=>void 0)}:void 0,[y,L,R,re]),ie=p?void 0:f??null,oe=(0,Q.useMemo)(()=>Fa(e,n,r,ie),[e,n,r,ie]),V=(0,Q.useMemo)(()=>za(oe,e.id),[oe,e.id]),H=e.delegation?.role===`root`||e.delegation?.role===`worker`,le=F(e.id,{enabled:H}),ue=(0,Q.useMemo)(()=>Ki(e,o.data,le.data?.titles),[e,o.data,le.data]),de=(0,Q.useMemo)(()=>Gi(e,o.data),[e,o.data]),fe=(0,Q.useCallback)(t=>(0,$.jsx)(Ii,{permission:t,runId:e.id,sessionOpen:g}),[e.id,g]),pe=(0,Q.useMemo)(()=>{if(B===void 0)return;let t={task:{onEdit:B.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>B.onEditMessage(n.id,e),onRemove:()=>B.onRemoveMessage(n.id)};return t},[B,e.queuedMessages]),me=ge(e,z()),{search:U}=t(),he=sr(U,V.length),W=Ea(`${e.id}:main`,{onLoadOlder:i?.hasOlder?i.loadOlder:void 0,onJumpToLatest:i?.jumpToLatest,rowKeys:V.map(({key:e})=>e)}),{pinnedAsk:ve,pendingQuestions:ye}=uc(oe),G=rc({pendingAskId:f,askSeq:i?u?.seq:void 0,rows:V,history:i,jumpToRow:W.jumpToRow}),xe=(0,Q.useRef)(f);p||(xe.current=f);let Se=(0,Q.useRef)({rows:V,jumpToRow:W.jumpToRow,reveal:G.reveal});Se.current={rows:V,jumpToRow:W.jumpToRow,reveal:G.reveal};let Ce=(0,Q.useCallback)(t=>t.placement===`origin`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,$.jsx)(qs,{text:t.context}):null,t.resolved?null:(0,$.jsx)(Sa,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=Se.current,r=Ia(e,t.id,`pinned`);r&&n(r.key,r.index,e=>ya(e))}})]}):(0,$.jsx)(Gs,{ask:t,run:e,onShowOrigin:()=>Se.current.reveal()}),[e]);return be(W.restickIfStuck),(0,$.jsxs)(`div`,{ref:ic(),"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,$.jsx)(tt,{run:e,onMarkedUnread:()=>a?.(e.id)}),(0,$.jsx)(dc,{run:e,thread:n,history:i,footer:h,issueUrl:me,sections:oe,renderAsk:Ce,renderPermission:fe,messageActions:pe,scroll:W,mode:he,taskTitles:ue,recipientBackends:de}),(0,$.jsx)(yo,{status:e.status}),(0,$.jsx)(Ja,{runId:e.id,renderAsk:Ce,renderPermission:fe,agent:A,entries:te,taskTitles:ue,recipientBackends:de,onClose:()=>D(void 0)}),(0,$.jsx)(fc,{run:e,thread:n,currentThread:r,currentComplete:i?.currentComplete??!0,scroll:W,pendingQuestions:ye,onJump:()=>{let e=ye>0?ve?.id:void 0;W.jumpToLatest(e===void 0?void 0:ba(e,()=>xe.current===e))},onOpenWorker:D,sessionOpen:g,attention:m,queued:y,continuable:T,continueAction:b,composerRef:s,tellProposed:l,stopAction:x,finishAction:S,needsAnswer:C,sendMessage:ne,reply:j,providerBlocked:N,providerReason:P}),(0,$.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function sc(e,t){let n=e?it(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function cc(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function lc(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function uc(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function dc({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:a,renderAsk:s,renderPermission:c,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,$.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 md:gap-3.5 md:px-16 md:py-5`,children:[n?(0,$.jsx)(gc,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,$.jsx)(Ba,{runId:e.id,viewId:`main`,sections:a,mode:`document`,renderAsk:s,renderPermission:c,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,$.jsx)(_c,{run:e}):(0,$.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,$.jsx)(Hr,{}):null,r&&r.state===`closed`?(0,$.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:l(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,o(he(e))?(0,$.jsx)(`a`,{"data-slot":`pr-link`,href:he(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,o(i)?(0,$.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,$.jsx)(mo,{run:e}):null]})}function fc({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,composerRef:p,tellProposed:m,stopAction:h,finishAction:g,needsAnswer:_,sendMessage:v,reply:y,providerBlocked:b,providerReason:x}){return(0,$.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible?(0,$.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,$.jsx)(Aa,{pendingQuestions:a,onJump:o})}):null,(0,$.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,$.jsx)(xs,{run:e,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},e.id),(0,$.jsx)(wn,{run:e}),e.status===`waiting`&&c?(0,$.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,$.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&f.startsNewConversation?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,$.jsx)(pc,{run:e,thread:t,composerRef:p,tellProposed:m,stopAction:h,finishAction:g,attention:l,needsAnswer:_,continuable:d,continueAction:f,queued:u,sendMessage:v,reply:y,providerBlocked:b,providerReason:x,sessionOpen:c})]})]})}function pc({run:e,thread:t,composerRef:n,tellProposed:r,stopAction:i,finishAction:a,attention:o,needsAnswer:s,continuable:c,continueAction:l,queued:u,sendMessage:d,reply:f,providerBlocked:p,providerReason:m,sessionOpen:h}){return(0,$.jsx)(Pt,{ref:n,voiceProposal:r,onStop:Vt(e).cancel?i.stop:void 0,onFinish:pn(e)?()=>a.mutateAsync().catch(()=>void 0):void 0,finishing:a.isPending,secondaryAction:Kt(e)?(0,$.jsx)(Xe,{run:e,compactOnMobile:!0}):void 0,stopOnEmpty:mc(e,o,s),stopping:i.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:c?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:c?l.pills:void 0,onSubmit:c?(e,t)=>l.continueWith(e,t):u?(e,t)=>d.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await f.send(e,t);if(n!==void 0)throw Error(n)},disabled:p||!h&&!u&&!c,disabledReason:p?m:`Session closed — no session to resume.`,footerEnd:p&&!l.providerPending?(0,$.jsx)(J,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:c&&!s,emptySubmitLabel:c&&!s?`Continue`:void 0,placeholder:hc(e,u,c),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>ct(t)})}function mc(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function hc(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function gc({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,$.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,$.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,$.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,$.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,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function _c({run:e}){let t=Ft(I().data??[],e.id);return(0,$.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,$.jsx)(rn,{tone:`neutral`,shape:`ring`}),(0,$.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,$.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{ac as TaskThreadRoute};
|