cezarion 0.19.0-dev.8754 → 0.19.0-dev.8773
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/web/dist/assets/{accounts-section-CqJiDoKE.js → accounts-section-CIgJyKva.js} +1 -1
- package/web/dist/assets/activity-motion-D_URV8Di.js +1 -0
- package/web/dist/assets/{activity-route-DOcAtf9i.js → activity-route-Do33FDky.js} +1 -1
- package/web/dist/assets/{agent-config-section-B6lCNWlM.js → agent-config-section-BMfcQCbi.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-DHwkBXuz.js → agent-defaults-section-Co96ec0d.js} +1 -1
- package/web/dist/assets/{appearance-DEK8ezEQ.js → appearance-DkSPOcn0.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-BT4e_k9f.js → archive-on-merge-field-Bzuu6JUq.js} +1 -1
- package/web/dist/assets/attention-wzzAdp4t.js +1 -0
- package/web/dist/assets/{automations-route-BXoyFkhx.js → automations-route-YNUMP0mD.js} +1 -1
- package/web/dist/assets/{commit-list-DjhAXNOu.js → commit-list-0tp9mxng.js} +1 -1
- package/web/dist/assets/{diff-eQ6oM_Ti.js → diff-6Tr1DKFm.js} +2 -2
- package/web/dist/assets/{diff-controls-CYiGOTLb.js → diff-controls-Uj68AWl-.js} +1 -1
- package/web/dist/assets/{diff-view-kgRbXZ06.js → diff-view-DMO64pR1.js} +1 -1
- package/web/dist/assets/{file-preview-D5Mc18GN.js → file-preview-BqaVkwcr.js} +1 -1
- package/web/dist/assets/{folder-browser-BJ3aXo9k.js → folder-browser-BzYB6BT2.js} +1 -1
- package/web/dist/assets/{git-toolbar-BYCPpYE3.js → git-toolbar-D513sAp1.js} +1 -1
- package/web/dist/assets/{github-B0s8RT3R.js → github-C5qUGzPx.js} +1 -1
- package/web/dist/assets/{global-activity-route-DTNGyGoC.js → global-activity-route-DRZlGf9a.js} +2 -2
- package/web/dist/assets/{index-DwDvloUQ.js → index-CIAFRUw6.js} +5 -5
- package/web/dist/assets/index-DclFk8VO.css +1 -0
- package/web/dist/assets/{label-CH-a6Jyv.js → label-CgZJ4LAh.js} +1 -1
- package/web/dist/assets/{markdown-jbBslIIT.js → markdown-B8uIJFot.js} +1 -1
- package/web/dist/assets/{notifications-section-C1aUjb3n.js → notifications-section-DcR7A7aZ.js} +1 -1
- package/web/dist/assets/{open-in-menu-CML2QKil.js → open-in-menu-C09BLcfQ.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-ChoZcfZF.js → preview-pane-connected-BOptVmB7.js} +1 -1
- package/web/dist/assets/{project-location-CZNz3wYW.js → project-location-CVu4xirj.js} +1 -1
- package/web/dist/assets/{project-router-BvBqllk2.js → project-router-BypHPat0.js} +1 -1
- package/web/dist/assets/{projects-section-Dlz2V18-.js → projects-section-ByjMveO2.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-KYeZJ5it.js → prompt-templates-section-mztZbjR2.js} +1 -1
- package/web/dist/assets/{queries-CYWRnyM5.js → queries-EvENG6TN.js} +1 -1
- package/web/dist/assets/{reference-chip-BdikRjql.js → reference-chip-BLHAGMsc.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-CXNs2m11.js → remote-settings-notice-_lT2fFKo.js} +1 -1
- package/web/dist/assets/{repo-git-xHDvySA0.js → repo-git-muNCGIF4.js} +1 -1
- package/web/dist/assets/{report-reader-pkkocX-w.js → report-reader-CJTciXLf.js} +1 -1
- package/web/dist/assets/{report-selection-D2RvkiGX.js → report-selection-CXF3VYjA.js} +1 -1
- package/web/dist/assets/{reports-DE76L7r9.js → reports-Ddq_ls0m.js} +1 -1
- package/web/dist/assets/{resources-section-CsyiFux8.js → resources-section-C5ssAmKn.js} +1 -1
- package/web/dist/assets/review-panel-wst8aLz4.js +11 -0
- package/web/dist/assets/{run-detail-refresh-BNI7eMgG.js → run-detail-refresh-DXnE6Lc2.js} +1 -1
- package/web/dist/assets/{run-header-kGdJVGJm.js → run-header-bZAJ80iC.js} +1 -1
- package/web/dist/assets/{select-BH4KzC9I.js → select-B05NBo-9.js} +1 -1
- package/web/dist/assets/{session-context-section-CQaaWpJ6.js → session-context-section-BzflGStM.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-Cv_4wnFI.js → settings-agent-picker-BjvjnUs4.js} +1 -1
- package/web/dist/assets/{settings-shell-CG6eFmsm.js → settings-shell-vD5R1O7D.js} +1 -1
- package/web/dist/assets/{sidebar-section-CcO5Q0as.js → sidebar-section-BZLTjCJ6.js} +1 -1
- package/web/dist/assets/{skills-C2TtFkX0.js → skills-BNbkK6g-.js} +1 -1
- package/web/dist/assets/{tab-link-B0pNjKxZ.js → tab-link-Bjo_gEiX.js} +1 -1
- package/web/dist/assets/{task-changes-CS7sYCut.js → task-changes-BbRB1M0L.js} +1 -1
- package/web/dist/assets/{task-commits-B0HDJ95C.js → task-commits-_hMQ47BK.js} +1 -1
- package/web/dist/assets/{task-file-scope-vwEp2s7o.js → task-file-scope-CGgYP4rR.js} +1 -1
- package/web/dist/assets/{task-files-kehKktnF.js → task-files-Cce3Lghe.js} +1 -1
- package/web/dist/assets/{task-github-item-BNc2Oyvq.js → task-github-item-C25rYc6W.js} +1 -1
- package/web/dist/assets/{task-groups-lh9gz7TP.js → task-groups-nvRvmVHf.js} +1 -1
- package/web/dist/assets/task-thread-Cqs9j6f8.js +2 -0
- package/web/dist/assets/{tasks-table-k18AuMR5.js → tasks-table-DGBiE6ux.js} +1 -1
- package/web/dist/assets/{thread-state-B_UW2DqR.js → thread-state-C4f5H6np.js} +1 -1
- package/web/dist/assets/{toaster-B0kvcFif.js → toaster-Cer2NOxt.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-DzPA14Gk.js → use-hand-to-agent-state-Dnb5uNM1.js} +1 -1
- package/web/dist/assets/{workflows-CKtzm8xW.js → workflows-Cl1NhrpU.js} +1 -1
- package/web/dist/assets/{workspace-tools-Br4fSGhx.js → workspace-tools-DJcDHrF-.js} +1 -1
- package/web/dist/assets/{worktrees-section-TGAZ2n-T.js → worktrees-section-DRG2wiAo.js} +1 -1
- package/web/dist/index.html +14 -14
- package/web/dist/assets/activity-motion-BrtMWCAJ.js +0 -1
- package/web/dist/assets/attention-CGsbqL2t.js +0 -1
- package/web/dist/assets/index-D9L-uSh4.css +0 -1
- package/web/dist/assets/review-panel-CLsVpcPr.js +0 -11
- package/web/dist/assets/task-thread-BRpUqs1N.js +0 -2
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{$ as o,$t as s,Ct as c,P as l,Wt as u,Xt as d,Yt as f,_ as p,dn as m,lt as h,rn as g,un as _}from"./queries-CYWRnyM5.js";import{Fn as v,ct as y,dr as b,hi as x,n as S,ot as C,pt as w,rr as T}from"./toaster-B0kvcFif.js";import{f as E,n as D,p as O}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{B as k,F as ee,K as te,X as ne,at as A,c as re,dt as j,ft as ie,s as ae,u as M,v as oe}from"./design-icons-CzEoMH9c.js";import{t as N}from"./createLucideIcon-BHp8sXmF.js";import{t as se}from"./check-OP-CVgZG.js";import{t as ce}from"./chevron-right-BENZ-1ZN.js";import{t as le}from"./external-link-BE6y205O.js";import{t as P}from"./eye-B8okNWXU.js";import{n as ue}from"./smartphone-Lr8Ug2z_.js";import{t as F}from"./loader-circle-CPBhhDbB.js";import{t as de}from"./message-square-B-MD-8rD.js";import{n as fe,t as pe}from"./tool-display-B9NN44oU.js";import{t as me}from"./square-terminal-B6RYYieR.js";import{t as I}from"./button-B7MKxYjT.js";import{n as L,r as R,t as z}from"./collapsible-BEV4FO-1.js";import{t as B}from"./project-router-BvBqllk2.js";import{O as he}from"./task-groups-lh9gz7TP.js";import{a as ge,c as _e,i as ve,l as ye,o as be,s as xe,t as Se}from"./report-selection-D2RvkiGX.js";import{n as Ce}from"./centered-state-V15AR_qo.js";import{F as we,Qt as Te,Y as Ee,_n as De,ar as V,dr as Oe,en as ke,er as Ae,fn as je,ln as Me,nn as Ne}from"./index-DwDvloUQ.js";import{i as Pe,r as Fe}from"./highlighter-DvLzHjjY.js";import{t as Ie}from"./zoomable-image-6RTKhLGE.js";import{i as Le,r as Re,t as H}from"./markdown-jbBslIIT.js";import{r as ze}from"./html-report-BX3msvci.js";import{t as U}from"./textarea-vJt9undk.js";import{t as Be}from"./task-file-scope-vwEp2s7o.js";import{t as Ve}from"./report-title-D4Mbu2Er.js";var He=N(`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`}]]),Ue=N(`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`}]]),We=N(`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`}]]),Ge=N(`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`}]]),Ke=N(`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`}]]),qe=N(`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`}]]),W=e(t(),1),G=n();function Je(e,t){if(e.length===1)return[t.replace(RegExp(`^${Ye(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 Ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Xe(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]:[]}var Ze=`
|
|
2
|
-
|
|
3
|
-
Additional comments:
|
|
4
|
-
`;function Qe(e){let t=e.indexOf(Ze);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function $e({ask:e}){let t=e.answer===void 0?void 0:Qe(e.answer),n=t===void 0?void 0:Je(e.questions,t.body);return(0,G.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Xe(t,i),o=i!==void 0&&a.length===0;return(0,G.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,G.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,G.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,G.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,G.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,G.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,G.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,G.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,G.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,G.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,G.jsx)(K,{text:i}):null]})]}):i===void 0?null:(0,G.jsx)(K,{text:i})]},t.id??r)}),n&&t?.comment?(0,G.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,G.jsx)(K,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,G.jsx)(K,{text:e.answer}):null]})}function K({text:e}){return(0,G.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function q(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function et(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function tt({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:o,showContextButtonRef:s,onOpenContext:c,onShowOrigin:l}){return(0,G.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,G.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,G.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[o?(0,G.jsxs)(I,{ref:s,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,G.jsx)(V,{"aria-hidden":`true`,className:`size-3.5`}),`Show context`]}):l?(0,G.jsx)(ct,{onShowOrigin:l}):null,r?(0,G.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,G.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":t===`options`,onClick:()=>n(`options`),className:a(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,G.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":t===`reply`,onClick:()=>n(`reply`),className:a(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]}):null]})]})}function nt({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:o}){let s=e.length;return(0,G.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let s=t===i,c=q(i,n,r);return(0,G.jsxs)(`button`,{type:`button`,"aria-current":s?`step`:void 0,onClick:()=>o(i),className:a(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,s?`border-accent-strong bg-accent-strong/15 text-foreground`:c?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,G.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:c?(0,G.jsx)(se,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,G.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,G.jsxs)(`button`,{type:`button`,"aria-current":t===s?`step`:void 0,onClick:()=>o(s),className:a(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===s?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,G.jsx)(Ke,{"aria-hidden":`true`,className:`size-3`}),(0,G.jsx)(`span`,{children:`Comment`})]})]})}function rt({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:o,onJumpToQuestion:s}){let c=(0,W.useId)();return(0,G.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,G.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=q(r,t,n);return(0,G.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>s(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,G.jsx)(`span`,{className:a(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:et(r,t,n)})]},e.id??r)})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:c,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,G.jsx)(U,{id:c,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>o(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function it({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,W.useId)();return r?(0,G.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,G.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,G.jsx)(U,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function at({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:o,disabled:s,onBack:c,onNext:l,onOpenComment:u,onSend:d,questions:f,selections:p,otherAnswers:m,stopControl:h}){let g=e===t-1,_=e===t,v=o?`Send answer & reopen`:`Send answer`;return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,G.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,G.jsx)(Oe,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,G.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,i=q(n,p,m);return(0,G.jsx)(`span`,{className:a(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,G.jsx)(`span`,{className:a(`size-2 rounded-full motion-safe:transition-colors`,_?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,G.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),o?(0,G.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,(0,G.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,!g&&!_?(0,G.jsxs)(I,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:l,children:[`Next`,(0,G.jsx)(ce,{"aria-hidden":`true`,className:`size-4`})]}):null,g?(0,G.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:u,children:i?`Edit comment`:`+ Comment`}):null,g||_||r?(0,G.jsx)(I,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:s||!r,onClick:d,children:v}):null]})]})}function ot({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,G.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 min-w-11 px-2 text-xs text-muted-foreground hover:text-foreground md:min-h-8 md:min-w-0`,onClick:s,children:[(0,G.jsx)(Ke,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,(0,G.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,G.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,G.jsx)(I,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function st({blockedBy:e,reason:t,error:n}){return(0,G.jsxs)(G.Fragment,{children:[t?(0,G.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,G.jsx)(B,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,G.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function ct({onShowOrigin:e,className:t}){return(0,G.jsx)(I,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:a(`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,t),children:`Show where it was asked`})}function lt({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,W.useRef)(!1);return(0,G.jsx)(ve,{open:e,onOpenChange:t,children:(0,G.jsxs)(be,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,G.jsxs)(_e,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,G.jsx)(ye,{children:`Question context`}),(0,G.jsx)(xe,{children:`Your selections and drafts stay intact while you read.`}),(0,G.jsx)(ge,{asChild:!0,children:(0,G.jsx)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2 size-11 md:size-9`,children:(0,G.jsx)(ie,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,G.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,G.jsx)(Be,{runId:n,children:(0,G.jsx)(H,{breaks:!0,children:r})})}),i?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,G.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,className:`min-h-11 md:min-h-8`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var dt=/^[A-Za-z0-9_./:=+,@%-]+$/;function ft(e){return e.replaceAll(`'`,`'\\''`)}function pt(e){return e===``?`''`:dt.test(e)?e:`\u0027${ft(e)}\u0027`}function mt(e){if(!ut(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(pt).join(` `)}}function ht(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 gt(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function _t(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function J(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function vt(e){let t=ht(gt(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))J(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]){J(e[2])&&i.push({label:_t(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:_t(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&J(t)&&i.push({label:t,href:t})}return i}var yt=(0,W.createContext)(void 0),bt=(0,W.createContext)(void 0);function xt(e,t){let n=new Map;for(let r of vt(e)){let e=Le(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 St(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Ct({text:e,messageKey:t}){let n=(0,W.useContext)(Re),r=(0,W.useContext)(bt),i=t??r;if(!n||i===void 0)return null;let a=xt(e,n);return a.length===0?null:(0,G.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,G.jsx)(wt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function wt({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,W.useContext)(yt),s=(0,W.useContext)(Se);(0,W.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=l(r,n),u=E(),d=O();if(c.isError)return(0,G.jsx)(D,{id:St(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:u.pathname+u.search},children:i});let f=c.data?.artifact;if(f&&!ze(f.name))return null;let p=new URLSearchParams(u.search);p.set(`report`,n),p.set(`card`,t);let m=new URLSearchParams(u.search).has(`report`)?u.state:null,h=new URLSearchParams(u.search);h.delete(`report`),h.delete(`card`);let g=`${u.pathname}${h.size?`?${h}`:``}`,_=window.navigation,v={reportCardEntry:!0,reportReturnTo:m?.reportReturnTo??g,reportReturnKey:m?.reportReturnKey??_?.currentEntry?.key,reportScrollTop:m?.reportScrollTop},y={pathname:u.pathname,search:`?${p}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,G.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,G.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:f?Ve(f):i}),(0,G.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,G.jsx)(D,{id:St(t,n),to:y,state:v,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=v.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;d(y,{state:{...v,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Tt={message:!0,reasoning:!0,tool:!0,hook:!0};function Et(e){return Object.hasOwn(Tt,e)&&Tt[e]}var Dt=e=>e.kind===`tool`,Ot=e=>e.kind===`conversation`,kt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,At=(e,t,n)=>`${e} ${e===1?t:n}`;function jt(e,t){let n=[];return e>0&&n.push(At(e,`file`,`files`)),t>0&&n.push(At(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Mt(e){return`${e} earlier tool call${e===1?``:`s`}`}var Nt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function Pt(e){for(let t of Nt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var Ft=new WeakMap;function It(e){let t=Ft.get(e);if(t)return t;let n=Lt(e);return Ft.set(e,n),n}function Lt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(Dt).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Et(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:jt(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 Rt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Ot(e)){s(),c.push(e);continue}l(),Dt(e)&&kt(e)&&!r.has(e.id)?o.push(e):(s(),Dt(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 Rt(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 zt=new Map,Bt=(0,W.createContext)(null);function Vt(){return(0,W.useContext)(Bt)}function Ht({runId:e,children:t}){let n=(0,W.useMemo)(()=>({get:t=>zt.get(e)?.get(t),set:(t,n)=>{let r=zt.get(e)??new Map;r.set(t,n),zt.set(e,r)}}),[e]);return(0,G.jsx)(Bt.Provider,{value:n,children:t})}function Ut(e){return e.scrollTop<Math.max(600,e.clientHeight)}function Wt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Gt(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 Kt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function qt(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Jt=new Map;function Yt(e,t){Jt.set(e,t)}function Xt(e){return Jt.get(e)}var Zt=new Map;function Qt(e,t){Zt.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function $t(e){return Zt.get(e)}function en(e,t,n){let r=Zt.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 tn=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),nn=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),rn=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),an=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),on=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:tn.format(t)}function sn(e){let t=Y(e);return t===void 0?void 0:nn.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function cn(e){let t=Y(e);return t===void 0?void 0:Z(t)}function ln(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?rn:an).format(n)}function un(e,t){let n=Y(e),r=Y(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 dn({ts:e}){let t=X(e);return t===void 0?null:(0,G.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:sn(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function fn({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=un(e,t);return(0,G.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,G.jsx)(`time`,{dateTime:t,title:sn(t),children:n}),r===void 0?null:(0,G.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function pn({ts:e}){let t=ln(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=on.format(n);return(0,G.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-xs font-medium text-soft-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,G.jsx)(`time`,{dateTime:cn(e),title:r,children:t}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var mn={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function hn({note:e}){return e.icon===`handoff`?(0,G.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,G.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,G.jsx)(Ae,{className:`size-3`})}),(0,G.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,G.jsxs)(z,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,G.jsxs)(`div`,{className:a(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,G.jsxs)(R,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,G.jsx)(M,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,G.jsx)(L,{children:(0,G.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,G.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,G.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[mn[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,G.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:a(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var gn={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 Q({role:e,children:t,className:n,ts:r,headerActions:i,...o}){let s=gn[e],c=r===void 0?void 0:X(r);return(0,G.jsxs)(`article`,{...o,"data-role":e,"aria-label":s.speaker,className:a(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,G.jsxs)(`p`,{className:a(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,G.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,G.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,G.jsx)(de,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,G.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,G.jsx)(dn,{ts:r})})]}),(0,G.jsx)(`div`,{className:a(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var _n=[],vn=(0,W.memo)(function({text:e,imageCount:t=0,images:n=_n,ts:i,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(e),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(),y=()=>{m(e),v(void 0),f(!0)},x=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},S=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,G.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,G.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(),x())},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,G.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,G.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,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),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,G.jsx)(F,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,G.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,G.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,G.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:[a?(0,G.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,G.jsx)(qe,{className:`size-3.5`})}):null,o?(0,G.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void S(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,G.jsx)(A,{className:`size-3.5`})}):null]}):null,_?(0,G.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,G.jsx)(H,{breaks:!0,children:e}),n.length>0?(0,G.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>b(e.split(`/`).pop()??``)?(0,G.jsx)(Ie,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,G.jsxs)(`a`,{href:r(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,G.jsx)(te,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,G.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),yn=`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`,bn=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function xn(e,t){let n=e.cloneNode(!0);n.querySelectorAll(bn).forEach(e=>e.remove());let r=vt(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||!J(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 Sn(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=xn(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Cn=(0,W.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,W.useRef)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Sn(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,G.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,G.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:yn,children:[(0,G.jsx)(oe,{className:`size-3.5`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:yn,children:[(0,G.jsx)(V,{className:`size-3.5`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,G.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,G.jsx)(`div`,{ref:r,children:(0,G.jsx)(H,{breaks:!0,children:e})}),(0,G.jsx)(Ct,{text:e,messageKey:n})]})});function wn({incident:e}){let t=g().data;if(!t)return null;let n=d(t,e.provider);return(0,G.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,G.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,G.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,G.jsx)(B,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var Tn=(0,W.memo)(function({text:e}){let t=(0,W.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
5
|
-
`,1)[0]??``,r=n.length<e.length;return(0,G.jsxs)(z,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,G.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,G.jsx)(M,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,G.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,G.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,G.jsx)(H,{inline:!0,children:n})}),r?(0,G.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,G.jsx)(R,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,G.jsx)(H,{children:e})})})]})});function En(){return(0,G.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,G.jsx)(F,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,G.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Dn={read:V,edit:qe,delete:A,move:Ge,search:ne,execute:me,think:Ue,fetch:ue,task:ae,plan:k,other:j},On=e=>e.split(`
|
|
6
|
-
`).length;function kn({text:e,streaming:t}){let[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null),o=(0,W.useRef)(!0);(0,W.useEffect)(()=>{let e=i.current;t&&e&&o.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=On(e),c=!t&&!n&&s>12;return(0,G.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`div`,{ref:i,onScroll:t?e=>{o.current=Kt(e.currentTarget)}:void 0,className:a(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,G.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,G.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&&s>12?(0,G.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-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function An({diffs:e}){return(0,G.jsx)(G.Fragment,{children:e.map((e,t)=>(0,G.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,G.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...jn(e.oldText).map((e,t)=>(0,G.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...jn(e.newText).map((e,t)=>(0,G.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
7
|
-
`).map((e,t)=>(0,G.jsx)(Mn,{text:e},t))})]},`${e.path}:${t}`))})}function jn(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
8
|
-
`)}function Mn({text:e}){return(0,G.jsx)(`span`,{className:a(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function Nn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function Pn(e){let t=e.status===`running`||e.status===`pending`,n=Pt(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`?mt(e.input):fe(e.name).toolKind===e.toolKind?pe(e.name,e.input):void 0)??i,Icon:Dn[e.toolKind]??j}}function Fn(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 In({item:e,busy:t}){return(0,G.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,G.jsx)(F,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,G.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,G.jsx)(`span`,{"data-slot":`tool-exit`,className:a(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function Ln({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,G.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,G.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,G.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,G.jsx)(An,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,G.jsx)(kn,{text:e.output,streaming:n}):null,r.length>0?(0,G.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 Rn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=Vt(),[o,s]=(0,W.useState)(()=>n===void 0?null:i?.get(n)??null),c=e=>{n!==void 0&&i?.set(n,e),s(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=Pn(e),m=Fn(e,t.length),h=f!==void 0||m,g=h&&(o??(m&&Nn(e)));return(0,G.jsxs)(z,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:c,className:a(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,G.jsxs)(R,{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,G.jsx)(M,{"aria-hidden":!0,className:a(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,G.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:a(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,G.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,G.jsx)(In,{item:e,busy:l})]}),(0,G.jsx)(L,{children:(0,G.jsx)(Ln,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function zn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function Bn({item:e,cacheKey:t}){let n=Vt(),[r,i]=(0,W.useState)(()=>t===void 0?!1:n?.get(t)??!1),o=e=>{t!==void 0&&n?.set(t,e),i(e)},s=e.status!==`completed`,c=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=zn(e);return(0,G.jsxs)(z,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:o,className:a(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,G.jsxs)(R,{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,G.jsx)(M,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,G.jsx)(He,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,G.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,G.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,G.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,G.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,G.jsx)(L,{children:(0,G.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,G.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:a(`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,G.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,G.jsxs)(z,{className:`border-t border-border`,children:[(0,G.jsxs)(R,{"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,G.jsx)(M,{"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,G.jsxs)(L,{children:[e.stdout?(0,G.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,G.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 Vn({group:e,scope:t}){return(0,G.jsxs)(z,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,G.jsxs)(R,{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,G.jsx)(M,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,G.jsx)(Rn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Hn({count:e,children:t}){return(0,G.jsxs)(z,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,G.jsxs)(R,{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,G.jsx)(M,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Mt(e)]}),(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Un({image:e}){return(0,G.jsx)(Ie,{"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`})}var Wn={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 Gn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Kn(e,t,n,r=``){let i=e.map((e,r)=>Gn(e,t[r]??[],n[r])).join(`
|
|
9
|
-
`),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function qn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`}){let h=m===`transcript`&&e.context?(0,G.jsx)(Jn,{text:e.context}):null;if(e.resolved)return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,G.jsx)(Jn,{text:e.context}):null,(0,G.jsxs)(Q,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,G.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?Wn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,G.jsx)($e,{ask:e})]})]});let g=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,G.jsx)(Yn,{ask:e,runId:t.id,surface:m,onShowOrigin:g})]}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,G.jsx)($n,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:g,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p})]})}function Jn({text:e}){return(0,G.jsx)(Q,{role:`agent`,children:(0,G.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,G.jsx)(H,{breaks:!0,children:e})})})}function Yn({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,G.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,G.jsx)(I,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,G.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,G.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,G.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,G.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,G.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,G.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,G.jsxs)(`li`,{className:`break-words`,children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,G.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,G.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,G.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,G.jsx)(B,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,G.jsx)(ct,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,G.jsx)(lt,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function Xn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,W.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,W.useState)(0),[h,g]=(0,W.useState)({}),[_,v]=(0,W.useState)({}),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(``),[T,E]=(0,W.useState)(!1),D=s&&p===c,O=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;je(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let k=(e,t)=>g(n=>({...n,[e]:t})),ee=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),te=e=>{k(e,[]),v(t=>({...t,[e]:t[e]??``}))},ne=o.some((e,t)=>!e.options||_[t]!==void 0),A=o.filter((e,t)=>q(t,h,_)).length,re=A===o.length,j=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:E,onCommentStep:D,oneTap:O,setQuestion:k,clearOtherAnswer:ee,selectOther:te,hasOtherAnswer:ne,answeredCount:A,allAnswered:re,deliver:j,sendAll:()=>void j(Kn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&j(e).then(e=>{e===void 0&&w(``)})}}}function Zn({state:e,renderFreeTextReply:t}){let n=(0,W.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,G.jsx)(it,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,G.jsx)(rt,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(rr,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(Gn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,G.jsxs)(`div`,{className:`pt-1`,children:[(0,G.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,G.jsx)(U,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function Qn({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e))})};return(0,G.jsxs)(G.Fragment,{children:[e?(0,G.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,G.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function $n(e){return e.delivery===void 0?(0,G.jsx)(er,{...e}):(0,G.jsx)(tr,{...e,delivery:e.delivery})}function er(e){let t=Te(e.run,e.projectId);return(0,G.jsx)(tr,{...e,delivery:t})}function tr({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:o,onStop:s,stopping:c,onFinish:l,finishing:u,controlledMode:d,onModeChange:f,hideReplyBody:p,delivery:m}){let h=Xn(e,m,d,f,i),[g,_]=(0,W.useState)(void 0),v=(0,W.useRef)(null),y=h.delivery.mode===`resume`,b=n===`decision-zone`||o!==void 0,x=n===`decision-zone`&&!!e.context,S=h.additionalComment.trim()!==``,C=h.mode===`reply`&&p,w=(0,G.jsx)(Qn,{onFinish:l,finishing:u,onStop:s,stopping:c,onActionError:_});return(0,G.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":h.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":h.delivery.mode,className:a(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,C&&`rounded-b-none border-b-0`),children:[(0,G.jsx)(tt,{stepped:h.stepped,mode:h.mode,onModeChange:h.setMode,showModeSwitch:b,stepLabel:h.onCommentStep?`Comment (optional)`:`${h.stepIndex+1} of ${h.questions.length}`,hasSheetContext:x,showContextButtonRef:v,onOpenContext:()=>h.setContextOpen(!0),onShowOrigin:x?void 0:r}),h.stepped&&h.mode===`options`?(0,G.jsx)(nt,{questions:h.questions,stepIndex:h.stepIndex,selections:h.selections,otherAnswers:h.otherAnswers,hasComment:S,onSelectStep:h.setStepIndex}):null,C?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,G.jsx)(Zn,{state:h,renderFreeTextReply:o})}),(0,G.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,G.jsx)(nr,{state:h,hasComment:S,resuming:y,hasCustomReply:o!==void 0,stopControl:w}),(0,G.jsx)(st,{blockedBy:h.delivery.blockedBy,reason:h.delivery.reason,error:h.delivery.error??g})]})]}),x&&e.context?(0,G.jsx)(lt,{open:h.contextOpen,onOpenChange:h.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:v}):null]})}function nr({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i}){return e.mode===`reply`?r?null:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,G.jsx)(I,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,G.jsx)(at,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i}):(0,G.jsx)(ot,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i})}function rr({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:o,onOtherToggle:s,onOtherChange:c}){let l=(0,W.useId)(),u=e.options,d=u!==void 0&&e.multiSelect===!0,f=e=>{if(!d){o([e]);return}o(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,G.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,G.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),d?(0,G.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),u?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[u.map(e=>{let r=n.includes(e.label);return(0,G.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>f(e.label),className:a(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring`,`pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.06] [html:not(.light)_&]:pointer-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,G.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[d?(0,G.jsx)(`span`,{"aria-hidden":`true`,className:a(`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,G.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,G.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,G.jsx)(I,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,className:a(`h-auto min-h-11 w-full justify-start px-2.5 py-1.5 text-left`,u.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,G.jsx)(U,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,G.jsx)(U,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}var ir=/^diff --git /;function ar(e){let t=e.replace(ir,``),n=t.lastIndexOf(` b/`);return $(n>=0?t.slice(n+3):t)}function $(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function or(e){let t=$(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function sr(e){return{path:ar(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function cr(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=$(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=$(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=or(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=or(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function lr(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function ur(e){let t=[],n=null,r=!1;for(let i of e.split(`
|
|
10
|
-
`)){if(ir.test(i)){n=sr(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):cr(n,i);continue}lr(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function dr(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var fr=20,pr=300;function mr({runId:e,projectId:t}){let n=x(),r=o(e,t);(0,W.useEffect)(()=>{let r=t?[t,`runs`,`diff`,e]:u.runs.diff(e);n.invalidateQueries({queryKey:r})},[t,n,e]);let i=(0,W.useMemo)(()=>ur(r.data??``),[r.data]),[a,s]=(0,W.useState)(!1);if(r.isPending)return(0,G.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(r.isError)return(0,G.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:r.error.message});if(i.length===0)return(0,G.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:r.data.trim()||`(no changes)`});let c=dr(i),l=a?i:i.slice(0,fr);return(0,G.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,G.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[c.files,` `,c.files===1?`file`:`files`,` changed`]}),(0,G.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`text-semantic-green`,children:[`+`,c.additions]}),` `,(0,G.jsxs)(`span`,{className:`text-semantic-red`,children:[`−`,c.deletions]})]})]}),l.map(e=>(0,G.jsx)(gr,{file:e},`${e.oldPath??``}→${e.path}`)),i.length>l.length?(0,G.jsxs)(I,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>s(!0),children:[`Show `,i.length-l.length,` more files`]}):null]})}var hr={added:`added`,deleted:`deleted`,renamed:`renamed`};function gr({file:e}){let[t,n]=(0,W.useState)(!0),r=hr[e.status],i=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,G.jsxs)(z,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-card-edge bg-card shadow-card`,children:[(0,G.jsxs)(R,{className:`flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,G.jsx)(ce,{className:a(`mbs-[1px] size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,G.jsx)(`span`,{"data-slot":`diff-file-path`,title:i,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:e.oldPath?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,G.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,G.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,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-xs font-semibold tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`text-semantic-green`,children:[`+`,e.additions]}),` `,(0,G.jsxs)(`span`,{className:`text-semantic-red`,children:[`−`,e.deletions]})]})]}),(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,G.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,G.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,G.jsx)(_r,{lines:e.lines})})})]})}function _r({lines:e}){let[t,n]=(0,W.useState)(!1),r=t?e:e.slice(0,pr),i=r.join(`
|
|
11
|
-
`),[o,s]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!1;return Fe(i,`diff`).then(t=>{e||s({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let c=o?.text===i?o.tokens:Pe(i,`diff`)?.tokens??null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:a(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[c?.[t]===void 0?e:c[t].map((e,t)=>(0,G.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>pr?(0,G.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-xs font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function vr(e,t,n,r){return he(e,t)?.runner??e.runner??(t||n?r:void 0)??`claude`}function yr(e,t,n){let r=new Set;for(let i of e.workflowDef?.steps??[]){if(i.command!==void 0||i.kind===`plugin`)continue;let a=i.runner??t,o=i.agentProfile??(a===(e.runner??t)?e.agentProfile:void 0)??n.repoAccount?.[a];n.readyOn(a,o)||r.add(a)}return[...r]}function br(e,t,n,r,i){if(!e)return t!==null||!n||r?i:void 0}function xr(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 Sr(){let e=c(),t=g();return{providers:e,registered:t,providersPending:e.isPending||t.isPending,providersError:e.isError||t.isError,providersReady:e.isSuccess&&t.isSuccess}}function Cr(e,t=null,n){let{registered:r,providersPending:i,providersError:a,providersReady:o}=Sr(),c=p(n),l=Ne(e),u=e.removedRunner!==void 0,d=l&&!e.runner||u,m=De(n),h=e.delegation?.role===`worker`,g=c.data?.defaultRunner,_=vr(e,l,u,f(g,s(r.data))??g),v=(t,n)=>Me(e,t,m.repoAccount,{original:_,target:n},l),{runners:y,signedOut:b}=m.runnersOn(e=>v(e,e)),x=h?_:we(t,y,_),S=y.includes(_),C=l?T(e.workflowDef,x,s(r.data)):[x],w=l&&h&&e.workflowDef?yr(e,x,m):C.filter(e=>!m.readyOn(e,v(e,x))),E=o&&(!d||c.isSuccess)&&w.length===0,D=xr({needsConfig:d,configPending:c.isPending,configError:c.isError,providersPending:i,providersError:a,canContinue:E,untouched:l,missing:w});return{runners:y,signedOut:b,currentRunner:_,runner:x,currentRunnerConnected:S,canContinue:E,providerPending:i||d&&c.isPending,providerError:a,reason:D,runnerOverride:br(h,t,S,u,x)}}function wr(e,t){let n=x();return m({mutationFn:()=>w(e,t?.projectId),onSuccess:()=>{n.invalidateQueries({queryKey:u.runs.all}),t?.onSuccess?.()},onError:e=>S(e.message,{tone:`danger`})})}function Tr({run:e,projectId:t,onResolved:n}){return(0,G.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex flex-col gap-2 rounded-xl border border-info/35 bg-info/10 px-3.5 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,G.jsx)(P,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,G.jsxs)(`p`,{className:`min-w-0 break-words text-[13px] leading-relaxed`,children:[(0,G.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,G.jsx)(`span`,{className:`block text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,G.jsx)(Dr,{run:e,projectId:t,onResolved:n})]})}function Er({run:e,projectId:t,onResolved:n,showDiff:r=!0}){return(0,G.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-2.5`,children:[(0,G.jsx)(Tr,{run:e,projectId:t,onResolved:n}),r?(0,G.jsx)(mr,{runId:e.id,projectId:t}):null]})}function Dr({run:e,projectId:t,onResolved:n}){let r=h(),a=x(),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(``),[l,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),g=wr(e.id,{projectId:t,onSuccess:n}),b=Cr(e,null,t),w=()=>a.invalidateQueries({queryKey:u.runs.all}),T=m({mutationFn:async n=>b.canContinue?C(_(e.id,{projectId:t}),{text:`Review feedback:\n${n}`,runner:b.runnerOverride}):null,onMutate:()=>_(e.id,{projectId:t}),onSuccess:(e,t,i)=>{e!==null&&(c(``),r.invalidateAfter(`continue`,i),n?.())},onError:e=>S(e.message,{tone:`danger`})}),E=m({mutationFn:()=>y(e.id,t),onSuccess:e=>{S(`Draft PR created — ${e.url}`),w(),n?.()},onError:e=>{e instanceof v&&e.manual!==void 0&&p(e.manual),S(e.message,{tone:`danger`})}});(0,W.useEffect)(()=>{l&&o.current?.focus()},[l]);let O=()=>{if(!l){d(!0);return}let e=s.trim();if(e.length===0){S(`Write what to change first.`),o.current?.focus();return}T.mutate(e)};return(0,G.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[b.canContinue?null:(0,G.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:b.reason}),b.providerPending?null:(0,G.jsx)(B,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button]:min-h-11 [&_a]:min-h-11`,children:[(0,G.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,children:t?(0,G.jsxs)(D,{to:`/p/${encodeURIComponent(t)}/tasks/${encodeURIComponent(e.id)}/changes`,children:[(0,G.jsx)(P,{"aria-hidden":`true`}),`Review changes`]}):(0,G.jsxs)(B,{to:`/tasks/${e.id}/changes`,children:[(0,G.jsx)(P,{"aria-hidden":`true`}),`Review changes`]})}),(0,G.jsxs)(I,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:b.reason??(l?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":b.canContinue?void 0:`review-provider-guidance`,"aria-expanded":l,"aria-controls":l?`review-notes`:void 0,disabled:T.isPending||!b.canContinue,onClick:O,children:[(0,G.jsx)(We,{"aria-hidden":`true`}),l?`Send back with notes`:`Send back`]}),i(e.pullRequestUrl)?(0,G.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,children:(0,G.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,G.jsx)(le,{"aria-hidden":`true`}),`PR ↗`]})}):(0,G.jsxs)(I,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:E.isPending,onClick:()=>E.mutate(),children:[(0,G.jsx)(ee,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,G.jsxs)(I,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:ke(`review`),disabled:g.isPending,onClick:()=>g.mutate(),children:[(0,G.jsx)(re,{"aria-hidden":`true`}),`Accept`]}):null]}),l?(0,G.jsx)(U,{ref:o,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:1,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{Ee({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(),O())},className:`min-h-11 text-base md:text-[13px]`}):null,f===null?null:(0,G.jsx)(Or,{command:f})]})}function Or({command:e}){return(0,G.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>S(`Command copied to clipboard.`)).catch(()=>S(`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-xs text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,G.jsx)(oe,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,G.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function kr(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Ar=1500;function jr({status:e}){let t=(0,W.useRef)(e),[n,r]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||kr())return;r(!0);let i=setTimeout(()=>r(!1),Ar);return()=>clearTimeout(i)},[e]),n?(0,G.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,G.jsx)(Ce,{}),(0,G.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,G.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}export{Qt as A,yt as B,cn as C,$t as D,Ut as E,Vt as F,xt as H,It as I,Pt as L,Gt as M,qt as N,en as O,Ht as P,Et as R,X as S,Kt as T,$e as U,St as V,Ke as W,En as _,mr as a,dn as b,Cn as c,Un as d,wn as f,vn as g,Hn as h,Cr as i,Yt as j,Xt as k,Vn as l,Rn as m,Er as n,qn as o,Tn as p,wr as r,Jn as s,jr as t,Bn as u,hn as v,Wt as w,fn as x,pn as y,bt as z};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{n as i,t as a}from"./utils-DSMR_WLb.js";import{G as o,J as s,R as c,Ut as l,V as u,Wt as d,Xt as f,Y as p,_ as m,dn as h,dt as g,ln as _,lt as v,nt as y,ot as b,rn as x,rt as S,sn as C,un as w,xt as T,yt as E,z as D}from"./queries-CYWRnyM5.js";import{$r as O,An as k,At as A,Fn as j,Nn as M,Pn as N,Qn as P,Xn as F,Yn as I,Zn as ee,ei as L,hi as R,ii as z,it as B,lt as V,n as H,ot as te,rt as U,tr as ne,vr as W,yr as re}from"./toaster-B0kvcFif.js";import{f as ie,h as ae,n as oe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as se,m as ce,r as le,s as ue,v as de}from"./tasks-table-k18AuMR5.js";import{A as fe,B as pe,a as me,f as he,g as G,h as ge,it as _e,k as ve,l as K,m as ye,n as be,ot as xe,p as Se,s as Ce,u as we,ut as Te,y as Ee,z as De}from"./design-icons-CzEoMH9c.js";import{t as Oe}from"./createLucideIcon-BHp8sXmF.js";import{A as ke,B as Ae,C as je,D as Me,E as Ne,F as Pe,H as Fe,I as Ie,L as Le,M as Re,N as ze,O as Be,P as Ve,R as He,S as Ue,T as We,U as Ge,V as Ke,W as qe,_ as Je,a as Ye,b as Xe,c as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,j as rt,k as it,l as at,m as ot,n as st,o as ct,p as lt,r as ut,s as dt,t as ft,u as pt,v as mt,w as ht,x as gt,y as _t,z as vt}from"./review-panel-CLsVpcPr.js";import{a as yt,i as bt,n as xt,o as St,r as Ct,s as wt,t as Tt}from"./run-header-kGdJVGJm.js";import{t as Et}from"./eye-B8okNWXU.js";import{t as Dt}from"./loader-circle-CPBhhDbB.js";import{a as Ot}from"./tool-display-B9NN44oU.js";import{i as kt,l as At,o as jt,t as Mt}from"./reference-chip-BdikRjql.js";import{a as Nt,i as Pt,n as Ft,o as It,r as Lt,t as Rt}from"./thread-state-B_UW2DqR.js";import{t as q}from"./button-B7MKxYjT.js";import{n as zt,r as Bt,t as Vt}from"./collapsible-BEV4FO-1.js";import{a as Ht,i as Ut,o as Wt,r as Gt,t as Kt}from"./popover-CZV6tz9i.js";import{s as qt,t as Jt}from"./project-router-BvBqllk2.js";import"./attention-CGsbqL2t.js";import{D as Yt,E as Xt,O as Zt,S as Qt,b as $t,f as J,u as en,w as tn,x as nn}from"./task-groups-lh9gz7TP.js";import{t as Y}from"./status-dot-BRzVlF2X.js";import{c as rn,i as an,l as on,o as sn,r as cn,s as ln,t as un}from"./report-selection-D2RvkiGX.js";import{c as dn}from"./page-shell-7pLJMOgh.js";import{t as fn}from"./centered-state-V15AR_qo.js";import{A as pn,Dn as mn,G as hn,J as gn,M as _n,N as vn,Nn as yn,P as bn,Pn as xn,Qt as Sn,Sn as Cn,Tn as wn,U as Tn,W as En,Xt as Dn,an as On,b as kn,cn as An,gn as jn,h as Mn,i as Nn,j as Pn,l as Fn,m as In,mn as Ln,n as Rn,nn as zn,on as Bn,pn as Vn,s as Hn,sn as Un,tn as Wn,un as Gn,v as Kn}from"./index-DwDvloUQ.js";import{t as qn}from"./markdown-jbBslIIT.js";import{t as Jn}from"./task-file-scope-vwEp2s7o.js";import{i as Yn}from"./automation-format-DB34jUyF.js";var Xn=Oe(`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`}]]),X=e(t(),1),Z=r();function Zn(e,t,n,r,i,a,o,s,c){let l=Zt(e,zn(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=_n(t,o,a,[p,f?.[t]]),h=bn(p,t,o,f,a),g=Pn(h,a),_=r?``:c??d??``,v=vn(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function Qn(e,t,n,r){let i=Xt(e.steps),a=Zt(e,zn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function $n(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function er(e,t,n,r){return!!t&&(r!==Yt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function tr({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 nr(e){let t=v(),n=An(e).continueRun,r=m(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),u=`${e.id}:${Zt(e,zn(e))?.id??``}`,[d,p]=(0,X.useState)(u);d!==u&&(p(u),a(null),s(null),l(null));let g=nt(e,i),{runners:_,canContinue:y,currentRunner:b,runner:S}=g,{sessionStep:T,workerStep:D,account:O}=Qn(e,S,S!==b,jn().repoAccount),k=E(),A=k.data?.capabilities?.localHandoff!==!1,M=x(),N=C(S,n&&!k.isPending&&!M.isPending,A?O:null),P=r.data?.modelsLocked===!0,F=S!==b,I=Zn(e,S,F,P,r.data,N.data,M.data,o,c),{models:ee,model:L,effortOptions:R,effort:z}=I,{modelLabel:B,effortLabel:V}=tr(I),H=h({mutationFn:({text:t,images:n})=>y?te(w(e.id),$n(t,n,g.runnerOverride,P,F,o,c,I)):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onMutate:()=>w(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof j&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),U=e.delegation?.role===`worker`;return{skillRunner:S,skillAccount:O,available:n,canContinue:y,startsNewConversation:er(e,T,D,S),reason:g.reason,providerPending:g.providerPending,pills:(0,Z.jsx)(rr,{compact:e.status===`review`,summary:`${f(M.data,S)} · ${B} · ${V}`,children:(0,Z.jsxs)(En,{children:[!U&&(_.length>1||g.signedOut.length>0)?(0,Z.jsx)(hn,{icon:(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,signedOut:g.signedOut,value:S,onPick:e=>{e!==S&&(a(e),s(null))}}):(0,Z.jsx)(Tn,{icon:(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:U?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:S,value:S,onPick:()=>{},options:[{value:S,label:S}]}),(0,Z.jsx)(Tn,{icon:(0,Z.jsx)(Ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:B,value:L,readOnly:P,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=Pn(e,N.data);z!==``&&vn(z,t)===``&&l(``)},options:ee.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:pn(S,M.data,N)}),(0,Z.jsx)(Tn,{icon:(0,Z.jsx)(ve,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:V,value:z,readOnly:P,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:R.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},u),continueWith:(e,t)=>H.mutateAsync({text:e,images:t})}}function rr({compact:e,summary:t,children:n}){let[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(null),o=e&&!r;return(0,X.useEffect)(()=>{r&&a.current?.querySelector(`button:not([disabled])`)?.focus()},[r]),(0,Z.jsx)(`div`,{ref:a,"data-slot":`follow-up-engine`,"data-folded":o||void 0,className:o?`min-w-0`:`session-engine-controls`,children:o?(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`follow-up-engine-summary`,"aria-expanded":!1,"aria-label":`Agent settings: ${t}`,title:`Change the runner, model or effort`,onClick:()=>i(!0),className:`inline-flex min-h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground transition-colors outline-hidden hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(K,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var ir=120,ar=e=>e!==`pending`&&e!==`running`,or=e=>e.kind===`tool`&&e.toolKind===`task`,sr=e=>or(e)&&e.parentItemId===void 0,cr=e=>He(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function lr(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 ur(e){if(e.kind===`tool`)return dr(e.title);if(e.kind===`hook`)return dr(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
2
|
-
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return dr(n)}}}function dr(e){return e.length>ir?`${e.slice(0,ir-1).trimEnd()}…`:e}function fr(e,t=!1,n=e){let r=gr(e,e=>e.items.some(sr));if(r===-1)return[];let i=e=>!t&&!ar(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(sr);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(sr)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>pr(r,br(n,e,r.id),t))}function pr(e,t,n){let r={id:e.id,title:Le(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=lr(e);i!==void 0&&(r.agentType=i),n&&!ar(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=ur(t[e]);if(n!==void 0){r.activity=n;break}}return r}function mr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function hr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function gr(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function _r(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&sr(e));if(a!==void 0)return pr(a,br(r,e,t),n)}}function vr(e,t){return gr(e,e=>e.items.some(e=>e.id===t&&sr(e)))}function yr(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)cr(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function br(e,t,n){let r=vr(t,n);if(r===-1)return[];let i=yr(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of yr(e,n,Math.max(vr(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:xr(t,e))}return[...s.values()].sort(Sr).map(({entry:e})=>e)}function xr(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function Sr(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function Cr(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`?Ie(e.children).flatMap(n=>Cr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Cr(e,t)):[]}function wr(e){return e.flatMap((e,t)=>e.content.kind===`block`?Cr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Tr(e,t,n,r){let i=(0,X.useContext)(un),{projectId:a}=ae(),o=(0,X.useMemo)(()=>wr(t),[t]);(0,X.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=Fe(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=Ke(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function Er(e){let t=R();return h({mutationFn:t=>V(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:d.runs.all})}})}var Dr=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Or=()=>navigator.onLine;function kr({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,Z.jsx)(jr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,Z.jsx)(Ar,{permission:e,runId:t},e.requestId)}function Ar({permission:e,runId:t}){let n=Er(t),r=(0,X.useSyncExternalStore)(Dr,Or,()=>!1),i=(0,X.useRef)(!1),[a,o]=(0,X.useState)(`pending`),[s,c]=(0,X.useState)(),[l,u]=(0,X.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 j&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,Z.jsx)(jr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function jr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,X.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,Z.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-card-edge bg-card shadow-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,Z.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,Z.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,Z.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,Z.jsx)(q,{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,Z.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}var Mr=(0,X.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Nr(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 Pr(e,t,n=[]){let r={};for(let e of n)r[e.id]=J(e);for(let e of t??[])r[e.id]=J(e);return r[e.id]=J(e),r}function Fr(e,t){return t?.[e]??`Task`}function Ir(e,t,n){return t?n?.[e]??`peer task`:Fr(e,n)}function Lr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Rr(e){return e?.relationship===`peer`}function zr(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Br(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 Vr(e){if(e.outcome)return Br(e.outcome.status);if(e.delivery===`not-delivered`)return Hr(`not-delivered`)}function Hr(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Ur(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Rr(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 ${Vn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Wr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Fr(e,n),linkable:!0}):(0,Z.jsx)(Gr,{id:e,children:r})}function Gr({id:e,children:t}){let n=p(e);return n.data?t({title:J(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof j&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Kr={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`}},qr=`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 Jr({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,Z.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,Z.jsx)(Yr,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function Yr({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Lr(e.messages[0]??{senderRunId:e.senderRunId},t),o=Rr(e.messages[0]),s=Kr[o?`peer`:i],c=ii(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),l=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>Ir(e,o,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,Z.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":o?`peer`:`family`,"data-kind":e.kind,className:a(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes),children:[(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`p`,{className:a(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,Z.jsx)(`span`,{children:l}),c.map((e,t)=>(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,Z.jsx)(Wr,{id:e,peer:o,taskTitles:n,children:t=>(0,Z.jsx)(ei,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),o?(0,Z.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,Z.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:zr(e.kind)}),e.messages.length===1&&d?(0,Z.jsx)(Zr,{message:d}):null]}),(0,Z.jsx)(Xr,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-xs text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,Z.jsx)($r,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Ur(e,r?.[e.recipientRunId])))].map(e=>e?(0,Z.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,Z.jsx)(Qr,{messages:e.messages,peer:o,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,Z.jsx)(ti,{message:d,runId:t,taskTitles:n}):null,(0,Z.jsx)(ni,{batch:e,heading:u})]})}function Xr({at:e,className:t,children:n}){return e===void 0||Ue(e)===void 0?null:(0,Z.jsxs)(`span`,{className:t,children:[n,(0,Z.jsx)(Xe,{ts:e})]})}function Zr({message:e}){let t=Vr(e),n=Hr(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,Z.jsxs)(Z.Fragment,{children:[t?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function Qr({messages:e,peer:t,runId:n,taskTitles:r}){return(0,Z.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Vr(e),a=e.createdAt??e.recordedAt;return(0,Z.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Wr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,Z.jsx)(ei,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Hr(e.delivery)===i?null:(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Hr(e.delivery)}),(0,Z.jsx)(ti,{message:e,runId:n,taskTitles:r}),(0,Z.jsx)(Xr,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function $r({batch:e}){let t=Pe(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,X.useState)(()=>t?.get(n)??!1),a=(0,Z.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,Z.jsx)(qn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,Z.jsxs)(Vt,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,Z.jsxs)(Bt,{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,Z.jsx)(we,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,Z.jsx)(zt,{children:a})]})}function ei({view:e,to:t,label:n}){return e.linkable?(0,Z.jsx)(Jt,{className:qr,to:t,"aria-label":n,children:e.title}):(0,Z.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function ti({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:o}=(0,X.useContext)(Mr),s=e.requestId?r.get(e.requestId):void 0,c=e.requestId?s?[s]:[]:i.get(e.messageId)??[],l=e.requestId?`request`:`reply`;return c.length===0?e.requestId||e.outcome?.replyId?(0,Z.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,l,` is outside loaded history.`]}):null:c.map(e=>{let r=Lr(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:a(qr,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>o(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,Z.jsx)(Wr,{id:i,peer:Rr(e.message),taskTitles:n,children:e=>(0,Z.jsxs)(Z.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function ni({batch:e,heading:t}){return(0,Z.jsxs)(Vt,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,Z.jsxs)(Bt,{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,Z.jsx)(we,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,Z.jsx)(zt,{children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-xs text-muted-foreground`,children:[(0,Z.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>ri(e)).map((e,t)=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,Z.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function ri(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Rr(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Hr(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 ii(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var ai=e(n(),1),oi=`pending-ask`;function si(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function ci(e,t){if(e.dataset.askMode===`reply`){let n=(t??e.closest(`[data-slot="thread-dock"]`)??document).querySelector(`[data-slot="thread-composer-slot"]:not([hidden]) textarea:not(:disabled)`);if(n)return n}return si(e)}function li(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?ci(t,e):null}function ui(e,t){let n=`${oi}:${e}`;return r=>{if(!t())return!1;let i=[...r.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);if(i)return li(i);let a=[...r.querySelectorAll(`[data-slot="ask-card"][data-pinned="true"]`)].find(t=>t.dataset.askId===e);return a?ci(a,r):null}}function di(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function fi({onGoToQuestion:e}){return(0,Z.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,Z.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,Z.jsx)(q,{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`})]})}function pi(){let e=(0,X.useRef)(null);return(0,X.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.closest(`[data-slot="main"]`),r=t.querySelector(`[data-slot="run-header"]`),i=t.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),a=r.getBoundingClientRect(),o=getComputedStyle(document.documentElement),s=document.documentElement.style.getPropertyValue(`--kb`)||(typeof o.getPropertyValue==`function`?o.getPropertyValue(`--kb`):``),c=Number.parseFloat(s)||0;n.clientHeight>0&&n.clientHeight<420?t.dataset.compactViewport=`true`:delete t.dataset.compactViewport,c>0||Ht(window)?t.dataset.keyboardOpen=`true`:delete t.dataset.keyboardOpen,r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-a.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${mi(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),delete t.dataset.compactViewport,delete t.dataset.keyboardOpen,r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function mi(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var hi={viewKey:void 0,generation:0},gi=600,_i=24;function vi(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,X.useRef)(a);o.current=a;let s=(0,X.useRef)(e);s.current=e;let c=(0,X.useRef)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),m=(0,X.useRef)(!0),h=(0,X.useRef)(!0),g=(0,X.useRef)(0),_=(0,X.useRef)(0),v=(0,X.useRef)(new Set),y=(0,X.useCallback)(e=>{for(let t of[...v.current])t(e)},[]),b=(0,X.useCallback)(e=>(v.current.add(e),()=>{v.current.delete(e)}),[]),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(e=>{let t=c.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,X.useCallback)(()=>{let e=c.current;if(!e)return;let t=h.current?o.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=h.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?mi(r):0;n?T(e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top-i-12):t>=0&&w.current?w.current.scrollToIndex(t,{align:`start`,offset:-i-12}):T(e.scrollHeight-e.clientHeight)},[T]),D=(0,X.useCallback)(()=>{if(c.current){if(C.current!==e){C.current=e,h.current=!0;let t=it(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=Me(e)?.rowKeys?{viewKey:e,top:t.top}:null):(m.current=!0,x.current=null,S.current=null)}x.current===null?m.current&&E():T(x.current)}},[e,T,E]),O=(0,X.useCallback)(e=>S.current?.viewKey===e,[]),k=(0,X.useCallback)(e=>{let t=S.current;return!t||!O(e)||e!==s.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),A=(0,X.useCallback)(e=>{d(e),e&&(c.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="thread-transcript"], [data-slot="main"]`),D())},[n,D]),j=(0,X.useCallback)(()=>{m.current&&E()},[E]),M=(0,X.useRef)(!1),N=(0,X.useRef)(0),P=(0,X.useRef)(!1),F=(0,X.useRef)(void 0),I=(0,X.useRef)(!1),ee=(0,X.useRef)(!1),L=(0,X.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),R=(0,X.useRef)(null),z=(0,X.useRef)(0);(0,X.useEffect)(()=>{if(!l())return;let e=e=>{x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let B=(0,X.useCallback)(()=>{let e=R.current,t=c.current;if(!e||!t)return;R.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:o.current.indexOf(e.anchor.key),a=w.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):T(Re(t.scrollTop,r,e.anchor,L(t),n))},[L,T]),V=(0,X.useCallback)(()=>{let e=c.current;if(!e||!r||M.current)return;x.current=null,S.current=null,m.current=!1,M.current=!0;let t=N.current+1;N.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,l=ht(a,L(e)),u=l===void 0?-1:o.current.indexOf(l.key),d=s.current,f=z.current;r().then(()=>{s.current===d&&z.current===f&&(R.current={beforeHeight:n,beforeTop:i,anchor:l,anchorIndex:u})},()=>{}).finally(()=>{N.current===t&&(M.current=!1)})},[L,r]);(0,X.useEffect)(()=>()=>clearTimeout(F.current),[]);let H=(0,X.useRef)(null),te=(0,X.useRef)(0),U=(0,X.useCallback)(()=>n===`document`?++hi.generation:++te.current,[n]),ne=(0,X.useCallback)((e,t)=>n===`document`?hi.viewKey===e&&hi.generation===t:s.current===e&&te.current===t,[n]);(0,X.useEffect)(()=>()=>H.current?.disconnect(),[e,u]);let W=(0,X.useCallback)((t,n,r,i)=>{let a=c.current;if(!a||!u)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0,p(!0),U(),H.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=a.querySelector(`[data-slot="run-header"]`),l=s&&getComputedStyle(s).position===`sticky`?mi(s):0,d=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;if(t===e)e.tabIndex=-1;else{let e=a.getBoundingClientRect(),n=t.getBoundingClientRect();(n.top<e.top+l||n.bottom>e.bottom)&&T(a.scrollTop+n.top-e.top-l-12)}return t.focus({preventScroll:!0}),document.activeElement===t?(H.current?.disconnect(),!0):!1},f=w.current;if(i!==void 0)T(i);else if(f)f.scrollToIndex(n,{align:`start`,...l>0?{offset:-l}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-l)}d()||(H.current=new MutationObserver(()=>{d()}),H.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),rt(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,U]),re=(0,X.useCallback)(t=>{let n=U(),r=s.current;H.current?.disconnect();let a=c.current;if(!a)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),rt(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},l=a.closest(`[data-slot="main"]`)??a.closest(`[data-route="task-thread"]`)??a,u=()=>ne(r,n),d=()=>{let e=t?.(l);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!u()||d())return;H.current?.disconnect();let e=new MutationObserver(()=>{u()?d()&&e.disconnect():e.disconnect()});H.current=e,e.observe(l,{childList:!0,subtree:!0})})})})},[i,e,E,U,ne,y]),ie=a.at(-1),ae=a.length;return(0,X.useLayoutEffect)(()=>{z.current+=1,R.current=null,M.current=!1,n===`document`?hi.viewKey!==e&&(hi.viewKey=e,hi.generation+=1):te.current+=1},[e,n]),(0,X.useLayoutEffect)(()=>{let e=R.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?B():R.current=null:m.current&&E()},[ie,ae,B,E]),(0,X.useLayoutEffect)(()=>{!c.current||!u||D()},[u,D]),(0,X.useEffect)(()=>{let t=c.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,l,d=()=>{h.current&&!We(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),l=e},v=()=>{U(),H.current?.disconnect(),x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,z.current+=1,R.current=null,g.current=Date.now()},C=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){v();let e=!P.current;P.current=!0,clearTimeout(F.current),F.current=setTimeout(()=>{P.current=!1},180),e&&Ne(t)&&V()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&Ne(t)&&V()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),b())},D=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,ee.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||(h.current=!1,x.current=null,S.current=null,We(t,80)||(v(),b()))},k=()=>{i=!1},A=e=>{I.current=!1,r=e.touches[0]?.clientY??null},j=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),v(),!I.current&&Ne(t)&&(I.current=!0,V())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},M=e=>{if(e===0||!i&&Date.now()-_.current>=gi)return;let n=e<0?`up`:`down`;!i&&n!==l||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=_i&&(0,ai.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},N=()=>{let n=m.current;M(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!ee.current&&t.scrollTop<a&&Ne(t)&&(ee.current=!0,V()),a=t.scrollTop;let r=We(t,80);r&&x.current===null&&(m.current||Date.now()-g.current<2e3)&&(m.current=!0),!n&&m.current&&y({direction:`tail`}),p(!r),x.current===null&&!O(e)&&rt(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,N,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,A,{passive:!0}),t.addEventListener(`touchmove`,j,{passive:!0}),t.addEventListener(`pointerdown`,D,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,w);let L;if(typeof ResizeObserver<`u`){L=new ResizeObserver(()=>{let e=x.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;T(Math.min(e,n)),n>=e&&(x.current=null)}else m.current&&E()}),L.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&&L.observe(r),i&&L.observe(i)}return()=>{t.removeEventListener(`scroll`,N),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,A),t.removeEventListener(`touchmove`,j),t.removeEventListener(`pointerdown`,D),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,w),L?.disconnect()}},[e,u,V,T,E,O,U,y]),{attachContent:A,scrollElRef:c,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:re,jumpToRow:W,loadOlder:V,restickIfStuck:j,subscribeReaderScroll:b}}function yi({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Z.jsx)(bi,{runId:e,rows:t,controls:r}):(0,Z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function bi({runId:e,rows:t,controls:n}){return(0,Z.jsx)(xi,{runId:e,rows:t,controls:n},e)}function xi({runId:e,rows:t,controls:n}){let r=(0,X.useRef)(null),i=(0,X.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,X.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,X.useState)(()=>Me(e)),[l,u]=(0,X.useState)(()=>({cache:Be(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,X.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,X.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,X.useRef)(t.length);f.current=t.length;let p=(0,X.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,X.useRef)(null),h=(0,X.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||ke(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,X.useState)(0);return(0,X.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,Z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,Z.jsx)(Hn,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function Si({onJump:e,pendingQuestions:t=0}){return(0,Z.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-sm hover:text-foreground`,children:[(0,Z.jsx)(be,{"aria-hidden":!0,className:`size-3.5`}),di(t)]})}function Ci(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function wi(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ci(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function Ti(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var Ei=new WeakMap;function Di(e,t){let n=Ei.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(Ei.set(e,t),t)}function Oi(e,t){if(t!=null)return e.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===t&&!e.resolved)}function ki(e,t,n=t,r,i){let a=Oi(n,r),o=i?.pinPendingAskInTranscript!==!1,s=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),c=new Set,l=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),u=[];e.task&&u.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])u.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let d=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===d?ji(n.items):n.items;u.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:Di(n.items,wi(e,t.filter(t=>!e.task||!Nt(t,`opening`)).map(e=>e.kind===`ask`&&l.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Ti(e,r,a):e.kind===`permission`?(c.add(e.requestId),s.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let f=[...s.values()].filter(e=>e.status===`pending`&&!c.has(e.requestId));return f.length>0&&u.push({id:`pending-permissions`,entries:f,inDaySequence:!1}),a!==void 0&&o&&u.push({id:oi,entries:[{...a,placement:`pinned`}],inDaySequence:!1}),u}var Ai=`changes ready for review`;function ji(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(Ai)))}function Mi(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 Ni(e,t){return[{id:`agent:${e}`,entries:t}]}function Pi(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Fi(e,t){let n=[],r;for(let t of e){let e=Pi(t),i=je(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 Ie(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 Ii({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,X.useMemo)(()=>Fi(n,e),[n,e]),p=vi(`${e}:${t}`,{surface:r}),m=c??p;Tr(e,f,m,r);let h=(0,X.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,X.useMemo)(()=>f.map(t=>({key:t.key,node:Li(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??ze(``,g.length),v=g.length===0?i??null:(0,Z.jsx)(yi,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,Z.jsx)(Jn,{runId:e,children:(0,Z.jsx)(Ve,{runId:e,children:(0,Z.jsx)(Mr.Provider,{value:h,children:r===`panel`?(0,Z.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,Z.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,Z.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,Z.jsx)(Si,{onJump:m.jumpToLatest})}):null]}):v})})})}function Li(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,Z.jsx)(Ri,{message:e.content.message,actions:t});case`day-separator`:return(0,Z.jsx)(_t,{ts:e.content.ts});case`turn-time`:return(0,Z.jsx)(gt,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,Z.jsx)(zi,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Ui(e.content)}}function Ri({message:e,actions:t}){return(0,Z.jsx)(et,{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,Z.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,Z.jsx)(Ge,{ask:e.ask})}):void 0})}function zi({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,Z.jsx)(vt.Provider,{value:`${t}:${e.entry.id}`,children:(0,Z.jsx)(Vi,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,Z.jsx)(ot,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Z.jsx)(Bi,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,Z.jsx)(at,{group:e,scope:t});case`streak`:return(0,Z.jsx)(tt,{count:e.count,children:e.blocks.map(e=>(0,Z.jsx)(zi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,Z.jsx)(Jr,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Ui(e)}}function Bi({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return Ie(e).map(e=>(0,Z.jsx)(zi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Vi({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,Z.jsx)(Ze,{text:e.text,ts:e.ts}):(0,Z.jsx)(et,{text:e.text,ts:e.ts});case`reasoning`:return(0,Z.jsx)(lt,{text:e.text});case`tool`:return(0,Z.jsx)(ot,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Z.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?` · ${Hr(e.delivery)}`:``]}),(0,Z.jsx)(mt,{note:e})]}):(0,Z.jsx)(mt,{note:e});case`conversation`:return(0,Z.jsx)(Jr,{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,Z.jsx)(Qe,{image:e});case`ask`:return n===void 0?(0,Z.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,Z.jsx)(kr,{permission:e,runId:i});case`provider-auth-required`:return(0,Z.jsx)($e,{incident:e});case`preview-server`:return(0,Z.jsx)(Hi,{entry:e});case`hook`:return(0,Z.jsx)(pt,{item:e,cacheKey:`${t}:${e.id}`});default:return Ui(e)}}function Hi({entry:e}){let t=In(),n=E().data?.capabilities?.preview===!0;return(0,Z.jsx)(It,{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 Ui(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Wi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,onBeforeOpenReport:o,onRestoreAgentFocus:s,taskTitles:c,recipientBackends:l}){let u=(0,X.useContext)(un),d=(0,X.useRef)(void 0),f=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{d.current?.()},[u,e]),(0,Z.jsx)(an,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,Z.jsx)(sn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{f.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,Z.jsx)(Ae.Provider,{value:e=>{let t=r?.id,n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);d.current?.(),d.current=u?.registerOpener(e,()=>{if(t&&s){s(t);return}n?.focus({preventScroll:!0})}),f.current=!0,o?.(),a()},children:(0,Z.jsx)(Gi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:c,recipientBackends:l})})})})}function Gi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(rn,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Z.jsxs)(on,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,Z.jsxs)(ln,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(Ki,{status:r.status}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Z.jsx)(Ii,{runId:e,viewId:`agent:${r.id}`,sections:Ni(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,Z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function Ki({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,Z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:a(`rounded-full px-2 py-0.5 text-xs font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function qi(e){let t=R(),[n,r]=(0,X.useState)(),i=$t(e);(0,X.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=h({mutationFn:async()=>{r(e.id);try{if(!(await B(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:d.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function Ji({agents:e,onSelect:t}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,Z.jsx)(Yi,{agent:e,onSelect:t},e.id))})}function Yi({agent:e,onSelect:t}){let n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xi,{status:e.status,stalled:e.stalled===!0}),(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:hr(e)}),(0,Z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,Z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,Z.jsx)(`button`,{type:`button`,"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,Z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Xi({status:e,stalled:t=!1}){return t?(0,Z.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Zi(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Qi({entries:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,Z.jsx)($i,{entry:e},`${t}:${e.content}`))})}function $i({entry:e}){return(0,Z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:a(`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-disabled-foreground line-through`),children:[(0,Z.jsx)(ea,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,Z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function ea({status:e}){return e===`cancelled`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-disabled-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Z.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ta(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 na(e,t){let n=ta(e);return n===`active`&&t===`waiting`?`paused`:n}function ra(e){return e===`active`?`running`:e}function ia(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 aa({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=ia(e)*100;return(0,Z.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,Z.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":na(n.status,t),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,Z.jsx)(oa,{visual:na(n.status,t)}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:n.name}),n.iterations>1?(0,Z.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-xs text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,Z.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function oa({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Z.jsx)(he,{"aria-hidden":!0,className:a(t,`text-success`)});case`active`:return(0,Z.jsx)(Dt,{role:`status`,"aria-label":`Step running`,className:a(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Se,{role:`img`,"aria-label":`Step paused`,className:a(t,sa)});case`failed`:return(0,Z.jsx)(G,{"aria-hidden":!0,className:a(t,`text-danger`)});case`pending`:return(0,Z.jsx)(ye,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)})}}var sa=`stroke-pending [html.light_&]:stroke-pending-strong`,ca={done:`done`,failed:`failed`,cancelled:`cancelled`};function la(e){let t=ca[e.status];return t?e.steps.map(e=>ta(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):ua(e)}function ua(e){let t=da(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function da(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ta(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function fa(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function pa(e){return typeof e==`object`&&!!e&&!(0,X.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:i,aside:o,open:s,onToggle:c,className:l,children:u}){let d=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,Z.jsx)(`span`,{className:a(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(pa(r)?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,Z.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,Z.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,Z.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:a(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,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,o,(0,Z.jsx)(K,{"aria-hidden":!0,className:a(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!o&&`ms-auto`,s&&`rotate-180`)})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,o]}),f&&s?(0,Z.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 ma(e){return W(e.delegation)}function ha(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 ga(e){let t=e.delegation,n=ma(e),r=y(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=ha(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 _a(e){let t=y(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>nn(e.status))}function va({run:e,open:t,onToggle:n}){let r=y(e.id),i=S(),o=Dn(),s=e.delegation,c=new Map(r.data?.workers.map(e=>[e.workerId,e])),l=ha(s,r.data),u=I(e)??F(e),d=u?ya(e,u):void 0,f=e=>i.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),p=e=>{let t=f(e);return t?J(t):`worker ${e.slice(0,8)}`};return(0,Z.jsx)(Q,{slot:`workers`,icon:(0,Z.jsx)(fe,{className:`size-4`}),title:`Workers`,meta:ba({ids:l,workers:c,desktop:o,query:r}),aside:r.data?.capacity?(0,Z.jsx)(Da,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,Z.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,Z.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,u?(0,Z.jsx)(wa,{wait:u,dependencyLabel:d}):null,l.length>0?(0,Z.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:l.map(t=>{let n=c.get(t),i=f(t),o=n?Sa(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,Z.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,Z.jsxs)(Jt,{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,Z.jsx)(xa,{status:n?.status}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate`,children:i?J(i):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,Z.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,p(n.supervisorRunId)]}):null]}),(0,Z.jsx)(`span`,{className:a(`max-w-[45%] shrink-0 truncate text-xs`,Ca(n?.status)),children:o}),(0,Z.jsx)(me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,Z.jsx)(ka,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,Z.jsx)(Na,{state:n.destroy}):null]},t)})}):ma(e)&&r.isSuccess?(0,Z.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,Z.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,Z.jsx)(q,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function ya(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return N(e)??M(n.role,t,`requestIds`in t&&P(n,t.requestIds))}function ba({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 xa({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,Z.jsx)(he,{"aria-hidden":!0,className:a(t,`text-semantic-green`)}):e===`failed`?(0,Z.jsx)(G,{"aria-hidden":!0,className:a(t,`text-semantic-red`)}):e===`cancelled`?(0,Z.jsx)(ge,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)}):e===`review`?(0,Z.jsx)(Et,{"aria-hidden":!0,className:a(t,`text-semantic-info`)}):e===`waiting`?(0,Z.jsx)(Se,{"aria-hidden":!0,className:a(t,`text-semantic-amber`)}):e===`running`?(0,Z.jsx)(Dt,{role:`status`,"aria-label":`Worker running`,className:a(t,`animate-spin stroke-status-running motion-reduce:animate-none`)}):(0,Z.jsx)(ye,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)})}function Sa(e){return wn(e)}function Ca(e){return e===`done`?`text-semantic-green`:e===`failed`?`text-semantic-red`:e===`review`?`text-semantic-info`:e===`waiting`?`text-semantic-amber`:`text-muted-foreground`}function wa({wait:e,dependencyLabel:t}){return(0,Z.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?Cn(`waiting-on-workers`,t):`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting for request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting for workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,Z.jsxs)(Z.Fragment,{children:[` `,`Deadline: `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function Ta(e){return e.delegation?.role===`worker`&&F(e)?.phase===`wake-pending`}function Ea({run:e}){let t=F(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,Z.jsx)(wa,{wait:t,dependencyLabel:M(`worker`,t)}):null}function Da({capacity:e}){return(0,Z.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 Oa=new Set([`review`,`done`,`failed`,`cancelled`]);function ka({parentRunId:e,worker:t}){let n=c(e),[r,i]=(0,X.useState)(!1);if(!Oa.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof j?n.error.work:void 0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`break-words text-xs`,children:re(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,Z.jsx)(q,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,Z.jsx)(q,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,Z.jsx)(q,{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,Z.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${ja(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,Z.jsx)(q,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var Aa=(e,t,n)=>`${e} ${e===1?t:n}`;function ja(e){return[...e.uncommittedFiles?[Aa(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Aa(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Ma(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Na({state:e}){if(!Ma(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,Z.jsx)(Pa,{at:t.nextAt});return(0,Z.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,Z.jsxs)(Z.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,Z.jsxs)(Z.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Pa({at:e}){let t=cn(3e4);return(0,Z.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Yn(t,Date.parse(e))})}function Fa({items:e,lead:t=0}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(-1/0);return(0,X.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,Z.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,Z.jsxs)(`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:[!a||t>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ia({run:e,references:t}){return(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,Z.jsx)(Mt,{reference:t,taskTitle:J(e),inert:!0},ue(t)))})}function La(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?Ln(e.accounts,e.accountBackend)?`default`:void 0:e.known?Ln(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Ra(e){let t=x(),n=m(),r=g(),{accounts:i}=jn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,u=c?.backend??a,d=r.data?.profiles.find(e=>e.id===l&&e.provider===u),p=La({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:d,accounts:i,accountBackend:u}),h=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?f(t.data,a):O(e.removedRunner),...p?{account:p}:{},model:o,effort:s,...h?{identity:h}:{}}}var za=[`running`,`queued`,`waiting`];function Ba(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function $(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function Va(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function Ha(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Ua(e){let t=Ba(e.waits),n=za.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&Ha(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Ba(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Wa(e){return Ua(e)!==void 0}function Ga(e){return(Ua(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Ka({run:e}){let t=Ua(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,Z.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,Z.jsx)(Ja,{run:e,wait:t},t.id):t.kind===`worker`?(0,Z.jsx)(Ya,{wait:t},t.id):t.kind===`process`?(0,Z.jsx)(to,{run:e,wait:t},t.id):t.kind===`peer`?(0,Z.jsx)(Xa,{wait:t},t.id):t.kind===`subagent`?(0,Z.jsx)(Za,{wait:t},t.id):t.kind===`plugin`?(0,Z.jsx)(Qa,{run:e,wait:t},t.id):(0,Z.jsx)($a,{run:e,wait:t},t.id)),i?(0,Z.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,Z.jsx)(Ja,{run:e,wait:r,settled:!0}):null,a?(0,Z.jsx)(to,{run:e,wait:a,settled:!0}):null]})}function qa(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha?yn(r.headSha):`unknown`} → ${r?.observedHeadSha?yn(r.observedHeadSha):`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Va(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function Ja({run:e,wait:t,settled:n=!1}){let r=t.result,a=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=qa(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=$(c),u=`${t.repository}#${t.prNumber}`;return(0,Z.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,Z.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,Z.jsx)(`dd`,{children:s}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,Z.jsx)(`dd`,{className:`min-w-0`,children:i(t.prUrl)?(0,Z.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,Z.jsx)(`span`,{children:u})}),l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,Z.jsxs)(`dd`,{children:[a,` deadline unavailable`]})]})]})})}function Ya({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,Z.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,Z.jsxs)(`p`,{children:[`Waiting for `,r,` `,i]}),a?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,Z.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function Xa({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,Z.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,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`task`:`tasks`]}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function Za({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=$(e.deadline);return(0,Z.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,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,Z.jsxs)(`p`,{children:[`Check by`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function Qa({run:e,wait:t}){let n=t.phase===`open`?$(t.deadline):void 0;return(0,Z.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsx)(`p`,{children:t.phase===`resolved`?Va(t.summary,e):t.summary}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function $a({run:e,wait:t}){let n=$(t.deadline);return(0,Z.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,Z.jsx)(`p`,{children:Va(`Automatic check due`,e)}):n?(0,Z.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,Z.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,Z.jsx)(`p`,{children:t.note}):null]})}function eo(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 to({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?eo(t):t.phase===`resolved`?Va(eo(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?$(t.deadline):void 0;return(0,Z.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,Z.jsx)(`p`,{children:r}),i?(0,Z.jsxs)(`p`,{children:[`Until`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var no=new Map,ro=new Map;function io(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=St(e.run);return(0,Z.jsx)(kt,{projectId:t,repoBase:n,requests:i,children:(0,Z.jsx)(ao,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!ce(e.run)||!!se(e.run,n)})})}function ao({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,presentation:s=`card`,prNumbers:c,hasReferences:l,references:u}){let d=Dn(),f=Ra(e),[p,m]=(0,X.useState)(()=>i?!1:no.get(e.id)??!1),h=Co(o,p),g=s===`panel`||h.open,[_,v]=(0,X.useState)({}),y=so(e,t??n,n,r,c),b=yt(e),x=t=>_[t]??ro.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);ro.set(`${e.id}:${t}`,n),v(e=>({...e,[t]:n}))},C=e=>({open:x(e),onToggle:()=>S(e)}),w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,Z.jsx)(go,{run:e,activity:y,...C(`status`)}),(0,Z.jsx)(_o,{run:e,desktop:d,automations:y.automations,...C(`workflow`)}),(0,Z.jsx)(vo,{activity:y,desktop:d,onOpenWorker:a,...C(`subagents`)}),(0,Z.jsx)(yo,{run:e,...C(`workers`)}),(0,Z.jsx)(bo,{activity:y,desktop:d,...C(`plan`)}),(0,Z.jsx)(xo,{run:e,identity:f,activity:y,...C(`usage`)}),(0,Z.jsx)(So,{run:e,references:u,conflicts:y.conflicts,hasReferences:l,onResume:()=>b.mutate(),...C(`workspace`)})]});return s===`panel`?(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-presentation":`panel`,"data-state":`open`,"aria-label":`Session activity`,className:`flex min-w-0 flex-col bg-card`,children:[(0,Z.jsxs)(`div`,{className:`sticky inset-bs-0 z-10 flex items-center gap-2 bg-card px-3.5 py-2.5 text-[13px]`,children:[(0,Z.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Session activity`}),y.cost?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums`,children:y.cost}):null]}),w]}):(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:h.ref,"data-state":g?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Z.jsx)(po,{run:e,identity:f,activity:y,references:u,open:g,onToggle:()=>{no.set(e.id,!g),m(!g),h.chose(!g)}}),g?w:null]})}function oo(e,t,n,r){let i=E(),a=Rn(i.data),o=S(),s=wt(e,{queuePosition:e.status===`queued`?en(o.data??[]).get(e.id):void 0}),c=!Qt(e)&&e.status!==`queued`,l=(0,X.useMemo)(()=>r?fr(n.turns,c,t.turns):[],[r,n.turns,c,t.turns]),u=Rt(n)??[],d=ga(e),f=mr(l),p=Zi(u);return{health:i,line:s,...co(e,s,d,r?f:void 0,p),...lo(e,a),agents:l,agentCounts:f,planEntries:u,planCounts:p}}function so(e,t,n,r,i){let a=oo(e,t,n,r),o=jt(i);return{...a,conflicts:o,waitReferences:Ga(e),automations:xn(a.health.data)}}function co(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`,glyph:o?(0,Z.jsx)(he,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function lo(e,t){return{cost:t.cost&&e.costUsd!==void 0?le(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,Z.jsx)(Nn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function uo(e){return e.allComplete?`text-semantic-green`:e.failed&&`text-semantic-red`}function fo(e){let t=la(e),n=da(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function po({run:e,identity:t,activity:n,references:r,open:i,onToggle:o}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[ue(e),e])).values()];return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":mo(e,t,n,c,i),onClick:o,className:a(`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,Z.jsx)(De,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,Z.jsx)(ho,{run:e,identity:t,activity:n,summaryReferences:c}),i&&s?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:s}):null,(0,Z.jsx)(K,{"aria-hidden":!0,className:a(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!s&&`ms-auto`,i&&`rotate-180`)})]})}function mo(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=fo(e)?.step,u=l?`; step ${l.name}, ${ra(na(l.status,e.status))}`:``,d=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${u}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${d}`}function ho({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:o,conflicts:s}=n,c=fo(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...o?[{id:`cost`,priority:1,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,children:o})}]:[],...r.length||s.length?[{id:`chips`,priority:0,content:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ia,{run:e,references:r}),s.length>0?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:a(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,uo(n)),children:[n.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),c?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-step`,className:a(`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,e.status===`waiting`&&`max-md:hidden`),children:[(0,Z.jsx)(Do,{step:c,runStatus:e.status,decorative:!0}),(0,Z.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:c.name,className:`min-w-0 truncate`,children:c.name})]}):null,(0,Z.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,Z.jsx)(Fa,{items:l,lead:8})})]})}function go({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:o}=t,s=Ta(e);return(0,Z.jsxs)(Q,{slot:`status-row`,icon:t.glyph,title:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:a(`truncate`,uo(t)),children:t.statusText}),i.nextCheck?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,Z.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&o.length>0?(0,Z.jsx)(Fa,{items:[{id:`chips`,priority:0,content:(0,Z.jsx)(Ia,{run:e,references:o})}]}):void 0,open:n,onToggle:Wa(e)||s?r:void 0,children:[(0,Z.jsx)(Ka,{run:e}),s?(0,Z.jsx)(Ea,{run:e}):null]})}function _o({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=de(e),o=fo(e);return!a&&!o?null:(0,Z.jsxs)(Q,{slot:`workflow`,icon:o?(0,Z.jsx)(Do,{step:o.step,runStatus:e.status}):(0,Z.jsx)(Te,{className:`size-4`}),title:(0,Z.jsxs)(Z.Fragment,{children:[`Workflow`,a?(0,Z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:fa(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,Z.jsx)(aa,{steps:o.steps,runStatus:e.status}):null,(0,Z.jsx)(Eo,{run:e,available:n})]})}function vo({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,Z.jsx)(Q,{slot:`subagents`,icon:(0,Z.jsx)(Ce,{className:`size-4`}),title:`Subagents`,meta:fa(o.done,o.total,t),open:r,onToggle:i,children:(0,Z.jsx)(Ji,{agents:a,onSelect:n})})}function yo({run:e,open:t,onToggle:n}){return ma(e)?(0,Z.jsx)(va,{run:e,open:t,onToggle:n}):null}function bo({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,Z.jsx)(Q,{slot:`plan`,icon:(0,Z.jsx)(pe,{className:`size-4`}),title:`Plan`,meta:fa(a.done,a.total,t),open:n,onToggle:r,children:(0,Z.jsx)(Qi,{entries:i})})}function xo({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,Z.jsx)(Q,{slot:`usage`,icon:(0,Z.jsx)(Xn,{className:`size-4`}),title:`Usage & agent`,summary:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(Fa,{items:c})}),open:r,onToggle:i,children:(0,Z.jsx)(To,{run:e,tokens:o,cost:a})})}function So({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||Un(e)||Ma(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,Z.jsx)(Q,{slot:`workspace`,icon:(0,Z.jsx)(fe,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(Fa,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,Z.jsx)(Ia,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,Z.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,Z.jsx)(Na,{state:s}):null,(0,Z.jsx)(Ct,{run:e}),e.branch?(0,Z.jsx)(wo,{label:`Branch`,children:(0,Z.jsx)(xt,{branch:e.branch})}):null,e.worktreePath?(0,Z.jsx)(wo,{label:`Worktree`,children:(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,Z.jsx)(bt,{run:e,canResume:An(e).terminal,onResume:i})]})})}function Co(e,t){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(t);a.current=t;let o=(0,X.useRef)({active:!1,override:!1});return(0,X.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 wo({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function To({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Ra(e);return(0,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,Z.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,Z.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Eo({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,Z.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,Z.jsx)(Jt,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:a(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,Z.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Do({step:e,runStatus:t,decorative:n=!1}){let r=na(e.status,t),i=`size-4 shrink-0`;switch(r){case`active`:return(0,Z.jsx)(Dt,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Se,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,sa)});case`failed`:return(0,Z.jsx)(G,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-danger`)});case`pending`:return(0,Z.jsx)(ye,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-soft-foreground`)});case`done`:return(0,Z.jsx)(he,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-success`)})}}function Oo(e,t,n,r){let i=oo(e,t,n,r),a=ma(e),o=y(e.id,{enabled:a}),s=(0,X.useMemo)(()=>{let t=e.delegation?.role===`root`?e.delegation.receipts.map(e=>e.workerId):[],n=o.data?.workers.map(e=>e.workerId)??[];return new Set([...t,...n]).size},[e.delegation,o.data?.workers]),c=la(e),l=c.length>0?c[da(e.currentStepId,c)]:void 0;return{statusText:i.statusText,glyph:i.glyph,allComplete:i.allComplete,failed:i.failed,activeStepName:l?.name,workerCount:s,agentCounts:i.agentCounts,cost:i.cost,nextCheckText:i.line.nextCheck?.text}}function ko(e,t){let n=[`Session activity: ${e.statusText}`];return e.nextCheckText&&n.push(`Next check ${e.nextCheckText}`),e.activeStepName&&n.push(`step ${e.activeStepName}`),e.workerCount>0&&n.push(`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`),e.agentCounts.total>0&&n.push(`${e.agentCounts.done}/${e.agentCounts.total} subagents`),e.cost&&n.push(`cost ${e.cost}`),t===`sidebar`&&n.push(`toggle activity sidebar`),n.join(`; `)}function Ao({props:e,align:t,sideOffset:n,contentClassName:r,children:i}){let{run:a,thread:o,currentThread:s,currentComplete:c,onOpenWorker:l,open:u,onOpenChange:d,keepOpen:f=!1,onOpenAutoFocus:p}=e,m=e=>{f&&e.preventDefault()};return(0,Z.jsxs)(Kt,{open:u,onOpenChange:e=>{!e&&f||d(e)},children:[(0,Z.jsx)(Ut,{asChild:!0,children:i}),(0,Z.jsx)(Gt,{align:t,sideOffset:n,"data-slot":`run-activity-popover`,className:r,onOpenAutoFocus:p,onInteractOutside:m,onPointerDownOutside:m,onFocusOutside:m,onEscapeKeyDown:m,children:(0,Z.jsx)(io,{presentation:`panel`,run:a,thread:o,currentThread:s,currentComplete:c,onOpenWorker:l})})]})}function jo(e){let{run:t,thread:n,currentThread:r,currentComplete:i,mode:o,open:s,onOpenChange:c}=e,l=Oo(t,n,r,i),u=ko(l,o),d=l.allComplete?`text-semantic-green`:l.failed?`text-semantic-red`:`text-foreground`,f=(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger`,"data-activity-mode":o,"aria-expanded":s,"aria-label":u,onClick:o===`sidebar`?()=>c(!s):void 0,className:a(`hidden min-h-9 min-w-0 max-w-full shrink items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-[12px] font-medium text-foreground shadow-xs transition-colors md:inline-flex`,`pointer-hover:bg-muted/60 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,s&&`border-accent-strong/60`),children:[(0,Z.jsxs)(`span`,{"data-slot":`pill`,className:`inline-flex min-w-0 items-center gap-1.5`,children:[l.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:a(`truncate`,d),children:(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,children:l.statusText})})]}),l.activeStepName?(0,Z.jsxs)(`span`,{className:`hidden max-w-[140px] truncate text-muted-foreground @min-[1120px]:inline`,children:[`· `,l.activeStepName]}):null,l.workerCount>0?(0,Z.jsxs)(`span`,{"data-slot":`activity-workers-badge`,className:`rounded-full bg-muted px-2 py-0.5 text-xs text-foreground tabular-nums`,children:[l.workerCount,` `,l.workerCount===1?`worker`:`workers`]}):null,l.agentCounts.total>0?(0,Z.jsxs)(`span`,{"data-slot":`activity-subagents-badge`,className:`rounded-full bg-muted px-2 py-0.5 text-xs text-foreground tabular-nums`,children:[l.agentCounts.done,`/`,l.agentCounts.total,` agents`]}):null,l.cost?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`font-mono text-xs text-muted-foreground tabular-nums`,children:l.cost}):null,(0,Z.jsx)(K,{"aria-hidden":`true`,className:a(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,s&&`rotate-180`)})]});return o===`sidebar`?f:(0,Z.jsx)(Ao,{props:e,align:`end`,sideOffset:6,contentClassName:`w-[380px] max-w-[calc(100vw-2rem)] max-h-[min(70dvh,540px)] overflow-y-auto overscroll-contain p-0`,children:f})}function Mo(e){let{run:t,thread:n,currentThread:r,currentComplete:i,open:o}=e,s=Oo(t,n,r,i),c=ko(s,`popover`),l=s.allComplete?`text-semantic-green`:s.failed?`text-semantic-red`:`text-muted-foreground`;return(0,Z.jsx)(Ao,{props:e,align:`center`,sideOffset:4,contentClassName:`w-[calc(100vw-1.5rem)] max-w-[420px] max-h-[min(65dvh,460px)] overflow-y-auto overscroll-contain p-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger-mobile`,"aria-expanded":o,"aria-label":c,className:a(`flex min-h-11 min-w-0 flex-1 items-center gap-2 border-t border-border bg-background px-1 text-start text-[13px] text-foreground md:hidden`,`active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`),children:[(0,Z.jsx)(De,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-status`,className:a(`inline-flex min-w-0 items-center gap-1.5 truncate`,l),children:[s.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`truncate`,children:s.statusText})]}),s.workerCount>0?(0,Z.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-foreground tabular-nums`,children:[s.workerCount,`w`]}):null,s.agentCounts.total>0?(0,Z.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-foreground tabular-nums`,children:[s.agentCounts.done,`/`,s.agentCounts.total]}):null,s.cost?(0,Z.jsx)(`span`,{className:`ms-auto shrink-0 font-mono text-xs text-muted-foreground tabular-nums`,children:s.cost}):null,(0,Z.jsx)(K,{"aria-hidden":`true`,className:a(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!s.cost&&`ms-auto`,o&&`rotate-180`)})]})})}var No=2e3;function Po(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 Fo(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 Io(e,t){let n=R(),r=(0,X.useMemo)(()=>Po(t),[t]),i=(0,X.useMemo)(()=>Fo(t),[t]),a=e?.id,o=e?.status;(0,X.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:d.runs.detail(a)}),n.invalidateQueries({queryKey:d.runs.list()})},No);return()=>clearTimeout(e)},[r,i,a,o,n])}function Lo(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Ro({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,X.useState)(void 0),s=(0,X.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,X.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Mi(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Lo);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}var zo=12;function Bo({run:e}){let t=R(),n=h({mutationFn:()=>U(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:d.runs.detail(e.id)}),t.invalidateQueries({queryKey:d.runs.list()}),H(`This task will not resume itself`)},onError:e=>H(e.message,{tone:`danger`})});if(!ne(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,Z.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Z.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,zo,`)`]}):(0,Z.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Z.jsx)(oe,{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 Vo({pinnedAskId:e,runStatus:t,askModeState:n,replyPending:r,composerPending:i}){let a=e!==void 0,o=!a&&t===`review`,s=n.askId===e?n.mode:`options`;return{hasPendingAsk:a,isReviewGate:o,askMode:s,decisionMode:a?`ask`:o?`review`:`composer`,unifiedReplyActive:a&&s===`reply`,composerHidden:o||a&&s===`options`,optionDeliveryPending:a&&r&&!i}}function Ho(e){let{run:t,thread:n,pinnedAsk:r,pendingQuestions:i,scroll:o,onJump:s,onShowOrigin:c,sessionOpen:l,attention:u,queued:d,continuable:f,continueAction:p,stopAction:m,finishAction:h,needsAnswer:g,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,removedRunnerNotice:x}=e,S=An(t,_a(t)).cancel,[C,w]=(0,X.useState)({askId:r?.id,mode:`options`}),[T,E]=(0,X.useState)(!1),D=e=>w({askId:r?.id,mode:e}),{hasPendingAsk:O,isReviewGate:k,askMode:A,decisionMode:j,unifiedReplyActive:M,composerHidden:N,optionDeliveryPending:P}=Vo({pinnedAskId:r?.id,runStatus:t.status,askModeState:C,replyPending:v.isPending,composerPending:T});return(0,Z.jsxs)(`div`,{"data-slot":`thread-dock`,"data-pending-ask":g||void 0,"data-decision-mode":j,className:`relative z-10 shrink-0 bg-background py-1.5 md:pt-2.5 md:pb-4`,children:[o.pillVisible?(0,Z.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,Z.jsx)(Si,{pendingQuestions:i,onJump:s})}):null,(0,Z.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:a(`mx-auto flex w-full min-w-0 max-w-[var(--measure)] flex-col px-[14px] md:px-16`,M?`gap-0`:`gap-1.5 md:gap-2`),children:[k?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Bo,{run:t}),(0,Z.jsx)(Uo,{run:t,sessionOpen:l,attention:u,queued:d,continuable:f,startsNewConversation:p.startsNewConversation,removedRunnerNotice:x})]}),r===void 0?k?(0,Z.jsx)(st,{run:t,showDiff:!1}):null:(0,Z.jsx)(ct,{ask:{...r,placement:`pinned`},run:t,surface:`decision-zone`,mode:A,onModeChange:D,hideReplyBody:!0,delivery:v,onShowOrigin:c,onStop:S?m.stop:void 0,stopping:m.stopping,onFinish:On(t)?()=>h.mutateAsync():void 0,finishing:h.isPending},r.id),(0,Z.jsx)(`div`,{"data-slot":`thread-composer-slot`,hidden:N,className:a(`min-w-0 w-full`,N&&`hidden`,M&&`rounded-b-xl border border-t-0 border-accent-strong/30 bg-accent-strong/[0.04] p-2.5 [html:not(.light)_&]:bg-card`),children:(0,Z.jsx)(Ko,{run:t,thread:n,canStop:S,hasPendingAsk:O,composerHidden:N,optionDeliveryPending:P,onComposerPendingChange:E,stopAction:m,finishAction:h,attention:u,needsAnswer:g,continuable:f,continueAction:p,queued:d,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,sessionOpen:l})})]})]})}function Uo({run:e,sessionOpen:t,attention:n,queued:r,continuable:i,startsNewConversation:a,removedRunnerNotice:o}){if(e.status===`waiting`&&t)return(0,Z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:n.tone,shape:n.shape,pulse:n.pulse}),n.bucket===`permission`?`Choose an approval option above to continue`:n.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${mn(e,n).label} — you can send a message to resume`]});if(e.status===`running`){let t=wt(e,{}),n=la(e),r=n.length>0?n[da(e.currentStepId,n)]:void 0;return(0,Z.jsxs)(`div`,{"data-slot":`running-hint`,className:`flex min-w-0 items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[t.label,r?` · ${r.name}`:``]})]})}return r?(0,Z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):o===void 0?i&&a?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null:(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:o})}function Wo(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function Go(e){let{run:t,hasPendingAsk:n,optionDeliveryPending:r,continuable:i,continueAction:a,queued:o,sendMessage:s,reply:c,providerBlocked:l,providerReason:u,sessionOpen:d}=e,f=async(e,t)=>{let n=await c.send(e,t);if(n!==void 0)throw Error(n)};return n?{onSubmit:f,pendingLabel:c.mode===`resume`?`Continuing…`:`Sending…`,disabled:l||c.blockedBy!==void 0||r,disabledReason:l?u:r?`Sending your answer…`:c.reason,placeholder:`Reply — / for skills, @ for files…`}:{onSubmit:i?(e,t)=>a.continueWith(e,t??[]):o?(e,t)=>s.mutateAsync({text:e,images:t}):f,pendingLabel:i?`Continuing…`:`Sending…`,disabled:l||!d&&!o&&!i,disabledReason:l?u:`Session closed — no session to resume.`,placeholder:Jo(t,o,i)}}function Ko(e){let{run:t,thread:n,canStop:r,hasPendingAsk:i,composerHidden:a,onComposerPendingChange:o,stopAction:s,finishAction:c,attention:l,needsAnswer:u,continuable:d,continueAction:f,providerBlocked:p}=e,m=Go(e),h=!i&&d&&!u;return(0,Z.jsx)(gn,{...Wo(t,d,f),onPendingChange:o,onStop:r?s.stop:void 0,onFinish:On(t)?()=>c.mutateAsync().catch(()=>void 0):void 0,finishing:c.isPending,stopOnEmpty:!i&&qo(t,l,u),stopping:s.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:m.pendingLabel,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:!i&&d?f.pills:void 0,onSubmit:m.onSubmit,disabled:m.disabled,disabledReason:m.disabledReason,footerEnd:p&&!f.providerPending?(0,Z.jsx)(Jt,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:h,emptySubmitVariant:t.status===`review`?`outline`:`primary`,emptySubmitLabel:h?`Continue`:void 0,placeholder:m.placeholder,autocompleteSkills:!0,quickReplies:!a,getMentionCandidates:()=>Lt(n)})}function qo(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function Jo(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 Yo(){let{id:e}=ae(),t=p(e),n=Fn(e),r=t.data?.status,i=(0,X.useMemo)(()=>Ft(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,X.useMemo)(()=>Ft(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,X.useRef)(void 0),s=(0,X.useCallback)(e=>{o.current=e},[]),{mutate:c}=u();if((0,X.useEffect)(()=>{t.data&&o.current!==t.data.id&&tn(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Io(t.data,n.visibleEvents),t.isPending)return(0,Z.jsx)(kn,{});if(t.isError){let e=t.error instanceof j&&t.error.status===404;return(0,Z.jsx)(dn,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,Z.jsx)(fn,{icon:e?(0,Z.jsx)(At,{}):(0,Z.jsx)(qe,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,Z.jsx)(q,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(Jt,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Z.jsx)(kn,{}):(0,Z.jsx)(Zo,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var Xo=e=>({titles:Object.fromEntries(e.map(e=>[e.id,J(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function Zo({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){qt();let a=z({queryKey:d.runs.list(),queryFn:({signal:e})=>A(_(),{signal:e}),select:Xo}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=ns(r,n),u=k(e),f=Pt(e.status,e.error,t),p=Wn(e),m=!p&&e.status!==`queued`,h=e.status===`queued`,g=nr(e),v=qi(e),y=ut(e.id),x=s||ee(e),{hasContinuation:S,continuable:C}=rs(p,h,g),{openAgentId:w,setOpenAgentId:E,activityMode:D,activityOpen:O,setActivityOpen:j,showActivitySidebar:M,closeActivityPopover:N}=es(e.id),P=(0,X.useRef)(void 0),F=(0,X.useCallback)(e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(t=>t.dataset.agentId===e);if(t){t.focus({preventScroll:!0});return}P.current=e,j(!0)},[j]),I=(0,X.useCallback)(e=>{let t=P.current;if(!t)return;P.current=void 0;let n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);n&&(e.preventDefault(),n.focus({preventScroll:!0}))},[]),{openAgent:R,openAgentChildren:B}=Qo(w,n,t,m),V=b(e.id),H=Sn(e),{providerBlocked:te,providerReason:U}=is(p,Gn(e),S,g),ne=ts(e,h),W=l?void 0:c??null,re=(0,X.useMemo)(()=>Oi(n,W),[n,W]),ae=re?.questions.length??0,oe=(0,X.useMemo)(()=>ki(e,t,n,W,{pinPendingAskInTranscript:!1}),[e,t,n,W]),ce=(0,X.useMemo)(()=>Fi(oe,e.id),[oe,e.id]),{taskTitles:le,recipientBackends:ue}=$o(e,a.data),de=(0,X.useCallback)(t=>(0,Z.jsx)(kr,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),fe=C&&e.removedRunner!==void 0?L(e.removedRunner):void 0,pe=se(e,T()),{search:me}=ie(),he=ze(me,ce.length),G=vi(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:ce.map(({key:e})=>e)}),ge=Ro({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:ce,history:r,jumpToRow:G.jumpToRow}),_e=(0,X.useRef)(c);l||(_e.current=c);let ve=pi(),K=(0,X.useRef)({reveal:ge.reveal});K.current={reveal:ge.reveal};let ye=(0,X.useCallback)(()=>{li(ve.current??document.body)?.focus({preventScroll:!0})},[ve]),be=(0,X.useCallback)(t=>t.placement===`origin`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.context?(0,Z.jsx)(dt,{text:t.context}):null,t.resolved?null:(0,Z.jsx)(fi,{onGoToQuestion:ye})]}):(0,Z.jsx)(ct,{ask:t,run:e,onShowOrigin:()=>K.current.reveal()}),[e,ye]);Wt(G.restickIfStuck);let xe=r?.currentComplete??!0,Se={run:e,thread:t,currentThread:n,currentComplete:xe,onOpenWorker:E,mode:D,open:O,onOpenChange:j,keepOpen:w!==void 0,onOpenAutoFocus:I};return(0,Z.jsxs)(dn,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,fillHeight:!0,flushPadding:!0,rootRef:ve,rootProps:{"data-run-id":e.id},className:`overflow-clip`,children:[(0,Z.jsx)(Tt,{run:e,onMarkedUnread:()=>i?.(e.id),desktopActivitySlot:(0,Z.jsx)(jo,{...Se}),mobileActivitySlot:(0,Z.jsx)(Mo,{...Se})}),(0,Z.jsxs)(`div`,{"data-slot":`thread-workspace`,children:[(0,Z.jsxs)(`div`,{"data-slot":`thread-main`,children:[(0,Z.jsx)(`div`,{"data-slot":`thread-transcript`,role:`region`,"aria-label":`Session transcript`,tabIndex:0,children:(0,Z.jsx)(as,{run:e,thread:t,history:r,footer:f,issueUrl:pe,sections:oe,renderAsk:be,renderPermission:de,messageActions:ne,scroll:G,mode:he,taskTitles:le,recipientBackends:ue})}),(0,Z.jsx)(Ho,{run:e,thread:t,pinnedAsk:re,pendingQuestions:ae,scroll:G,onJump:()=>{let e=ae>0?re?.id:void 0;G.jumpToLatest(e===void 0?void 0:ui(e,()=>_e.current===e))},onShowOrigin:()=>K.current.reveal(),sessionOpen:p,attention:u,queued:h,continuable:C,continueAction:g,stopAction:v,finishAction:y,needsAnswer:x,sendMessage:V,reply:H,providerBlocked:te,providerReason:U,removedRunnerNotice:fe})]}),M?(0,Z.jsx)(`aside`,{"data-slot":`thread-activity-sidebar`,"aria-label":`Session activity`,children:(0,Z.jsx)(io,{presentation:`panel`,run:e,thread:t,currentThread:n,currentComplete:xe,onOpenWorker:E})}):null]}),(0,Z.jsx)(ft,{status:e.status}),(0,Z.jsx)(Wi,{runId:e.id,renderAsk:be,renderPermission:de,agent:R,entries:B,taskTitles:le,recipientBackends:ue,onBeforeOpenReport:N,onRestoreAgentFocus:F,onClose:()=>E(void 0)})]})}function Qo(e,t,n,r){return{openAgent:(0,X.useMemo)(()=>e===void 0?void 0:_r(t.turns,e,r,n.turns),[t.turns,e,r,n.turns]),openAgentChildren:(0,X.useMemo)(()=>e===void 0?[]:br(n.turns,t.turns,e),[n.turns,t.turns,e])}}function $o(e,t){let n=e.delegation?.role===`root`||e.delegation?.role===`worker`,r=y(e.id,{enabled:n});return{taskTitles:(0,X.useMemo)(()=>({...Pr(e,void 0,r.data?.titles),...t?.titles,[e.id]:J(e)}),[e,t,r.data]),recipientBackends:(0,X.useMemo)(()=>({...t?.backends,...Nr(e,void 0)}),[e,t])}}function es(e){let[t,n]=(0,X.useState)(void 0),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!0),[s,c]=(0,X.useState)(e);s!==e&&(c(e),n(void 0),i(!1));let l=In(),u=Mn()||l?.open===!0,d=Kn(`(min-width: 1600px)`,!1)&&!u?`sidebar`:`popover`;return{openAgentId:t,setOpenAgentId:n,activityMode:d,activityOpen:d===`sidebar`?a:r,setActivityOpen:d===`sidebar`?o:i,showActivitySidebar:d===`sidebar`&&a,closeActivityPopover:(0,X.useCallback)(()=>i(!1),[])}}function ts(e,t){let{mutateAsync:n}=o(e.id),{mutateAsync:r}=D(e.id),{mutateAsync:i}=s(e.id);return(0,X.useMemo)(()=>{if(!t)return;let a={task:{onEdit:async e=>{await n({task:e})},editLabel:`Edit the prompt`}};for(let t of e.queuedMessages??[])a[`queued:${t.id}`]={onEdit:e=>r({msgId:t.id,message:{text:e}}).then(()=>void 0),onRemove:()=>i(t.id).then(()=>void 0)};return a},[t,e.queuedMessages,n,r,i])}function ns(e,t){let n=e?Ot(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 rs(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function is(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function as({run:e,thread:t,history:n,footer:r,issueUrl:o,sections:s,renderAsk:c,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,Z.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,Z.jsx)(os,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,Z.jsx)(Ii,{runId:e.id,viewId:`main`,sections:s,mode:`document`,renderAsk:c,renderPermission:l,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,Z.jsx)(ss,{run:e}):(0,Z.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,Z.jsx)(Je,{}):null,r&&r.state===`closed`?(0,Z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:a(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[r.label,i(ce(e))?(0,Z.jsx)(`a`,{"data-slot":`pr-link`,href:ce(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,i(o)?(0,Z.jsx)(`a`,{"data-slot":`issue-link`,href:o,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,Z.jsx)(Ye,{runId:e.id}):null]})}function os({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Z.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,Z.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-xs text-soft-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Z.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function ss({run:e}){let t=Bn(S().data??[],e.id);return(0,Z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),(0,Z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Yo as TaskThreadRoute};
|