cezarion 0.19.0-dev.8704 → 0.19.0-dev.8714

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/accounts-section-CQAZjNMH.js +1 -0
  3. package/web/dist/assets/activity-motion-Cjk0Ozs9.js +1 -0
  4. package/web/dist/assets/activity-route-DQ2vQVUG.js +1 -0
  5. package/web/dist/assets/agent-config-section-6tcXGdqh.js +7 -0
  6. package/web/dist/assets/agent-defaults-section-DHdrzX19.js +1 -0
  7. package/web/dist/assets/{appearance-Ew3vb_-K.js → appearance-CxkUoLLY.js} +1 -1
  8. package/web/dist/assets/archive-on-merge-field-D7-FuLiL.js +1 -0
  9. package/web/dist/assets/attention--Y0CyzCN.js +1 -0
  10. package/web/dist/assets/automations-route-BFaRgLxq.js +2 -0
  11. package/web/dist/assets/commit-list-Ca61W21s.js +1 -0
  12. package/web/dist/assets/diff-B5yQN9UD.js +3 -0
  13. package/web/dist/assets/{diff-controls-CmYvdEGt.js → diff-controls-_6OoQImc.js} +1 -1
  14. package/web/dist/assets/{diff-view-DV6muJdZ.js → diff-view-DFiA3y5a.js} +1 -1
  15. package/web/dist/assets/file-preview-v5_F5k3C.js +2 -0
  16. package/web/dist/assets/folder-browser-CZiaPNK7.js +1 -0
  17. package/web/dist/assets/{git-toolbar-Dc_o1nrh.js → git-toolbar-C33icZYQ.js} +1 -1
  18. package/web/dist/assets/github-DAftYTLP.js +1 -0
  19. package/web/dist/assets/global-activity-route-Dc0oqViK.js +2 -0
  20. package/web/dist/assets/index-1TLdjVro.css +1 -0
  21. package/web/dist/assets/index-7M_Uae0m.js +21 -0
  22. package/web/dist/assets/label-BKUl84DF.js +1 -0
  23. package/web/dist/assets/{markdown-CJzxFk0P.js → markdown-nyVMLqM-.js} +1 -1
  24. package/web/dist/assets/notifications-section-oiF-HLRZ.js +1 -0
  25. package/web/dist/assets/open-in-menu-N8rXgYSG.js +1 -0
  26. package/web/dist/assets/preview-pane-connected-DgRQbaVm.js +3 -0
  27. package/web/dist/assets/project-location-CcmuGA5W.js +1 -0
  28. package/web/dist/assets/project-router-CT6gVIcC.js +1 -0
  29. package/web/dist/assets/projects-section-DtL1VsXT.js +1 -0
  30. package/web/dist/assets/prompt-templates-section-qK5TH9GX.js +1 -0
  31. package/web/dist/assets/queries-ClkIgWFx.js +1 -0
  32. package/web/dist/assets/reference-chip-bAUYx-Fl.js +1 -0
  33. package/web/dist/assets/remote-settings-notice-KN0zBmre.js +1 -0
  34. package/web/dist/assets/repo-git-BY2jC4L2.js +1 -0
  35. package/web/dist/assets/report-reader-CeBbC_Jy.js +1 -0
  36. package/web/dist/assets/report-selection-D9xJZoKb.js +1 -0
  37. package/web/dist/assets/reports-B-hz_AlB.js +1 -0
  38. package/web/dist/assets/resources-section-BywQtsIL.js +1 -0
  39. package/web/dist/assets/review-panel-DV9yD5Zl.js +8 -0
  40. package/web/dist/assets/run-detail-refresh-Bo51TspT.js +1 -0
  41. package/web/dist/assets/run-header-CZjnjsNk.js +2 -0
  42. package/web/dist/assets/{select-D3snxxoD.js → select-ETUx1MVz.js} +1 -1
  43. package/web/dist/assets/{session-context-section-esqZfONg.js → session-context-section-2B1lqgAc.js} +2 -2
  44. package/web/dist/assets/settings-agent-picker-BdoxLNMP.js +1 -0
  45. package/web/dist/assets/settings-shell-BIhAcEF4.js +1 -0
  46. package/web/dist/assets/sidebar-section-Bamq8P_D.js +1 -0
  47. package/web/dist/assets/skills-BIhWfWYY.js +1 -0
  48. package/web/dist/assets/{tab-link-BGXFZZ_Z.js → tab-link-DE6t7XkG.js} +1 -1
  49. package/web/dist/assets/task-changes-CBuihPwR.js +1 -0
  50. package/web/dist/assets/task-commits-BKHSmTUJ.js +1 -0
  51. package/web/dist/assets/task-files-CAPgay7C.js +1 -0
  52. package/web/dist/assets/task-github-item-BhIl0YRe.js +1 -0
  53. package/web/dist/assets/task-groups-aquji1Kv.js +1 -0
  54. package/web/dist/assets/task-thread-DwqQN87Q.js +2 -0
  55. package/web/dist/assets/tasks-table-BkjZYg2J.js +1 -0
  56. package/web/dist/assets/thread-state-C8v4gnTh.js +4 -0
  57. package/web/dist/assets/toaster-C-xqAWVX.js +4 -0
  58. package/web/dist/assets/tool-display-B9NN44oU.js +1 -0
  59. package/web/dist/assets/use-hand-to-agent-state-P0PYtQDy.js +1 -0
  60. package/web/dist/assets/use-search-params-writer-ClMScnNe.js +1 -0
  61. package/web/dist/assets/workflows-Cp5n5AnS.js +7 -0
  62. package/web/dist/assets/workspace-tools-CsubVxbO.js +1 -0
  63. package/web/dist/assets/worktrees-section-w7yDtBtW.js +4 -0
  64. package/web/dist/index.html +15 -14
  65. package/web/dist/assets/accounts-section-CzFhdKWy.js +0 -1
  66. package/web/dist/assets/activity-motion-D0Fch0mc.js +0 -2
  67. package/web/dist/assets/activity-route-Cvw0jXpy.js +0 -1
  68. package/web/dist/assets/agent-config-section-BCzxsvys.js +0 -7
  69. package/web/dist/assets/agent-defaults-section-DMRK-Qlp.js +0 -1
  70. package/web/dist/assets/archive-on-merge-field-g87CG6RL.js +0 -1
  71. package/web/dist/assets/attention-80jX8HhC.js +0 -1
  72. package/web/dist/assets/automations-route-CRBtWEo1.js +0 -2
  73. package/web/dist/assets/commit-list-Cd14tNSj.js +0 -1
  74. package/web/dist/assets/diff-D55N_7Ul.js +0 -3
  75. package/web/dist/assets/file-preview-CTPfK-oR.js +0 -2
  76. package/web/dist/assets/folder-browser-DnSFycbU.js +0 -1
  77. package/web/dist/assets/github-WYk7bQID.js +0 -1
  78. package/web/dist/assets/global-activity-route-Dvx2uk8w.js +0 -1
  79. package/web/dist/assets/hourglass-CikYdGGQ.js +0 -1
  80. package/web/dist/assets/index-CGdnowj-.js +0 -21
  81. package/web/dist/assets/index-DAxuDJAo.css +0 -1
  82. package/web/dist/assets/label-o_DsEmPt.js +0 -1
  83. package/web/dist/assets/live-reads-Cgk2XbiP.js +0 -1
  84. package/web/dist/assets/notifications-section-DNYO4sd4.js +0 -1
  85. package/web/dist/assets/open-in-menu-Bzae69TK.js +0 -1
  86. package/web/dist/assets/preview-pane-connected-CRooCkyb.js +0 -3
  87. package/web/dist/assets/project-location-D6riKh0Z.js +0 -1
  88. package/web/dist/assets/project-router-CZ89wg-5.js +0 -1
  89. package/web/dist/assets/project-scope-context-DIcqj4jJ.js +0 -4
  90. package/web/dist/assets/projects-section-4rsb8E52.js +0 -1
  91. package/web/dist/assets/prompt-templates-section-G3dlAOXt.js +0 -1
  92. package/web/dist/assets/queries-DZhNVAD_.js +0 -1
  93. package/web/dist/assets/reference-chip-DSJSqjmO.js +0 -1
  94. package/web/dist/assets/remote-settings-notice-GNs7i0kP.js +0 -1
  95. package/web/dist/assets/repo-git-CvZTTKFl.js +0 -1
  96. package/web/dist/assets/report-reader-CLlNdsZG.js +0 -1
  97. package/web/dist/assets/reports-sl2SMDG1.js +0 -1
  98. package/web/dist/assets/resources-section-DhEoaA0K.js +0 -1
  99. package/web/dist/assets/run-header-DZoOLIBZ.js +0 -2
  100. package/web/dist/assets/settings-agent-picker-Dso2TmRM.js +0 -1
  101. package/web/dist/assets/settings-shell-UO_0dSGl.js +0 -1
  102. package/web/dist/assets/sidebar-section-pp7e3AZa.js +0 -1
  103. package/web/dist/assets/skills-B99glme7.js +0 -1
  104. package/web/dist/assets/task-changes-Tn9M2OPH.js +0 -1
  105. package/web/dist/assets/task-commits-BHDMp1sO.js +0 -1
  106. package/web/dist/assets/task-files-Csx1Bonx.js +0 -1
  107. package/web/dist/assets/task-github-item-D0kQ0K4S.js +0 -1
  108. package/web/dist/assets/task-groups-DK0I9p71.js +0 -1
  109. package/web/dist/assets/task-thread-DsMuGSug.js +0 -9
  110. package/web/dist/assets/tasks-table-BNFYIwtc.js +0 -1
  111. package/web/dist/assets/thread-state-DMWi6eLk.js +0 -4
  112. package/web/dist/assets/toaster-0sM0sfWx.js +0 -1
  113. package/web/dist/assets/use-hand-to-agent-state-DqCW8Giu.js +0 -1
  114. package/web/dist/assets/workflows-CxJvAn6z.js +0 -7
  115. package/web/dist/assets/workspace-tools-DqJ8akIy.js +0 -1
  116. package/web/dist/assets/worktrees-section-DBZZlAe0.js +0 -4
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Nn as r,bt as i}from"./project-scope-context-DIcqj4jJ.js";import{$t as a,Bt as o,Q as s,Y as c,Z as l}from"./queries-DZhNVAD_.js";import{h as u}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{S as d,j as f,ot as p}from"./design-icons-CzEoMH9c.js";import{t as m}from"./run-header-DZoOLIBZ.js";import{n as h}from"./diff-controls-CmYvdEGt.js";import{t as g}from"./project-router-CZ89wg-5.js";import{b as _}from"./task-groups-DK0I9p71.js";import{c as v,d as y}from"./page-shell-7pLJMOgh.js";import{t as b}from"./centered-state-V15AR_qo.js";import{C as x,Sn as S,Tn as C,en as w,w as T,zt as E}from"./index-CGdnowj-.js";import{t as D}from"./diff-D55N_7Ul.js";import{t as O}from"./change-counts-CW7O8g5Y.js";import{r as k,t as A}from"./commit-list-Cd14tNSj.js";var j=e(t(),1),M=n();function N(){let{id:e}=u(),t=c(e);return t.isPending?(0,M.jsx)(T,{tab:`changes`}):t.isError?(0,M.jsx)(x,{tab:`changes`,error:t.error}):(0,M.jsx)(P,{run:t.data})}function P({run:e}){let{sha:t}=u(),n=s(e.id,_(e)),i=n.data?.commits[0]?.sha;return(0,M.jsxs)(v,{route:`task-commits`,density:y(n.data?.commits.length??0),flushPadding:!0,children:[(0,M.jsx)(m,{run:e,tab:`commits`}),t?(0,M.jsx)(I,{runId:e.id,sha:t}):n.isPending?(0,M.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading commits…`}):n.isError?(0,M.jsx)(b,{icon:(0,M.jsx)(f,{size:16}),tone:n.error instanceof r&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof r&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,M.jsx)(b,{icon:(0,M.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,M.jsx)(F,{run:e,commits:n.data.commits,selectedSha:i})]})}function F({run:e,commits:t,selectedSha:n}){let r=l(e.id,n),i=R(e.id,t),a=(0,j.useRef)(null),o=w(),[s,c]=(0,j.useState)(`unified`),[u,d]=(0,j.useState)(!0),m=o?s:`unified`;return(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5 px-4 py-5 md:px-9 lg:flex-row lg:items-start`,children:[(0,M.jsxs)(`div`,{className:`w-full shrink-0 lg:w-[380px] xl:w-[420px]`,children:[(0,M.jsx)(A,{slot:`task-commits`,selectedSha:n,heading:(0,M.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[t.length,` `,t.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:t.map(t=>({...t,href:`/tasks/${e.id}/commits/${t.sha}`,stat:i.get(t.sha)}))}),n&&r.data&&r.data.files.length>0?(0,M.jsx)(z,{runId:e.id,sha:n,files:r.data.files,onPick:e=>a.current?.scrollToPath(e)}):null]}),n?(0,M.jsx)(`section`,{"data-slot":`task-commit-preview`,"data-sha":n,className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card`,children:r.isPending?(0,M.jsx)(`p`,{className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):r.isError?(0,M.jsx)(b,{icon:(0,M.jsx)(p,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load commit diff`,subtitle:r.error.message}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h3`,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:r.data.subject}),(0,M.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,M.jsx)(`span`,{children:r.data.author}),(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,M.jsx)(`span`,{title:r.data.when,children:E(r.data.when)}),(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,M.jsx)(C,{sha:r.data.sha??n,variant:`inline`}),r.data.stat?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,M.jsx)(S,{stat:r.data.stat})]}):null]})]}),(0,M.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:(0,M.jsx)(h,{mode:s,wrap:u,onModeChange:c,onWrapChange:d})})]}),!r.data.files||r.data.files.length===0?(0,M.jsx)(b,{icon:(0,M.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,M.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem]`,children:(0,M.jsx)(D,{viewRef:a,files:r.data.files,mode:m,wrap:u,totals:!1,className:`min-w-0`})})]})}):null]})}function I({runId:e,sha:t}){return(0,M.jsx)(k,{commit:l(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`})}var L=12;function R(e,t){let n=t.length<=L,r=a({queries:t.map(t=>({queryKey:o.runs.commit(e,t.sha),queryFn:({signal:n})=>i(e,t.sha,{signal:n}),enabled:n,retry:!1}))}),s=new Map;return r.forEach((e,n)=>{let r=t[n]?.sha;r&&e.data?.stat&&s.set(r,e.data.stat)}),s}function z({runId:e,sha:t,files:n,onPick:r}){return(0,M.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-4 rounded-xl border border-border bg-card p-4`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,M.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[n.length,` `,n.length===1?`file`:`files`,` in`,` `,(0,M.jsx)(C,{sha:t,variant:`inline`,className:`text-[13px] font-medium`})]}),(0,M.jsx)(g,{to:`/tasks/${e}/changes`,className:`text-xs text-muted-foreground hover:text-foreground`,children:`All task changes ›`})]}),(0,M.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,"data-slot":`task-commit-file`,title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,onClick:()=>r(e.path),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,M.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:e.path}),(0,M.jsx)(O,{adds:e.adds,dels:e.dels,className:`font-mono text-xs`})]})},e.path))})]})}export{N as TaskCommitsRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Nn as i,et as a,ut as o}from"./project-scope-context-DIcqj4jJ.js";import{B as s,F as c,N as l,Y as u,et as d}from"./queries-DZhNVAD_.js";import{f,g as p,h as m,m as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{S as g,T as _,X as v,Y as y,ot as b,u as x}from"./design-icons-CzEoMH9c.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{n as C,t as w}from"./run-header-DZoOLIBZ.js";import{a as T,i as E,n as D,o as O,r as k}from"./file-preview-CTPfK-oR.js";import{t as A}from"./button-B7MKxYjT.js";import{c as j}from"./page-shell-7pLJMOgh.js";import{t as M}from"./centered-state-V15AR_qo.js";import{C as N,Jn as P,rr as F,w as I}from"./index-CGdnowj-.js";import{r as L}from"./markdown-CJzxFk0P.js";var R=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),z=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),B=e(t(),1),V=n();function H({runId:e,path:t,artifactId:n,worktreePath:r}){let i=s(e,n?null:t),c=l(e,n),u=n?c:i,d=(0,B.useContext)(L),p=f(),m=p.pathname.replace(/\/files\/?$/,`/report`)+p.search,h=u.data,g=(0,B.useMemo)(()=>h?.type===`file`&&h.source!==`artifact`?{runId:e,...d,basePath:h.path}:null,[h,d,e]);if(!t&&!n)return(0,V.jsx)(k,{runId:e,path:null,className:`min-w-0 flex-1`});if(u.isPending)return(0,V.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(u.isError)return(0,V.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,V.jsx)(`h2`,{children:`Could not load this file`}),(0,V.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:u.error.message}),(0,V.jsx)(A,{variant:`outline`,onClick:()=>void u.refetch(),children:`Retry`})]});if(!h)return(0,V.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});let _=E(h.path,r,t);if(h.type!==`file`)return(0,V.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,V.jsx)(`h2`,{children:h.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,V.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:_}),(0,V.jsx)(`p`,{className:`text-sm`,children:h.reason}),(0,V.jsx)(A,{variant:`outline`,onClick:()=>void u.refetch(),children:`Retry`})]});let v=h.artifact;return(0,V.jsx)(L.Provider,{value:g,children:(0,V.jsx)(D,{runId:e,entry:h,displayPath:_,documentPreview:!0,readerHref:m,className:`min-w-0 flex-1`,imageUrl:v?a(e,v.id,`image`):o(e,t),...v?{downloadUrl:a(e,v.id,`download`),snapshot:new Date(v.createdAt).toLocaleString()}:{}},v?.id??h.path)})}var U=new Map;function W(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var G=(0,B.createContext)(null);function K(){let{key:e}=f(),t=h()===`POP`,[n,r]=(0,B.useState)({key:e,generation:0});if(n.key===e)return n.generation;let i={key:e,generation:t?n.generation+1:n.generation};return r(i),i.generation}var q=()=>document.querySelector(`[data-slot="main"]`);function J(e,t){let n=(0,B.useRef)(null),r=f(),i=h()===`POP`?r.key:W(r.state),[a]=(0,B.useState)(()=>{let t=i?U.get(i):void 0;return t?.runId===e?t:null}),o=(0,B.useRef)(new Set(a?.folders??[])),s=(0,B.useRef)(new Set),[c,l]=(0,B.useState)(0),u=(0,B.useRef)(a===null),d=(0,B.useCallback)(()=>{u.current&&U.set(r.key,{runId:e,folders:new Set(o.current),tree:n.current?.scrollTop??0,main:q()?.scrollTop??0})},[r.key,e]),p=(0,B.useMemo)(()=>({isOpen:e=>o.current.has(e),setOpen:(e,t)=>{t?o.current.add(e):o.current.delete(e),d()},loading:(e,t)=>{a?.folders.has(e)&&(t?s.current.add(e):s.current.delete(e),l(s.current.size))}}),[a,d]);return(0,B.useEffect)(()=>{if(u.current||!a||!t||s.current.size>0)return;n.current&&(n.current.scrollTop=a.tree);let e=q();e&&(e.scrollTop=a.main),u.current=!0,d()},[a,t,c,d]),(0,B.useEffect)(()=>{d();let e=[n.current,q()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,d,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,d)}},[d]),{tree:n,folders:p}}function Y({runId:e,selected:t,onSelect:n}){return(0,V.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,V.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,V.jsx)(X,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function X({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=d(e,t),o=(0,B.useContext)(G);return(0,B.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,V.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,V.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,V.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,V.jsx)(V.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,V.jsx)(Z,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,V.jsx)(Q,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function Z({runId:e,name:t,path:n,depth:i,selected:a,onSelect:o}){let s=(0,B.useContext)(G),[c,l]=(0,B.useState)(()=>s?.isOpen(n)??!1);return(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+i*14}px`},children:[(0,V.jsx)(x,{size:16,"aria-hidden":`true`,className:r(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,V.jsx)(_,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,V.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,V.jsx)(X,{runId:e,path:n,depth:i+1,selected:a,onSelect:o})}):null]})}function Q({name:e,path:t,size:n,depth:i,selected:a,onSelect:o}){let s=a===t,c=O(t)?z:g;return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>o(t),className:r(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+i*14}px`},children:[(0,V.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,V.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-xs tabular-nums text-soft-foreground`,children:T(n)})]})})}function $(){let{id:e}=m(),t=u(e),n=K();return t.isPending?(0,V.jsx)(I,{tab:`files`}):t.isError?(0,V.jsx)(N,{tab:`files`,error:t.error}):(0,V.jsx)(C,{runId:t.data.id,children:(0,V.jsx)(te,{run:t.data},`${t.data.id}:${n}`)})}function ee(e,t,n,r){let i=s(e,r||n!==null?null:t),a=l(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function te({run:e}){let t=d(e.id,``),n=c(e.id),[r,a]=p(),o=r.get(`path`),s=r.get(`artifact`),l=r.getAll(`path`).length>1||r.getAll(`artifact`).length>1||o!==null&&s!==null,[u,f]=(0,B.useState)(o??``);(0,B.useEffect)(()=>f(o??``),[o]);let m=(e,t)=>{let n=new URLSearchParams(r);n.delete(`path`),n.delete(`artifact`),n.set(e,t),a(n)},h=t.isError&&t.error instanceof i&&t.error.status===409,g=ee(e.id,o,s,l),_=J(e.id,!t.isPending&&g);return(0,V.jsxs)(j,{route:`task-files`,density:ne(t.isError),flushPadding:!0,children:[(0,V.jsx)(w,{run:e,tab:`files`}),(0,V.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-4 pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),u.trim()&&m(`path`,u.trim())},children:[(0,V.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,V.jsx)(v,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,V.jsx)(P,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:u,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,V.jsx)(A,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!u.trim(),children:`Open file`})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-4 py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,V.jsxs)(`aside`,{ref:_.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,V.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,V.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,V.jsx)(M,{icon:h?(0,V.jsx)(R,{}):(0,V.jsx)(b,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,V.jsx)(G.Provider,{value:_.folders,children:(0,V.jsx)(Y,{runId:e.id,selected:o,onSelect:e=>m(`path`,e)})}),(0,V.jsx)(re,{artifacts:n,artifactId:s,onSelect:e=>m(`artifact`,e)})]}),l?(0,V.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):o!==null||s!==null||t.isSuccess?(0,V.jsx)(H,{runId:e.id,path:o,artifactId:s,worktreePath:e.worktreePath}):null]}),(0,V.jsx)(`p`,{className:`px-4 pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}function ne(e){return e?`empty`:`full`}function re({artifacts:e,artifactId:t,onSelect:n}){return(0,V.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),e.isPending?(0,V.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):e.isError?(0,V.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):e.data.artifacts.length===0?(0,V.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,V.jsx)(`ul`,{children:e.data.artifacts.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-slot":`artifact-row`,"aria-current":e.id===t?`true`:void 0,className:`group flex min-h-11 w-full items-center gap-2 rounded px-2 py-2 text-left text-xs text-foreground hover:bg-muted focus-visible:ring-2 aria-[current=true]:bg-muted aria-[current=true]:font-medium`,onClick:()=>n(e.id),children:[(0,V.jsx)(F,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 wrap-anywhere underline-offset-2 group-hover:underline`,children:e.name}),(0,V.jsx)(x,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-foreground`})]})},e.id))}),(0,V.jsxs)(A,{variant:`outline`,size:`sm`,"data-action":`refresh-artifacts`,className:`mt-2 max-md:h-11 no-hover:h-11`,onClick:()=>void e.refetch(),children:[(0,V.jsx)(y,{"aria-hidden":`true`}),`Refresh published files`]})]})}export{$ as TaskFilesRoute};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{n as t}from"./utils-DSMR_WLb.js";import{G as n,pi as r}from"./project-scope-context-DIcqj4jJ.js";import{Bt as i,Qt as a,Y as o,bt as s,o as c,r as l,vt as u,xt as d}from"./queries-DZhNVAD_.js";import{h as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{g as p,p as m}from"./tasks-table-BNFYIwtc.js";import{F as h,ot as g,p as _}from"./design-icons-CzEoMH9c.js";import{t as v}from"./run-header-DZoOLIBZ.js";import{t as y}from"./external-link-BE6y205O.js";import{u as b}from"./reference-chip-DSJSqjmO.js";import{t as x}from"./button-B7MKxYjT.js";import{t as S}from"./project-router-CZ89wg-5.js";import{c as C}from"./page-shell-7pLJMOgh.js";import{t as w}from"./centered-state-V15AR_qo.js";import{C as T,S as E,er as D}from"./index-CGdnowj-.js";import{n as O,o as k,t as A}from"./use-hand-to-agent-state-DqCW8Giu.js";var j=e(),M={issue:`Issue`,pr:`Pull request`};function N({kind:e}){let{id:t}=f(),n=o(t);return n.isPending?(0,j.jsx)(E,{kind:e}):n.isError?(0,j.jsx)(T,{tab:`github-item`,error:n.error}):(0,j.jsx)(P,{run:n.data,kind:e})}function P({run:e,kind:t}){let{n}=f(),r=Number(n),i=s(),a=d(),o=u(),l=a.isPending||o.isPending,p=m(e,i).some(e=>e.kind===t&&e.number===r),h=c(t,r,p);return(0,j.jsxs)(C,{route:`task-github-item`,density:p?`full`:`empty`,flushPadding:!0,children:[(0,j.jsx)(v,{run:e,tab:{kind:t,number:r}}),p?(0,j.jsx)(H,{run:e,kind:t,number:r,repoBase:i,item:h}):l?(0,j.jsx)(E,{kind:t,number:r,heading:`h2`}):(0,j.jsx)(w,{icon:(0,j.jsx)(D,{size:16}),tone:`neutral`,heading:`h2`,title:`#${n} is not linked to this task`,subtitle:`Only the issues and pull requests this task references open here.`,actions:(0,j.jsx)(x,{asChild:!0,variant:`outline`,children:(0,j.jsx)(S,{to:`/tasks/${e.id}`,children:`Back to the session`})})})]})}function F(e,t){return e===`pr`&&t.data?.available===!0&&t.data.item!==null}function I(e,t,n,r){return e===`pr`?n?.[t]??r:r}function L({retry:e,kind:t,number:n}){return(0,j.jsx)(x,{variant:`outline`,disabled:e.isPending,onClick:()=>e.mutate(i.githubItem(t,n)),children:`Retry`})}function R({kind:e,number:t,error:n,retryButton:r}){return(0,j.jsx)(w,{icon:(0,j.jsx)(g,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load ${M[e].toLowerCase()} #${t}`,subtitle:n.message,actions:r})}function z({run:e,kind:n,number:r,repoBase:i,reason:a,retryError:o,retryButton:s}){let c=n===`pr`?h:_,l=p(e,i).find(e=>e.kind===`PR`==(n===`pr`)&&e.number===r)?.url;return(0,j.jsx)(w,{icon:(0,j.jsx)(c,{size:16}),tone:`neutral`,heading:`h2`,title:`GitHub is unavailable`,subtitle:o?.message??a,actions:(0,j.jsxs)(j.Fragment,{children:[s,l&&t(l)?(0,j.jsx)(x,{asChild:!0,variant:`outline`,children:(0,j.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,children:[`open on GitHub`,(0,j.jsx)(y,{"aria-hidden":`true`})]})}):null]})})}function B({label:e,repoBase:t}){return(0,j.jsx)(w,{icon:(0,j.jsx)(b,{}),tone:`neutral`,heading:`h2`,title:`${e} was not found in ${U(t)}`,subtitle:`It may have been deleted, or the number points at a different repository.`})}function V({kind:e,item:t,labelColors:n,checks:r}){return(0,j.jsx)(`div`,{className:`min-w-0 px-0.5 md:px-2`,children:(0,j.jsx)(k,{item:t,colors:n??{},checks:r,backLink:null,subNav:null,children:e===`issue`?(0,j.jsx)(W,{item:t},t.url):null})})}function H({run:e,kind:t,number:i,repoBase:o,item:s}){let c=r(),u=a({mutationFn:e=>n(t,i,{refresh:!0}),onSuccess:(e,t)=>c.setQueryData(t,e)}),d=F(t,s),f=l(d?[i]:[],d),p=f.data?.available?f.data.checks:void 0,m=`${M[t]} #${i}`,h=(0,j.jsx)(L,{retry:u,kind:t,number:i});if(s.isPending)return(0,j.jsx)(E,{kind:t,number:i,heading:`h2`});if(s.isError)return(0,j.jsx)(R,{kind:t,number:i,error:u.error??s.error,retryButton:h});let g=s.data;return g.available?g.item?(0,j.jsx)(V,{kind:t,item:g.item,labelColors:g.labelColors,checks:I(t,i,p,g.item.checks)}):(0,j.jsx)(B,{label:m,repoBase:o}):(0,j.jsx)(z,{run:e,kind:t,number:i,repoBase:o,reason:g.reason,retryError:u.error,retryButton:h})}function U(e){if(!e)return`this repository`;try{return new URL(e).pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`)||`this repository`}catch{return`this repository`}}function W({item:e}){let t=A();return(0,j.jsx)(O,{item:e,workflows:t.workflows.data?.workflows??[],skills:t.skillList,workflow:t.workflow,onWorkflowChange:t.setWorkflow,selectedSkills:t.selectedSkills,onSkillsChange:t.setSelectedSkills,engine:t.engine,onEngineChange:t.setEngine,queuedRunId:t.queued.get(e.url)??null,onQueued:t.onQueued},e.url)}export{N as TaskGithubItemRoute};
@@ -1 +0,0 @@
1
- import{$n as e,Bn as t,Cn as n,Ir as r,On as i,kn as a}from"./project-scope-context-DIcqj4jJ.js";import"./queries-DZhNVAD_.js";import"./attention-80jX8HhC.js";function o(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function s(e,t){return e?.backend??t?.runner??`claude`}function c(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function l(e){let t=o(e.steps),n=c(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:s(n,e),profileId:n?.profileId}}function u(e){return e.command===void 0&&e.kind!==`plugin`}function d(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=o(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function f(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(u);let r=d(e);return(r?n.find(e=>e.id===r&&u(e)):void 0)??[...n].reverse().find(u)}var p=new Set([`queued`,`running`,`waiting`]);function m(e){return p.has(e)}function h(t){return e(t)?!1:t.status===`queued`||t.status===`running`||t.status===`waiting`}function g(e){return h(e)&&e.status!==`queued`}function _(e,n,r){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||r!==void 0&&t(e)!==r?!1:n===`unpinned`?!e.pinned:n!==`pinned`||e.pinned===!0}var v=[`done`,`failed`];function y(t){return t.archived||e(t)||!v.includes(t.status)?!1:t.finishedAt!==void 0}function b(e){let t=e.finishedAt;return t===void 0||!y(e)?!1:e.seenAt===void 0||e.seenAt<t}var x=[`Needs you`,`Finished`,`Working`,`Archived`],S={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},C=3,w=t=>e(t)?C:S[t.status]??9;function T(e){let t=e=>n[i(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||w(e)-w(n))[0]}function E(e,t){return t===`archived`?`Archived`:a(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function D(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function O(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function k(e,t){return t!==void 0&&O(e).ref===t}function A(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function j(t,n){return t.filter(e=>n===`archived`?e.archived:!e.archived).sort((t,r)=>{if(n!==`archived`){let e=Number(!!r.pinned)-Number(!!t.pinned);if(e!==0)return e}let i=w(t)-w(r);if(i!==0)return i;if(e(t)&&e(r)){let e=t.autoResumeAt.localeCompare(r.autoResumeAt);if(e!==0)return e}return t.status===`queued`&&r.status===`queued`?t.createdAt.localeCompare(r.createdAt):r.createdAt.localeCompare(t.createdAt)})}function M(e){return e.delegation?.role===`worker`}function N(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!M(n)?e:n.delegation?.parentRunId??e}function P(e,t,n=A(e)){let r=j(e,t).filter(e=>!M(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(E(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return x.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function F(e,t={}){let n=typeof t==`number`?{overall:t}:r(t),i={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},a=[],o=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[i[t.label]]??1/0,r=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:o<=0||e<=0?!1:(--o,--e,!0)});r.length&&a.push({label:t.label,rows:r})}return a}function I(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function L(e){let t=0,n=0,r=0;for(let i of e)if(!M(i)){if(i.archived){n+=1;continue}t+=1,a(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function R(e,n,r){return e.filter(e=>!e.archived&&(!r||t(e)===(n===`automations`)))}var z={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},B=Object.keys(z),V=`section`;function H(e,t,n){let r=`${V}=${z[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function U(e){return B.find(t=>z[t]===e)??null}function W(e,n){let r={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let i of e){if(M(i)||i.archived)continue;let e=+!!a(i);n&&t(i)?(r.automations+=1,r.automationsWaiting+=e):(r.active+=1,r.activeWaiting+=e)}return r}export{_ as C,s as D,o as E,f as O,g as S,l as T,O as _,P as a,h as b,T as c,k as d,D as f,R as g,W as h,F as i,U as l,N as m,V as n,M as o,H as p,B as r,L as s,x as t,A as u,I as v,b as w,m as x,y};
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{l as i,n as a,t as o}from"./utils-DSMR_WLb.js";import{a as s,m as c,o as l,s as u,u as d}from"./live-reads-Cgk2XbiP.js";import{$n as f,Jn as p,Mn as m,Nn as h,On as g,Ot as _,Qr as v,Xn as y,Yn as b,Zr as x,_r as S,dt as C,gr as w,it as T,jn as E,lr as D,nt as O,ot as k,pi as A,qn as j,st as M,ti as ee,tr as te,tt as N}from"./project-scope-context-DIcqj4jJ.js";import{n as P}from"./toaster-0sM0sfWx.js";import{$ as F,Bt as I,G as L,J as R,Jt as z,P as B,Qt as V,R as H,St as U,V as ne,Xt as re,Y as ie,Zt as ae,_ as oe,bt as se,ct as ce,nt as le,ot as ue,rt as de,ut as fe,vt as pe,z as me}from"./queries-DZhNVAD_.js";import{f as he,h as W,n as ge,p as _e}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as ve,m as ye,r as be,s as xe,v as Se}from"./tasks-table-BNFYIwtc.js";import{A as Ce,B as we,F as Te,K as Ee,X as De,a as Oe,at as ke,c as Ae,dt as je,f as Me,g as Ne,h as Pe,it as Fe,k as Ie,l as Le,m as Re,n as ze,ot as Be,p as Ve,s as He,u as G,ut as Ue,v as We,y as Ge,z as Ke}from"./design-icons-CzEoMH9c.js";import{t as qe}from"./createLucideIcon-BHp8sXmF.js";import{a as Je,c as Ye,i as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./run-header-DZoOLIBZ.js";import{t as nt}from"./chevron-right-BENZ-1ZN.js";import{t as rt}from"./external-link-BE6y205O.js";import{t as it}from"./eye-B8okNWXU.js";import{n as at}from"./smartphone-Lr8Ug2z_.js";import{t as ot}from"./loader-circle-CPBhhDbB.js";import{t as st}from"./message-square-B-MD-8rD.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./thread-state-DMWi6eLk.js";import{i as _t,o as vt,t as yt,u as bt}from"./reference-chip-DSJSqjmO.js";import{t as xt}from"./square-terminal-B6RYYieR.js";import{t as K}from"./button-B7MKxYjT.js";import{n as q,r as J,t as Y}from"./collapsible-BEV4FO-1.js";import{a as St}from"./popover-BPgUYFyu.js";import{s as Ct,t as X}from"./project-router-CZ89wg-5.js";import"./attention-80jX8HhC.js";import{D as wt,E as Tt,O as Et,S as Dt,b as Ot,f as Z,u as kt,w as At,x as jt}from"./task-groups-DK0I9p71.js";import{t as Mt}from"./status-dot-BRzVlF2X.js";import{c as Nt}from"./page-shell-7pLJMOgh.js";import{n as Pt,t as Ft}from"./centered-state-V15AR_qo.js";import{$t as It,Bn as Lt,Dn as Rt,En as zt,F as Bt,G as Vt,Hn as Ht,I as Ut,K as Wt,M as Gt,N as Kt,P as qt,Qn as Jt,Rn as Yt,Vn as Xt,W as Zt,X as Qt,Y as $t,_n as en,an as tn,bn as nn,dn as rn,en as an,fn as on,gn as sn,i as cn,in as ln,j as un,l as dn,ln as fn,m as pn,mn,n as hn,nn as gn,on as _n,pn as vn,rr as yn,s as bn,un as xn,x as Sn,y as Cn,yn as wn,zn as Tn}from"./index-CGdnowj-.js";import{i as En,r as Dn}from"./highlighter-DvLzHjjY.js";import{t as On}from"./zoomable-image-CIQl1Wpe.js";import{i as kn,r as An,t as jn}from"./markdown-CJzxFk0P.js";import{r as Mn}from"./html-report-BX3msvci.js";import{i as Nn}from"./automation-format-DB34jUyF.js";import{t as Pn}from"./textarea-vJt9undk.js";import{t as Fn}from"./report-title-D4Mbu2Er.js";var In=qe(`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`}]]),Ln=qe(`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`}]]),Rn=qe(`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`}]]),zn=qe(`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`}]]),Bn=qe(`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`}]]),Vn=qe(`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`}]]),Hn=qe(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=r(),Un=12;function Wn({run:e}){let t=A(),n=V({mutationFn:()=>N(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:I.runs.detail(e.id)}),t.invalidateQueries({queryKey:I.runs.list()}),P(`This task will not resume itself`)},onError:e=>P(e.message,{tone:`danger`})});if(!f(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,$.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Mt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,$.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Un,`)`]}):(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,$.jsx)(ge,{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 Gn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Kn=/^[A-Za-z0-9_./:=+,@%-]+$/;function qn(e){return e.replaceAll(`'`,`'\\''`)}function Jn(e){return e===``?`''`:Kn.test(e)?e:`\u0027${qn(e)}\u0027`}function Yn(e){if(!Gn(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(Jn).join(` `)}}function Xn(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 Zn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Qn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function $n(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function er(e){let t=Xn(Zn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))$n(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]){$n(e[2])&&i.push({label:Qn(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:Qn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&$n(t)&&i.push({label:t,href:t})}return i}var tr=(0,Q.createContext)(void 0),nr=(0,Q.createContext)(void 0);function rr(e,t){let n=new Map;for(let r of er(e)){let e=kn(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 ir(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function ar({text:e,messageKey:t}){let n=(0,Q.useContext)(An),r=(0,Q.useContext)(nr),i=t??r;if(!n||i===void 0)return null;let a=rr(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(or,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function or({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,Q.useContext)(tr),s=(0,Q.useContext)(Cn);(0,Q.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=B(r,n),l=he(),u=_e();if(c.isError)return(0,$.jsx)(ge,{id:ir(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:l.pathname+l.search},children:i});let d=c.data?.artifact;if(d&&!Mn(d.name))return null;let f=new URLSearchParams(l.search);f.set(`report`,n),f.set(`card`,t);let p=new URLSearchParams(l.search).has(`report`)?l.state:null,m=new URLSearchParams(l.search);m.delete(`report`),m.delete(`card`);let h=`${l.pathname}${m.size?`?${m}`:``}`,g=window.navigation,_={reportCardEntry:!0,reportReturnTo:p?.reportReturnTo??h,reportReturnKey:p?.reportReturnKey??g?.currentEntry?.key,reportScrollTop:p?.reportScrollTop},v={pathname:l.pathname,search:`?${f}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,$.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,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:d?Fn(d):i}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(ge,{id:ir(t,n),to:v,state:_,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=_.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;u(v,{state:{..._,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 sr={message:!0,reasoning:!0,tool:!0,hook:!0};function cr(e){return Object.hasOwn(sr,e)&&sr[e]}var lr=e=>e.kind===`tool`,ur=e=>e.kind===`conversation`,dr=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,fr=(e,t,n)=>`${e} ${e===1?t:n}`;function pr(e,t){let n=[];return e>0&&n.push(fr(e,`file`,`files`)),t>0&&n.push(fr(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function mr(e){return`${e} earlier tool call${e===1?``:`s`}`}var hr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function gr(e){for(let t of hr)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 _r=new WeakMap;function vr(e){let t=_r.get(e);if(t)return t;let n=yr(e);return _r.set(e,n),n}function yr(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(lr).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=cr(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:pr(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 br(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(ur(e)){s(),c.push(e);continue}l(),lr(e)&&dr(e)&&!r.has(e.id)?o.push(e):(s(),lr(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 br(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 xr=new Map,Sr=(0,Q.createContext)(null);function Cr(){return(0,Q.useContext)(Sr)}function wr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>xr.get(e)?.get(t),set:(t,n)=>{let r=xr.get(e)??new Map;r.set(t,n),xr.set(e,r)}}),[e]);return(0,$.jsx)(Sr.Provider,{value:n,children:t})}function Tr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function Er(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Dr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function Or(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function kr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Ar=new Map;function jr(e,t){Ar.set(e,t)}function Mr(e){return Ar.get(e)}var Nr=new Map;function Pr(e,t){Nr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Fr(e){return Nr.get(e)}function Ir(e,t,n){let r=Nr.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 Lr=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Rr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),zr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Br=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Vr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Hr(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Ur(e){let t=Hr(e);return t===void 0?void 0:Lr.format(t)}function Wr(e){let t=Hr(e);return t===void 0?void 0:Rr.format(t)}var Gr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Kr(e){let t=Hr(e);return t===void 0?void 0:Gr(t)}function qr(e,t=new Date){let n=Hr(e);if(n===void 0)return;let r=Gr(n);return r===Gr(t)?`Today`:r===Gr(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?zr:Br).format(n)}function Jr(e,t){let n=Hr(e),r=Hr(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 Yr({ts:e}){let t=Ur(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Wr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Xr({startedAt:e,completedAt:t}){let n=Ur(t);if(n===void 0)return null;let r=Jr(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:Wr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Zr({ts:e}){let t=qr(e),n=Hr(e);if(t===void 0||n===void 0)return null;let r=Vr.format(n);return(0,$.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:Kr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Qr={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function $r({note:e}){return e.icon===`handoff`?(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,$.jsx)(Jt,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,$.jsxs)(Y,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:o(`flex items-start gap-2`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,$.jsxs)(J,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] 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,$.jsx)(G,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-[11px] text-muted-foreground`,children:e.details.map((e,t)=>(0,$.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,$.jsxs)(`span`,{className:`font-sans font-medium text-foreground/80`,children:[Qr[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:o(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var ei={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 ti({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let s=ei[e],c=r===void 0?void 0:Ur(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":s.speaker,className:o(`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,$.jsxs)(`p`,{className:o(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(st,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(Yr,{ts:r})})]}),(0,$.jsx)(`div`,{className:o(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var ni=[],ri=(0,Q.memo)(function({text:e,imageCount:t=0,images:n=ni,ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,$.jsxs)(ti,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,$.jsx)(ot,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)(ti,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Hn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(ke,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(jn,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>D(e.split(`/`).pop()??``)?(0,$.jsx)(On,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(Ee,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),ii=`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`,ai=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function oi(e,t){let n=e.cloneNode(!0);n.querySelectorAll(ai).forEach(e=>e.remove());let r=er(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||!$n(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 si(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=oi(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 ci=(0,Q.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await si(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)(ti,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:ii,children:[(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:ii,children:[(0,$.jsx)(yn,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(jn,{breaks:!0,children:e})}),(0,$.jsx)(ar,{text:e,messageKey:n})]})});function li({incident:e}){let t=c().data;if(!t)return null;let n=u(t,e.provider);return(0,$.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,$.jsx)(X,{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 ui=(0,Q.memo)(function({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
2
- `,1)[0]??``,r=n.length<e.length;return(0,$.jsxs)(Y,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,$.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,$.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,$.jsx)(jn,{inline:!0,children:n})}),r?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,$.jsx)(J,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,$.jsx)(jn,{children:e})})})]})});function di(){return(0,$.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,$.jsx)(ot,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var fi={read:yn,edit:Hn,delete:ke,move:Bn,search:De,execute:xt,think:Ln,fetch:at,task:He,plan:we,other:je},pi=e=>e.split(`
3
- `).length;function mi({text:e,streaming:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=pi(e),c=!t&&!n&&s>12;return(0,$.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=Or(e.currentTarget)}:void 0,className:o(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,$.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,$.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,$.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function hi({diffs:e}){return(0,$.jsx)($.Fragment,{children:e.map((e,t)=>(0,$.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,$.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...gi(e.oldText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...gi(e.newText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
- `).map((e,t)=>(0,$.jsx)(_i,{text:e},t))})]},`${e.path}:${t}`))})}function gi(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
- `)}function _i({text:e}){return(0,$.jsx)(`span`,{className:o(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function vi(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function yi(e){let t=e.status===`running`||e.status===`pending`,n=gr(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`?Yn(e.input):ht(e.name).toolKind===e.toolKind?pt(e.name,e.input):void 0)??i,Icon:fi[e.toolKind]??je}}function bi(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 xi({item:e,busy:t}){return(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,$.jsx)(ot,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,$.jsx)(`span`,{"data-slot":`tool-exit`,className:o(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function Si({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,$.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,$.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,$.jsx)(hi,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,$.jsx)(mi,{text:e.output,streaming:n}):null,r.length>0?(0,$.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function Ci({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=Cr(),[a,s]=(0,Q.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}=yi(e),m=bi(e,t.length),h=f!==void 0||m,g=h&&(a??(m&&vi(e)));return(0,$.jsxs)(Y,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:c,className:o(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(J,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:o(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,$.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:o(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,$.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,$.jsx)(xi,{item:e,busy:l})]}),(0,$.jsx)(q,{children:(0,$.jsx)(Si,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function wi(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function Ti({item:e,cacheKey:t}){let n=Cr(),[r,i]=(0,Q.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=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=wi(e);return(0,$.jsxs)(Y,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:o(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,$.jsxs)(J,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,$.jsx)(In,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,$.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,$.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,$.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,$.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:o(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,$.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,$.jsxs)(Y,{className:`border-t border-border`,children:[(0,$.jsxs)(J,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,$.jsxs)(q,{children:[e.stdout?(0,$.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,$.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function Ei({group:e,scope:t}){return(0,$.jsxs)(Y,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,$.jsxs)(J,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,$.jsx)(Ci,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Di({count:e,children:t}){return(0,$.jsxs)(Y,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,$.jsxs)(J,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),mr(e)]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Oi({image:e}){return(0,$.jsx)(On,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function ki(e,t,n,r){return Et(e,t)?.runner??e.runner??(t||n?r:void 0)??`claude`}function Ai(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 ji(e,t,n,r,i){if(!e)return t!==null||!n||r?i:void 0}function Mi(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 Ni(){let e=U(),t=c();return{providers:e,registered:t,providersPending:e.isPending||t.isPending,providersError:e.isError||t.isError,providersReady:e.isSuccess&&t.isSuccess}}function Pi(e,t=null){let{registered:n,providersPending:r,providersError:i,providersReady:a}=Ni(),o=oe(),s=_n(e),c=e.removedRunner!==void 0,u=s&&!e.runner||c,f=nn(),p=e.delegation?.role===`worker`,m=o.data?.defaultRunner,h=ki(e,s,c,l(m,d(n.data))??m),g=(t,n)=>vn(e,t,f.repoAccount,{original:h,target:n},s),{runners:_,signedOut:v}=f.runnersOn(e=>g(e,e)),y=p?h:Ut(t,_,h),b=_.includes(h),x=s?te(e.workflowDef,y,d(n.data)):[y],S=s&&p&&e.workflowDef?Ai(e,y,f):x.filter(e=>!f.readyOn(e,g(e,y))),C=a&&(!u||o.isSuccess)&&S.length===0,w=Mi({needsConfig:u,configPending:o.isPending,configError:o.isError,providersPending:r,providersError:i,canContinue:C,untouched:s,missing:S});return{runners:_,signedOut:v,currentRunner:h,runner:y,currentRunnerConnected:b,canContinue:C,providerPending:r||u&&o.isPending,providerError:i,reason:w,runnerOverride:ji(p,t,b,c,y)}}function Fi(e,t,n,r,i,a,o,s,c){let l=Et(e,_n(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=Kt(t,o,a,[p,f?.[t]]),h=Bt(p,t,o,f,a),g=Gt(h,a),_=r?``:c??d??``,v=qt(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function Ii(e,t,n,r){let i=Tt(e.steps),a=Et(e,_n(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function Li(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 Ri(e,t,n,r){return!!t&&(r!==wt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function zi({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function Bi(e){let t=ce(),n=on(e).continueRun,r=oe(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[l,d]=(0,Q.useState)(null),f=`${e.id}:${Et(e,_n(e))?.id??``}`,[p,m]=(0,Q.useState)(f);p!==f&&(m(f),a(null),s(null),d(null));let g=Pi(e,i),{runners:_,canContinue:v,currentRunner:y,runner:b}=g,{sessionStep:x,workerStep:S,account:C}=Ii(e,b,b!==y,wn().repoAccount),w=pe(),E=w.data?.capabilities?.localHandoff!==!1,D=c(),O=z(b,n&&!w.isPending&&!D.isPending,E?C:null),k=r.data?.modelsLocked===!0,A=b!==y,j=Fi(e,b,A,k,r.data,O.data,D.data,o,l),{models:M,model:ee,effortOptions:te,effort:N}=j,{modelLabel:P,effortLabel:F}=zi(j),I=V({mutationFn:({text:t,images:n})=>v?T(ae(e.id),Li(t,n,g.runnerOverride,k,A,o,l,j)):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onMutate:()=>ae(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof h&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),L=e.delegation?.role===`worker`;return{skillRunner:b,skillAccount:C,available:n,canContinue:v,startsNewConversation:Ri(e,x,S,b),reason:g.reason,providerPending:g.providerPending,pills:(0,$.jsx)(Vi,{compact:e.status===`review`,summary:`${u(D.data,b)} · ${P} · ${F}`,children:(0,$.jsxs)(Vt,{children:[!L&&(_.length>1||g.signedOut.length>0)?(0,$.jsx)(Wt,{icon:(0,$.jsx)(Fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,signedOut:g.signedOut,value:b,onPick:e=>{e!==b&&(a(e),s(null))}}):(0,$.jsx)(Zt,{icon:(0,$.jsx)(Fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:L?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:b,value:b,onPick:()=>{},options:[{value:b,label:b}]}),(0,$.jsx)(Zt,{icon:(0,$.jsx)(Ge,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:P,value:ee,readOnly:k,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=Gt(e,O.data);N!==``&&qt(N,t)===``&&d(``)},options:M.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:un(b,D.data,O)}),(0,$.jsx)(Zt,{icon:(0,$.jsx)(Ie,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:F,value:N,readOnly:k,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>d(e),options:te.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},f),continueWith:(e,t)=>I.mutateAsync({text:e,images:t})}}function Vi({compact:e,summary:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null),o=e&&!r;return(0,Q.useEffect)(()=>{r&&a.current?.querySelector(`button:not([disabled])`)?.focus()},[r]),(0,$.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,$.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,$.jsx)(Fe,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,$.jsx)(Le,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var Hi=120,Ui=e=>e!==`pending`&&e!==`running`,Wi=e=>e.kind===`tool`&&e.toolKind===`task`,Gi=e=>Wi(e)&&e.parentItemId===void 0,Ki=e=>cr(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function qi(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 Ji(e){if(e.kind===`tool`)return Yi(e.title);if(e.kind===`hook`)return Yi(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
6
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Yi(n)}}}function Yi(e){return e.length>Hi?`${e.slice(0,Hi-1).trimEnd()}…`:e}function Xi(e,t=!1,n=e){let r=ea(e,e=>e.items.some(Gi));if(r===-1)return[];let i=e=>!t&&!Ui(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(Gi);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(Gi)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>Zi(r,ia(n,e,r.id),t))}function Zi(e,t,n){let r={id:e.id,title:gr(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=qi(e);i!==void 0&&(r.agentType=i),n&&!Ui(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Ji(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Qi(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function $i(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function ea(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function ta(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&&Gi(e));if(a!==void 0)return Zi(a,ia(r,e,t),n)}}function na(e,t){return ea(e,e=>e.items.some(e=>e.id===t&&Gi(e)))}function ra(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)Ki(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function ia(e,t,n){let r=na(t,n);if(r===-1)return[];let i=ra(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 ra(e,n,Math.max(na(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:aa(t,e))}return[...s.values()].sort(oa).map(({entry:e})=>e)}function aa(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 oa(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function sa(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`?vr(e.children).flatMap(n=>sa(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>sa(e,t)):[]}function ca(e){return e.flatMap((e,t)=>e.content.kind===`block`?sa(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function la(e,t,n,r){let i=(0,Q.useContext)(Cn),{projectId:a}=W(),o=(0,Q.useMemo)(()=>ca(t),[t]);(0,Q.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=rr(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=ir(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 ua(e){let t=A();return V({mutationFn:t=>M(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:I.runs.all})}})}var da=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),fa=()=>navigator.onLine;function pa({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,$.jsx)(ha,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,$.jsx)(ma,{permission:e,runId:t},e.requestId)}function ma({permission:e,runId:t}){let n=ua(t),r=(0,Q.useSyncExternalStore)(da,fa,()=>!1),i=(0,Q.useRef)(!1),[a,o]=(0,Q.useState)(`pending`),[s,c]=(0,Q.useState)(),[l,u]=(0,Q.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof h&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,$.jsx)(ha,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function ha({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Q.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,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,$.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,$.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,$.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,$.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,$.jsx)(K,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,$.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}function ga(e,t){if(e.length===1)return[t.replace(RegExp(`^${_a(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 _a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function va(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}function ya({ask:e}){let t=e.answer===void 0?void 0:ga(e.questions,e.answer);return(0,$.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=va(n,i),o=i!==void 0&&a.length===0;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,$.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,$.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,$.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,$.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,$.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,$.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,$.jsx)(ba,{text:i}):null]})]}):i===void 0?null:(0,$.jsx)(ba,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,$.jsx)(ba,{text:e.answer}):null]})}function ba({text:e}){return(0,$.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}var xa=(0,Q.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Sa(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 Ca(e,t,n=[]){let r={};for(let e of n)r[e.id]=Z(e);for(let e of t??[])r[e.id]=Z(e);return r[e.id]=Z(e),r}function wa(e,t){return t?.[e]??`Task`}function Ta(e,t,n){return t?n?.[e]??`peer task`:wa(e,n)}function Ea(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Da(e){return e?.relationship===`peer`}function Oa(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function ka(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 Aa(e){if(e.outcome)return ka(e.outcome.status);if(e.delivery===`not-delivered`)return ja(`not-delivered`)}function ja(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Ma(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`?Da(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${sn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Na({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:wa(e,n),linkable:!0}):(0,$.jsx)(Pa,{id:e,children:r})}function Pa({id:e,children:t}){let n=ie(e);return n.data?t({title:Z(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof h&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Fa={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`}},Ia=`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 La({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,$.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,$.jsx)(Ra,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function Ra({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Ea(e.messages[0]??{senderRunId:e.senderRunId},t),a=Da(e.messages[0]),s=Fa[a?`peer`:i],c=qa(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),l=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>Ta(e,a,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,$.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:o(`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,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`p`,{className:o(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsx)(`span`,{children:l}),c.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,$.jsx)(Na,{id:e,peer:a,taskTitles:n,children:t=>(0,$.jsx)(Ua,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),a?(0,$.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,$.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:Oa(e.kind)}),e.messages.length===1&&d?(0,$.jsx)(Ba,{message:d}):null]}),(0,$.jsx)(za,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,$.jsx)(Ha,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Ma(e,r?.[e.recipientRunId])))].map(e=>e?(0,$.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,$.jsx)(Va,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,$.jsx)(Wa,{message:d,runId:t,taskTitles:n}):null,(0,$.jsx)(Ga,{batch:e,heading:u})]})}function za({at:e,className:t,children:n}){return e===void 0||Ur(e)===void 0?null:(0,$.jsxs)(`span`,{className:t,children:[n,(0,$.jsx)(Yr,{ts:e})]})}function Ba({message:e}){let t=Aa(e),n=ja(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function Va({messages:e,peer:t,runId:n,taskTitles:r}){return(0,$.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Aa(e),a=e.createdAt??e.recordedAt;return(0,$.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(Na,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,$.jsx)(Ua,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,$.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,ja(e.delivery)===i?null:(0,$.jsx)(`span`,{"data-slot":`conversation-delivery`,children:ja(e.delivery)}),(0,$.jsx)(Wa,{message:e,runId:n,taskTitles:r}),(0,$.jsx)(za,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function Ha({batch:e}){let t=Cr(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Q.useState)(()=>t?.get(n)??!1),a=(0,$.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,$.jsx)(jn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,$.jsxs)(Y,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,$.jsxs)(J,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,$.jsx)(q,{children:a})]})}function Ua({view:e,to:t,label:n}){return e.linkable?(0,$.jsx)(X,{className:Ia,to:t,"aria-label":n,children:e.title}):(0,$.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function Wa({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Q.useContext)(xa),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,$.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=Ea(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:o(Ia,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,$.jsx)(Na,{id:i,peer:Da(e.message),taskTitles:n,children:e=>(0,$.jsxs)($.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function Ga({batch:e,heading:t}){return(0,$.jsxs)(Y,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,$.jsxs)(J,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,$.jsx)(G,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,$.jsx)(q,{children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>Ka(e)).map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,$.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function Ka(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Da(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:ja(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 qa(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var Ja=e(n(),1),Ya=`pending-ask`;function Xa(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function Za(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?Xa(t):null}function Qa(e,t){let n=`${Ya}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?Za(r):null}}var $a=`[data-slot="ask-card"][data-pinned="true"]`;function eo(e,t){let[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(!e||typeof IntersectionObserver>`u`||typeof MutationObserver>`u`)return;let n=t.current??document.body,i=null,a=null,o=()=>{let e=n.querySelector($a);if(e===i)return;if(a?.disconnect(),i=e,!i){r(!1);return}let t=document.querySelector(`[data-slot="thread-dock"]`),o=t&&getComputedStyle(t).position===`sticky`?Math.round(t.getBoundingClientRect().height):0;a=new IntersectionObserver(e=>r(e.some(e=>e.isIntersecting)),{rootMargin:`0px 0px -${o}px 0px`}),a.observe(i)};o();let s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!0}),()=>{s.disconnect(),a?.disconnect()}},[e,t]),e&&n}function to(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function no({onGoToQuestion:e}){return(0,$.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,$.jsx)(K,{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 ro(){let e=(0,Q.useRef)(null);return(0,Q.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`[data-slot="main"]`),r=t?.querySelector(`[data-slot="run-header"]`),i=t?.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),t=r.getBoundingClientRect();r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-t.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${io(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(),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 io(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var ao={viewKey:void 0,generation:0},oo=600,so=24;function co(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Q.useRef)(a);o.current=a;let c=(0,Q.useRef)(e);c.current=e;let l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(!0),h=(0,Q.useRef)(!0),g=(0,Q.useRef)(0),_=(0,Q.useRef)(0),v=(0,Q.useRef)(new Set),y=(0,Q.useCallback)(e=>{for(let t of[...v.current])t(e)},[]),b=(0,Q.useCallback)(e=>(v.current.add(e),()=>{v.current.delete(e)}),[]),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),w=(0,Q.useRef)(null),T=(0,Q.useCallback)(e=>{let t=l.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,Q.useCallback)(()=>{let e=l.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`?io(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,Q.useCallback)(()=>{if(l.current){if(C.current!==e){C.current=e,h.current=!0;let t=Mr(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=Fr(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,Q.useCallback)(e=>S.current?.viewKey===e,[]),k=(0,Q.useCallback)(e=>{let t=S.current;return!t||!O(e)||e!==c.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),A=(0,Q.useCallback)(e=>{d(e),e&&(l.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),D())},[n,D]),j=(0,Q.useCallback)(()=>{m.current&&E()},[E]),M=(0,Q.useRef)(!1),ee=(0,Q.useRef)(0),te=(0,Q.useRef)(!1),N=(0,Q.useRef)(void 0),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(!1),I=(0,Q.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),L=(0,Q.useRef)(null),R=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(!s())return;let e=e=>{x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let z=(0,Q.useCallback)(()=>{let e=L.current,t=l.current;if(!e||!t)return;L.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(Dr(t.scrollTop,r,e.anchor,I(t),n))},[I,T]),B=(0,Q.useCallback)(()=>{let e=l.current;if(!e||!r||M.current)return;x.current=null,S.current=null,m.current=!1,M.current=!0;let t=ee.current+1;ee.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,s=Er(a,I(e)),u=s===void 0?-1:o.current.indexOf(s.key),d=c.current,f=R.current;r().then(()=>{c.current===d&&R.current===f&&(L.current={beforeHeight:n,beforeTop:i,anchor:s,anchorIndex:u})},()=>{}).finally(()=>{ee.current===t&&(M.current=!1)})},[I,r]);(0,Q.useEffect)(()=>()=>clearTimeout(N.current),[]);let V=(0,Q.useRef)(null),H=(0,Q.useRef)(0),U=(0,Q.useCallback)(()=>n===`document`?++ao.generation:++H.current,[n]),ne=(0,Q.useCallback)((e,t)=>n===`document`?ao.viewKey===e&&ao.generation===t:c.current===e&&H.current===t,[n]);(0,Q.useEffect)(()=>()=>V.current?.disconnect(),[e,u]);let re=(0,Q.useCallback)((t,n,r,i)=>{let a=l.current;if(!a||!u)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0,p(!0),U(),V.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(V.current?.disconnect(),!0):!1},c=a.querySelector(`[data-slot="run-header"]`),d=c&&getComputedStyle(c).position===`sticky`?io(c):0,f=w.current;if(i!==void 0)T(i);else if(f)f.scrollToIndex(n,{align:`start`,...d>0?{offset:-d}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-d)}s()||(V.current=new MutationObserver(()=>{s()}),V.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),jr(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,U]),ie=(0,Q.useCallback)(t=>{let n=U(),r=c.current;V.current?.disconnect();let a=l.current;if(!a)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),jr(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},s=()=>ne(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!s()||u())return;V.current?.disconnect();let e=new MutationObserver(()=>{s()?u()&&e.disconnect():e.disconnect()});V.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,E,U,ne,y]),ae=a.at(-1),oe=a.length;return(0,Q.useLayoutEffect)(()=>{R.current+=1,L.current=null,M.current=!1,n===`document`?ao.viewKey!==e&&(ao.viewKey=e,ao.generation+=1):H.current+=1},[e,n]),(0,Q.useLayoutEffect)(()=>{let e=L.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?z():L.current=null:m.current&&E()},[ae,oe,z,E]),(0,Q.useLayoutEffect)(()=>{!l.current||!u||D()},[u,D]),(0,Q.useEffect)(()=>{let t=l.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,c,d=()=>{h.current&&!Or(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),c=e},v=()=>{U(),V.current?.disconnect(),x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,R.current+=1,L.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=!te.current;te.current=!0,clearTimeout(N.current),N.current=setTimeout(()=>{te.current=!1},180),e&&Tr(t)&&B()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&Tr(t)&&B()):[`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,F.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,Or(t,80)||(v(),b()))},k=()=>{i=!1},A=e=>{P.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(),!P.current&&Tr(t)&&(P.current=!0,B())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},M=e=>{if(e===0||!i&&Date.now()-_.current>=oo)return;let n=e<0?`up`:`down`;!i&&n!==c||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=so&&(0,Ja.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},ee=()=>{let n=m.current;M(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!F.current&&t.scrollTop<a&&Tr(t)&&(F.current=!0,B()),a=t.scrollTop;let r=Or(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)&&jr(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,ee,{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 I;if(typeof ResizeObserver<`u`){I=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()}),I.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&&I.observe(r),i&&I.observe(i)}return()=>{t.removeEventListener(`scroll`,ee),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),I?.disconnect()}},[e,u,B,T,E,O,U,y]),{attachContent:A,scrollElRef:l,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:ie,jumpToRow:re,loadOlder:B,restickIfStuck:j,subscribeReaderScroll:b}}function lo({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,$.jsx)(uo,{runId:e,rows:t,controls:r}):(0,$.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function uo({runId:e,rows:t,controls:n}){return(0,$.jsx)(fo,{runId:e,rows:t,controls:n},e)}function fo({runId:e,rows:t,controls:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,Q.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Q.useState)(()=>Fr(e)),[l,u]=(0,Q.useState)(()=>({cache:Ir(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Q.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Q.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Q.useRef)(t.length);f.current=t.length;let p=(0,Q.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Q.useRef)(null),h=(0,Q.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||Pr(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Q.useState)(0);return(0,Q.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,$.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,$.jsx)(bn,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,$.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function po({onJump:e,pendingQuestions:t=0}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-sm hover:text-foreground`,children:[(0,$.jsx)(ze,{"aria-hidden":!0,className:`size-3.5`}),to(t)]})}function mo(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function ho(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,mo(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 go(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 _o=new WeakMap;function vo(e,t){let n=_o.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:(_o.set(e,t),t)}function yo(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let l=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===l?xo(n.items):n.items;c.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:vo(n.items,ho(e,t.filter(t=>!e.task||!lt(t,`opening`)).map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?go(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let u=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return u.length>0&&c.push({id:`pending-permissions`,entries:u,inDaySequence:!1}),i!==void 0&&c.push({id:Ya,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}var bo=`changes ready for review`;function xo(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(bo)))}function So(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 Co(e,t){return[{id:`agent:${e}`,entries:t}]}function wo(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function To(e,t){let n=[],r;for(let t of e){let e=wo(t),i=Kr(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 vr(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 Eo({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Q.useMemo)(()=>To(n,e),[n,e]),p=co(`${e}:${t}`,{surface:r}),m=c??p;la(e,f,m,r);let h=(0,Q.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Q.useMemo)(()=>f.map(t=>({key:t.key,node:Do(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??kr(``,g.length),v=g.length===0?i??null:(0,$.jsx)(lo,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,$.jsx)(Ze,{runId:e,children:(0,$.jsx)(wr,{runId:e,children:(0,$.jsx)(xa.Provider,{value:h,children:r===`panel`?(0,$.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,$.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,$.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,$.jsx)(po,{onJump:m.jumpToLatest})}):null]}):v})})})}function Do(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,$.jsx)(Oo,{message:e.content.message,actions:t});case`day-separator`:return(0,$.jsx)(Zr,{ts:e.content.ts});case`turn-time`:return(0,$.jsx)(Xr,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,$.jsx)(ko,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return No(e.content)}}function Oo({message:e,actions:t}){return(0,$.jsx)(ri,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,$.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,$.jsx)(ya,{ask:e.ask})}):void 0})}function ko({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,$.jsx)(nr.Provider,{value:`${t}:${e.entry.id}`,children:(0,$.jsx)(jo,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,$.jsx)(Ci,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,$.jsx)(Ao,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,$.jsx)(Ei,{group:e,scope:t});case`streak`:return(0,$.jsx)(Di,{count:e.count,children:e.blocks.map(e=>(0,$.jsx)(ko,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,$.jsx)(La,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return No(e)}}function Ao({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return vr(e).map(e=>(0,$.jsx)(ko,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function jo({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,$.jsx)(ci,{text:e.text,ts:e.ts}):(0,$.jsx)(ri,{text:e.text,ts:e.ts});case`reasoning`:return(0,$.jsx)(ui,{text:e.text});case`tool`:return(0,$.jsx)(Ci,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${ja(e.delivery)}`:``]}),(0,$.jsx)($r,{note:e})]}):(0,$.jsx)($r,{note:e});case`conversation`:return(0,$.jsx)(La,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,$.jsx)(Oi,{image:e});case`ask`:return n===void 0?(0,$.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,$.jsx)(pa,{permission:e,runId:i});case`provider-auth-required`:return(0,$.jsx)(li,{incident:e});case`preview-server`:return(0,$.jsx)(Mo,{entry:e});case`hook`:return(0,$.jsx)(Ti,{item:e,cacheKey:`${t}:${e.id}`});default:return No(e)}}function Mo({entry:e}){let t=pn(),n=pe().data?.capabilities?.preview===!0;return(0,$.jsx)(dt,{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 No(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Po({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,Q.useContext)(Cn),l=(0,Q.useRef)(void 0),u=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,$.jsx)(Yt,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,$.jsx)(Tn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,$.jsx)(tr.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,$.jsx)(Fo,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function Fo({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Xt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,$.jsxs)(Ht,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,$.jsxs)(Lt,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(Io,{status:r.status}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,$.jsx)(Eo,{runId:e,viewId:`agent:${r.id}`,sections:Co(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,$.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function Io({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,$.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:o(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}var Lo=/^diff --git /;function Ro(e){let t=e.replace(Lo,``),n=t.lastIndexOf(` b/`);return zo(n>=0?t.slice(n+3):t)}function zo(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function Bo(e){let t=zo(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function Vo(e){return{path:Ro(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function Ho(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=zo(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=zo(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=Bo(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=Bo(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function Uo(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function Wo(e){let t=[],n=null,r=!1;for(let i of e.split(`
7
- `)){if(Lo.test(i)){n=Vo(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):Ho(n,i);continue}Uo(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function Go(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var Ko=20,qo=300;function Jo({runId:e}){let t=A(),n=F(e);(0,Q.useEffect)(()=>{t.invalidateQueries({queryKey:I.runs.diff(e)})},[t,e]);let r=(0,Q.useMemo)(()=>Wo(n.data??``),[n.data]),[i,a]=(0,Q.useState)(!1);if(n.isPending)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,$.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(r.length===0)return(0,$.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let o=Go(r),s=i?r:r.slice(0,Ko);return(0,$.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[o.files,` `,o.files===1?`file`:`files`,` changed`]}),(0,$.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,o.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,o.deletions]})]})]}),s.map(e=>(0,$.jsx)(Xo,{file:e},`${e.oldPath??``}→${e.path}`)),r.length>s.length?(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>a(!0),children:[`Show `,r.length-s.length,` more files`]}):null]})}var Yo={added:`added`,deleted:`deleted`,renamed:`renamed`};function Xo({file:e}){let[t,n]=(0,Q.useState)(!0),r=Yo[e.status],i=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,$.jsxs)(Y,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,$.jsxs)(J,{className:`flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,$.jsx)(nt,{className:o(`mbs-[1px] size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,$.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,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,$.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,$.jsx)(Zo,{lines:e.lines})})})]})}function Zo({lines:e}){let[t,n]=(0,Q.useState)(!1),r=t?e:e.slice(0,qo),i=r.join(`
8
- `),[a,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1;return Dn(i,`diff`).then(t=>{e||s({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let c=a?.text===i?a.tokens:En(i,`diff`)?.tokens??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,$.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:o(`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,$.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>qo?(0,$.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function Qo(e){let t=A();return V({mutationFn:()=>C(e),onSuccess:()=>t.invalidateQueries({queryKey:I.runs.all}),onError:e=>P(e.message,{tone:`danger`})})}function $o({run:e}){return(0,$.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-2.5`,children:[(0,$.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex flex-col gap-2 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,$.jsx)(it,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`min-w-0 break-words text-[13px] leading-relaxed`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,$.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,$.jsx)(es,{run:e})]}),(0,$.jsx)(Jo,{runId:e.id})]})}function es({run:e}){let t=ce(),n=A(),r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),d=Qo(e.id),f=Pi(e),p=()=>n.invalidateQueries({queryKey:I.runs.all}),m=V({mutationFn:async t=>f.canContinue?T(ae(e.id),{text:`Review feedback:\n${t}`,runner:f.runnerOverride}):null,onMutate:()=>ae(e.id),onSuccess:(e,n,r)=>{e!==null&&(o(``),t.invalidateAfter(`continue`,r))},onError:e=>P(e.message,{tone:`danger`})}),g=V({mutationFn:()=>k(e.id),onSuccess:e=>{P(`Draft PR created — ${e.url}`),p()},onError:e=>{e instanceof h&&e.manual!==void 0&&u(e.manual),P(e.message,{tone:`danger`})}});(0,Q.useEffect)(()=>{s&&r.current?.focus()},[s]);let _=()=>{if(!s){c(!0);return}let e=i.trim();if(e.length===0){P(`Write what to change first.`),r.current?.focus();return}m.mutate(e)};return(0,$.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[f.canContinue?null:(0,$.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:f.reason}),f.providerPending?null:(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button]:min-h-11 [&_a]:min-h-11`,children:[(0,$.jsx)(K,{asChild:!0,variant:`outline`,size:`sm`,children:(0,$.jsxs)(X,{to:`/tasks/${e.id}/changes`,children:[(0,$.jsx)(it,{"aria-hidden":`true`}),`Review changes`]})}),(0,$.jsxs)(K,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:f.reason??(s?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":f.canContinue?void 0:`review-provider-guidance`,"aria-expanded":s,"aria-controls":s?`review-notes`:void 0,disabled:m.isPending||!f.canContinue,onClick:_,children:[(0,$.jsx)(zn,{"aria-hidden":`true`}),s?`Send back with notes`:`Send back`]}),a(e.pullRequestUrl)?(0,$.jsx)(K,{asChild:!0,variant:`outline`,size:`sm`,children:(0,$.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,$.jsx)(rt,{"aria-hidden":`true`}),`PR ↗`]})}):(0,$.jsxs)(K,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:g.isPending,onClick:()=>g.mutate(),children:[(0,$.jsx)(Te,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,$.jsxs)(K,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:ln(`review`),disabled:d.isPending,onClick:()=>d.mutate(),children:[(0,$.jsx)(Ae,{"aria-hidden":`true`}),`Accept`]}):null]}),s?(0,$.jsx)(Pn,{ref:r,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:1,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{Qt({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(),_())},className:`min-h-11 text-base md:text-[13px]`}):null,l===null?null:(0,$.jsx)(ts,{command:l})]})}function ts({command:e}){return(0,$.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>P(`Command copied to clipboard.`)).catch(()=>P(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,$.jsx)(We,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function ns(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var rs=1500;function is({status:e}){let t=(0,Q.useRef)(e),[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||ns())return;r(!0);let i=setTimeout(()=>r(!1),rs);return()=>clearTimeout(i)},[e]),n?(0,$.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,$.jsx)(Pt,{}),(0,$.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,$.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function as(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function os(e){return typeof e==`object`&&!!e&&!(0,Q.isValidElement)(e)&&`keep`in e}function ss({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:s,onToggle:c,className:l,children:u}){let d=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,$.jsx)(`span`,{className:o(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(os(r)?(0,$.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,$.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,$.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,$.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,$.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:o(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,$.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,a,(0,$.jsx)(Le,{"aria-hidden":!0,className:o(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,s&&`rotate-180`)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,a]}),f&&s?(0,$.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function cs(e){return w(e.delegation)}function ls(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 us(e){let t=e.delegation,n=cs(e),r=le(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=ls(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 ds(e){let t=le(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>jt(e.status))}function fs({run:e,open:t,onToggle:n}){let r=le(e.id),i=de(),a=an(),s=e.delegation,c=new Map(r.data?.workers.map(e=>[e.workerId,e])),l=ls(s,r.data),u=j(e)??p(e),d=u?ps(e,u):void 0,f=e=>i.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),m=e=>{let t=f(e);return t?Z(t):`worker ${e.slice(0,8)}`};return(0,$.jsx)(ss,{slot:`workers`,icon:(0,$.jsx)(Ce,{className:`size-4`}),title:`Workers`,meta:ms({ids:l,workers:c,desktop:a,query:r}),aside:r.data?.capacity?(0,$.jsx)(xs,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,$.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,u?(0,$.jsx)(vs,{wait:u,dependencyLabel:d}):null,l.length>0?(0,$.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),a=n?gs(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,$.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,$.jsxs)(X,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,$.jsx)(hs,{status:n?.status}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:i?Z(i):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,$.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,m(n.supervisorRunId)]}):null]}),(0,$.jsx)(`span`,{className:o(`max-w-[45%] shrink-0 truncate text-xs`,_s(n?.status)),children:a}),(0,$.jsx)(Oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,$.jsx)(Cs,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,$.jsx)(Ds,{state:n.destroy}):null]},t)})}):cs(e)&&r.isSuccess?(0,$.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,$.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,$.jsx)(K,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function ps(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return m(e)??E(n.role,t,`requestIds`in t&&y(n,t.requestIds))}function ms({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 hs({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,$.jsx)(Me,{"aria-hidden":!0,className:o(t,`text-success`)}):e===`failed`?(0,$.jsx)(Ne,{"aria-hidden":!0,className:o(t,`text-danger`)}):e===`cancelled`?(0,$.jsx)(Pe,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,$.jsx)(ot,{role:`status`,"aria-label":`Worker running`,className:o(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,$.jsx)(Re,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)})}function gs(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function _s(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function vs({wait:e,dependencyLabel:t}){return(0,$.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,$.jsxs)($.Fragment,{children:[` `,`Deadline: `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function ys(e){return e.delegation?.role===`worker`&&p(e)?.phase===`wake-pending`}function bs({run:e}){let t=p(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,$.jsx)(vs,{wait:t,dependencyLabel:E(`worker`,t)}):null}function xs({capacity:e}){return(0,$.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Ss=new Set([`review`,`done`,`failed`,`cancelled`]);function Cs({parentRunId:e,worker:t}){let n=H(e),[r,i]=(0,Q.useState)(!1);if(!Ss.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 h?n.error.work:void 0;return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`break-words text-xs`,children:S(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,$.jsx)(K,{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,$.jsx)(K,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,$.jsx)(K,{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,$.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${Ts(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,$.jsx)(K,{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 ws=(e,t,n)=>`${e} ${e===1?t:n}`;function Ts(e){return[...e.uncommittedFiles?[ws(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${ws(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Es(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Ds({state:e}){if(!Es(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,$.jsx)(Os,{at:t.nextAt});return(0,$.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,$.jsxs)($.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,$.jsxs)($.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Os({at:e}){let t=It(3e4);return(0,$.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Nn(t,Date.parse(e))})}function ks(e){let t=A(),[n,r]=(0,Q.useState)(),i=Ot(e);(0,Q.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=V({mutationFn:async()=>{r(e.id);try{if(!(await O(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:I.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function As({agents:e,onSelect:t}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,$.jsx)(js,{agent:e,onSelect:t},e.id))})}function js({agent:e,onSelect:t}){let n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ms,{status:e.status,stalled:e.stalled===!0}),(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,$.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,$.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:$i(e)}),(0,$.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,$.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,$.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,$.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Ms({status:e,stalled:t=!1}){return t?(0,$.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,$.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Ns(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Ps({entries:e}){return e.length===0?null:(0,$.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,$.jsx)(Fs,{entry:e},`${t}:${e.content}`))})}function Fs({entry:e}){return(0,$.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:o(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,$.jsx)(Is,{status:e.status}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,$.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function Is({status:e}){return e===`cancelled`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,$.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,$.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,$.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,$.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,$.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function Ls(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 Rs(e,t){let n=Ls(e);return n===`active`&&t===`waiting`?`paused`:n}function zs(e){return e===`active`?`running`:e}function Bs(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 Vs({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=Bs(e)*100;return(0,$.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,$.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Rs(n.status,t),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,$.jsx)(Hs,{visual:Rs(n.status,t)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:n.name}),n.iterations>1?(0,$.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,$.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,$.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function Hs({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,$.jsx)(Me,{"aria-hidden":!0,className:o(t,`text-success`)});case`active`:return(0,$.jsx)(ot,{role:`status`,"aria-label":`Step running`,className:o(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,$.jsx)(Ve,{role:`img`,"aria-label":`Step paused`,className:o(t,Us)});case`failed`:return(0,$.jsx)(Ne,{"aria-hidden":!0,className:o(t,`text-danger`)});case`pending`:return(0,$.jsx)(Re,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)})}}var Us=`stroke-pending [html.light_&]:stroke-pending-strong`,Ws={done:`done`,failed:`failed`,cancelled:`cancelled`};function Gs(e){let t=Ws[e.status];return t?e.steps.map(e=>Ls(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):Ks(e)}function Ks(e){let t=qs(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 qs(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>Ls(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 Js({items:e,lead:t=0}){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(-1/0);return(0,Q.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,$.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,$.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,$.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ys({run:e,references:t}){return(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,$.jsx)(yt,{reference:t,taskTitle:Z(e),inert:!0},xe(t)))})}function Xs(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?en(e.accounts,e.accountBackend)?`default`:void 0:e.known?en(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Zs(e){let t=c(),n=oe(),r=fe(),{accounts:i}=wn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,l=[...e.steps].reverse().find(e=>e.profileId),d=l?.profileId,f=l?.backend??a,p=r.data?.profiles.find(e=>e.id===d&&e.provider===f),m=Xs({accountId:d,profilesPending:r.isPending,profilesError:r.isError,known:p,accounts:i,accountBackend:f}),h=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?u(t.data,a):x(e.removedRunner),...m?{account:m}:{},model:o,effort:s,...h?{identity:h}:{}}}var Qs=[`running`,`queued`,`waiting`];function $s(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 ec(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 tc(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 nc(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function rc(e){let t=$s(e.waits),n=Qs.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&nc(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...$s(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 ic(e){return rc(e)!==void 0}function ac(e){return(rc(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function oc({run:e}){let t=rc(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,$.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,$.jsx)(cc,{run:e,wait:t},t.id):t.kind===`worker`?(0,$.jsx)(lc,{wait:t},t.id):t.kind===`process`?(0,$.jsx)(hc,{run:e,wait:t},t.id):t.kind===`peer`?(0,$.jsx)(uc,{wait:t},t.id):t.kind===`subagent`?(0,$.jsx)(dc,{wait:t},t.id):t.kind===`plugin`?(0,$.jsx)(fc,{run:e,wait:t},t.id):(0,$.jsx)(pc,{run:e,wait:t},t.id)),i?(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,$.jsx)(cc,{run:e,wait:r,settled:!0}):null,a?(0,$.jsx)(hc,{run:e,wait:a,settled:!0}):null]})}function sc(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?zt(r.headSha):`unknown`} → ${r?.observedHeadSha?zt(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`?tc(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function cc({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=sc(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=ec(c),u=`${t.repository}#${t.prNumber}`;return(0,$.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,$.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,$.jsx)(`dd`,{children:s}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,$.jsx)(`dd`,{className:`min-w-0`,children:a(t.prUrl)?(0,$.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,$.jsx)(`span`,{children:u})}),l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,$.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function lc({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=ec(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,$.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function uc({wait:e}){let t=e.peerIds.length,n=ec(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function dc({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=ec(e.deadline);return(0,$.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,$.jsxs)(`p`,{children:[`Check by`,` `,(0,$.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,$.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function fc({run:e,wait:t}){let n=t.phase===`open`?ec(t.deadline):void 0;return(0,$.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,$.jsx)(`p`,{children:t.phase===`resolved`?tc(t.summary,e):t.summary}),n?(0,$.jsxs)(`p`,{children:[`Deadline`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function pc({run:e,wait:t}){let n=ec(t.deadline);return(0,$.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,$.jsx)(`p`,{children:tc(`Automatic check due`,e)}):n?(0,$.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,$.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,$.jsx)(`p`,{children:t.note}):null]})}function mc(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 hc({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?mc(t):t.phase===`resolved`?tc(mc(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?ec(t.deadline):void 0;return(0,$.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,$.jsx)(`p`,{children:r}),i?(0,$.jsxs)(`p`,{children:[`Until`,` `,(0,$.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var gc=new Map,_c=new Map;function vc(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=et(e.run);return(0,$.jsx)(_t,{projectId:t,repoBase:n,requests:i,children:(0,$.jsx)(yc,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!ye(e.run)||!!ve(e.run,n)})})}function yc({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,prNumbers:s,hasReferences:c,references:l}){let u=an(),d=Zs(e),[f,p]=(0,Q.useState)(()=>i?!1:gc.get(e.id)??!1),m=Fc(o,f),h=m.open,[g,_]=(0,Q.useState)({}),v=bc(e,t??n,n,r,s),y=Qe(e),b=t=>g[t]??_c.get(`${e.id}:${t}`)??t===`workers`,x=t=>{let n=!b(t);_c.set(`${e.id}:${t}`,n),_(e=>({...e,[t]:n}))},S=e=>({open:b(e),onToggle:()=>x(e)});return(0,$.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:m.ref,"data-state":h?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,$.jsx)(Tc,{run:e,identity:d,activity:v,references:l,open:h,onToggle:()=>{gc.set(e.id,!h),p(!h),m.chose(!h)}}),h?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,$.jsx)(Oc,{run:e,activity:v,...S(`status`)}),(0,$.jsx)(kc,{run:e,desktop:u,automations:v.automations,...S(`workflow`)}),(0,$.jsx)(Ac,{activity:v,desktop:u,onOpenWorker:a,...S(`subagents`)}),(0,$.jsx)(jc,{run:e,...S(`workers`)}),(0,$.jsx)(Mc,{activity:v,desktop:u,...S(`plan`)}),(0,$.jsx)(Nc,{run:e,identity:d,activity:v,...S(`usage`)}),(0,$.jsx)(Pc,{run:e,references:l,conflicts:v.conflicts,hasReferences:c,onResume:()=>y.mutate(),...S(`workspace`)})]}):null]})}function bc(e,t,n,r,i){let a=pe(),o=hn(a.data),s=de(),c=Ye(e,{queuePosition:e.status===`queued`?kt(s.data??[]).get(e.id):void 0}),l=vt(i),u=!Dt(e)&&e.status!==`queued`,d=(0,Q.useMemo)(()=>r?Xi(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),f=gt(n)??[],p=us(e),m=Qi(d),h=Ns(f);return{line:c,...xc(e,c,p,r?m:void 0,h),...Sc(e,o),conflicts:l,waitReferences:ac(e),agents:d,agentCounts:m,planEntries:f,planCounts:h,automations:Rt(a.data)}}function xc(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`||e.status===`cancelled`,glyph:o?(0,$.jsx)(Me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,$.jsx)(Mt,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function Sc(e,t){return{cost:t.cost&&e.costUsd!==void 0?be(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,$.jsx)(cn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function Cc(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function wc(e){let t=Gs(e),n=qs(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function Tc({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[xe(e),e])).values()];return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":Ec(e,t,n,c,i),onClick:a,className:o(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,$.jsx)(Ke,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,$.jsx)(Dc,{run:e,identity:t,activity:n,summaryReferences:c}),i&&s?(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:s}):null,(0,$.jsx)(Le,{"aria-hidden":!0,className:o(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!s&&`ms-auto`,i&&`rotate-180`)})]})}function Ec(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=wc(e)?.step,u=l?`; step ${l.name}, ${zs(Rs(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 Dc({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:s}=n,c=wc(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,$.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||s.length?[{id:`chips`,priority:0,content:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ys,{run:e,references:r}),s.length>0?(0,$.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(Be,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:o(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,Cc(n)),children:[n.glyph,(0,$.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),c?(0,$.jsxs)(`span`,{"data-slot":`run-activity-step`,className:o(`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,$.jsx)(zc,{step:c,runStatus:e.status,decorative:!0}),(0,$.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:c.name,className:`min-w-0 truncate`,children:c.name})]}):null,(0,$.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,$.jsx)(Js,{items:l,lead:8})})]})}function Oc({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,s=ys(e);return(0,$.jsxs)(ss,{slot:`status-row`,icon:t.glyph,title:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{"data-slot":`run-activity-status`,className:o(`truncate`,Cc(t)),children:t.statusText}),i.nextCheck?(0,$.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,$.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,$.jsx)(Js,{items:[{id:`chips`,priority:0,content:(0,$.jsx)(Ys,{run:e,references:a})}]}):void 0,open:n,onToggle:ic(e)||s?r:void 0,children:[(0,$.jsx)(oc,{run:e}),s?(0,$.jsx)(bs,{run:e}):null]})}function kc({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=Se(e),o=wc(e);return!a&&!o?null:(0,$.jsxs)(ss,{slot:`workflow`,icon:o?(0,$.jsx)(zc,{step:o.step,runStatus:e.status}):(0,$.jsx)(Ue,{className:`size-4`}),title:(0,$.jsxs)($.Fragment,{children:[`Workflow`,a?(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:as(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,$.jsx)(Vs,{steps:o.steps,runStatus:e.status}):null,(0,$.jsx)(Rc,{run:e,available:n})]})}function Ac({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,$.jsx)(ss,{slot:`subagents`,icon:(0,$.jsx)(He,{className:`size-4`}),title:`Subagents`,meta:as(o.done,o.total,t),open:r,onToggle:i,children:(0,$.jsx)(As,{agents:a,onSelect:n})})}function jc({run:e,open:t,onToggle:n}){return cs(e)?(0,$.jsx)(fs,{run:e,open:t,onToggle:n}):null}function Mc({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,$.jsx)(ss,{slot:`plan`,icon:(0,$.jsx)(we,{className:`size-4`}),title:`Plan`,meta:as(a.done,a.total,t),open:n,onToggle:r,children:(0,$.jsx)(Ps,{entries:i})})}function Nc({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,$.jsx)(ss,{slot:`usage`,icon:(0,$.jsx)(Rn,{className:`size-4`}),title:`Usage & agent`,summary:(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(Js,{items:c})}),open:r,onToggle:i,children:(0,$.jsx)(Lc,{run:e,tokens:o,cost:a})})}function Pc({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||rn(e)||Es(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,$.jsx)(ss,{slot:`workspace`,icon:(0,$.jsx)(Ce,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,$.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,$.jsx)(Js,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,$.jsx)(Ys,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,$.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,$.jsx)(Be,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,$.jsx)(Ds,{state:s}):null,(0,$.jsx)(Xe,{run:e}),e.branch?(0,$.jsx)(Ic,{label:`Branch`,children:(0,$.jsx)($e,{branch:e.branch})}):null,e.worktreePath?(0,$.jsx)(Ic,{label:`Worktree`,children:(0,$.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,$.jsx)(Je,{run:e,canResume:on(e).terminal,onResume:i})]})})}function Fc(e,t){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)({active:!1,override:!1});return(0,Q.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function Ic({label:e,children:t}){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function Lc({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Zs(e);return(0,$.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,$.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,$.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,$.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,$.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Rc({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,$.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,$.jsx)(X,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:o(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,$.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function zc({step:e,runStatus:t,decorative:n=!1}){let r=Rs(e.status,t),i=`size-4 shrink-0`;switch(r){case`active`:return(0,$.jsx)(ot,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:o(i,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,$.jsx)(Ve,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:o(i,Us)});case`failed`:return(0,$.jsx)(Ne,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:o(i,`text-danger`)});case`pending`:return(0,$.jsx)(Re,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:o(i,`text-soft-foreground`)});case`done`:return(0,$.jsx)(Me,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:o(i,`text-success`)})}}var Bc={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 Vc(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Hc({ask:e,run:t,onShowOrigin:n}){let r=e.context?(0,$.jsx)(Wc,{text:e.context}):null;if(e.resolved)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(0,$.jsxs)(ti,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,$.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?Bc[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,$.jsx)(ya,{ask:e})]})]});let i=e.placement===`pinned`&&n?n:void 0;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,e.routedToParent?(0,$.jsx)(Gc,{ask:e,onShowOrigin:i}):(0,$.jsx)(Kc,{ask:e,run:t,onShowOrigin:i})]})}function Uc({onShowOrigin:e,className:t}){return(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:o(`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,t),onClick:e,children:`Show where it was asked`})}function Wc({text:e}){return(0,$.jsx)(ti,{role:`agent`,children:(0,$.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,$.jsx)(jn,{breaks:!0,children:e})})})}function Gc({ask:e,onShowOrigin:t}){return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,$.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,$.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,$.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,$.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,$.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,$.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,$.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,$.jsx)(X,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,$.jsx)(Uc,{onShowOrigin:t}):null]})}function Kc({ask:e,run:t,onShowOrigin:n}){let r=gn(t),i=r.blockedBy!==void 0,a=e.questions,s=a.length===1&&a[0]?.options!==void 0&&a[0]?.multiSelect!==!0,[c,l]=(0,Q.useState)({}),[u,d]=(0,Q.useState)({}),f=(e,t)=>l(n=>({...n,[e]:t})),p=e=>d(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),m=e=>{f(e,[]),d(t=>({...t,[e]:t[e]??``}))},h=a.some((e,t)=>!e.options||u[t]!==void 0),g=a.every((e,t)=>(c[t]?.length??0)>0||!!u[t]?.trim()),_=()=>void r.send(a.map((e,t)=>Vc(e,c[t]??[],u[t])).join(`
9
- `)),v=r.mode===`resume`;return(0,$.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":r.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-3 pt-4 pb-2.5 max-sm:pt-3 max-sm:pb-1`,children:[(0,$.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,$.jsx)(Zc,{question:e,disabled:r.isPending||i,selected:c[t]??[],isOther:u[t]!==void 0,otherAnswer:u[t]??``,onSelect:n=>{i||(p(t),s?r.send(Vc(e,n)):f(t,n))},onOtherToggle:()=>{i||(u[t]===void 0?m(t):p(t))},onOtherChange:e=>d(n=>({...n,[t]:e}))},e.id??t))}),(0,$.jsxs)(`div`,{"data-slot":`ask-footer`,className:`max-sm:mbs-2 max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:gap-x-2.5`,children:[(0,$.jsx)(Jc,{oneTap:s,hasOtherAnswer:h,resuming:v,disabled:r.isPending||i||!g,questionCount:a.length,onSend:_}),r.blockedBy===`provider`?(0,$.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground max-sm:order-4 max-sm:basis-full`,children:[(0,$.jsx)(`span`,{children:r.reason}),(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,r.blockedBy===`no-session`?(0,$.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground max-sm:order-4 max-sm:basis-full`,children:r.reason}):null,r.error?(0,$.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger max-sm:order-4 max-sm:basis-full`,children:r.error}):null,n?(0,$.jsx)(Uc,{onShowOrigin:n,className:o(`max-sm:order-2 max-sm:mbs-0`,qc(s,h)&&`max-sm:ms-auto`)}):null]})]})}var qc=(e,t)=>!e||t;function Jc({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return qc(e,t)?(0,$.jsxs)(`div`,{className:`mbs-2 flex flex-wrap items-center gap-x-2.5 max-sm:contents`,children:[(0,$.jsx)(K,{size:`sm`,className:`min-h-11 max-sm:order-1`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),n?(0,$.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:`the session has ended — sending reopens it`}):(0,$.jsxs)(`span`,{"data-slot":`ask-hint`,className:`inline-flex flex-wrap items-center gap-x-1 text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:[(0,$.jsx)(`span`,{children:t?`${i>1?`answer each question above`:`enter your answer above`} — or`:`${i>1?`answer each question`:`pick one or more`} — or`}),(0,$.jsx)(Xc,{})]})]}):n?(0,$.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null}function Yc(e){return(e.closest(`[data-route="task-thread"]`)??document).querySelector(`[data-slot="thread-dock"] [data-slot="composer-editor"] textarea`)}function Xc(){return(0,$.jsx)(`button`,{type:`button`,"data-slot":`ask-reply-jump`,className:`min-h-11 rounded-sm font-medium text-foreground underline underline-offset-4 hover:text-link-foreground focus-visible:outline-2 focus-visible:outline-ring`,onClick:e=>{let t=Yc(e.currentTarget);if(!t)return;let n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;t.scrollIntoView?.({behavior:n?`auto`:`smooth`,block:`center`}),t.focus({preventScroll:!0})},children:`type a reply below`})}function Zc({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:s,onOtherChange:c}){let l=(0,Q.useId)(),u=e.options,d=u!==void 0&&e.multiSelect===!0,f=e=>{if(!d){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,$.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,$.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),d?(0,$.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1 sm:grid-cols-2 sm:gap-2`,children:[u.map(e=>{let r=n.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>f(e.label),className:o(`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 text-left transition-colors sm:py-1.5`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[d?(0,$.jsx)(`span`,{"aria-hidden":!0,className:o(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,$.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,$.jsx)(K,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,className:o(`h-auto min-h-11 w-full justify-start px-2.5 py-1 text-left sm:py-1.5`,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,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Pn,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,$.jsx)(Pn,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]})]})}var Qc=2e3;function $c(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 el(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 tl(e,t){let n=A(),r=(0,Q.useMemo)(()=>$c(t),[t]),i=(0,Q.useMemo)(()=>el(t),[t]),a=e?.id,o=e?.status;(0,Q.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:I.runs.detail(a)}),n.invalidateQueries({queryKey:I.runs.list()})},Qc);return()=>clearTimeout(e)},[r,i,a,o,n])}function nl(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function rl({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Q.useState)(void 0),s=(0,Q.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Q.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=So(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,nl);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}function il(){let{id:e}=W(),t=ie(e),n=dn(e),r=t.data?.status,i=(0,Q.useMemo)(()=>ft(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,Q.useMemo)(()=>ft(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,Q.useRef)(void 0),s=(0,Q.useCallback)(e=>{o.current=e},[]),{mutate:c}=ne();if((0,Q.useEffect)(()=>{t.data&&o.current!==t.data.id&&At(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),tl(t.data,n.visibleEvents),t.isPending)return(0,$.jsx)(Sn,{});if(t.isError){let e=t.error instanceof h&&t.error.status===404;return(0,$.jsx)(Nt,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,$.jsx)(Ft,{icon:e?(0,$.jsx)(bt,{}):(0,$.jsx)(Vn,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,$.jsx)(K,{asChild:!0,variant:`outline`,children:(0,$.jsx)(X,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,$.jsx)(Sn,{}):(0,$.jsx)(ol,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var al=e=>({titles:Object.fromEntries(e.map(e=>[e.id,Z(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function ol({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Ct();let a=ee({queryKey:I.runs.list(),queryFn:({signal:e})=>_(re(),{signal:e}),select:al}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=sl(r,n),u=g(e),d=ut(e.status,e.error,t),f=tn(e),p=!f&&e.status!==`queued`,m=e.status===`queued`,h=Bi(e),v=ks(e),y=Qo(e.id),x=s||b(e),{hasContinuation:S,continuable:C}=cl(f,m,h),[w,T]=(0,Q.useState)(void 0),[E,D]=(0,Q.useState)(e.id);E!==e.id&&(D(e.id),T(void 0));let O=(0,Q.useMemo)(()=>w===void 0?void 0:ta(n.turns,w,p,t.turns),[n.turns,w,p,t.turns]),k=(0,Q.useMemo)(()=>w===void 0?[]:ia(t.turns,n.turns,w),[t.turns,n.turns,w]),A=ue(e.id),j=gn(e),{providerBlocked:M,providerReason:te}=ll(f,mn(e),S,h),{mutateAsync:N}=L(e.id),{mutateAsync:P}=me(e.id),{mutateAsync:F}=R(e.id),z=(0,Q.useMemo)(()=>m?{onEditTask:async e=>{await N({task:e})},onEditMessage:(e,t)=>P({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>F(e).then(()=>void 0)}:void 0,[m,N,P,F]),B=l?void 0:c??null,V=(0,Q.useMemo)(()=>yo(e,t,n,B),[e,t,n,B]),H=(0,Q.useMemo)(()=>To(V,e.id),[V,e.id]),U=e.delegation?.role===`root`||e.delegation?.role===`worker`,ne=le(e.id,{enabled:U}),ie=(0,Q.useMemo)(()=>({...Ca(e,void 0,ne.data?.titles),...a.data?.titles,[e.id]:Z(e)}),[e,a.data,ne.data]),ae=(0,Q.useMemo)(()=>({...a.data?.backends,...Sa(e,void 0)}),[e,a.data]),oe=(0,Q.useCallback)(t=>(0,$.jsx)(pa,{permission:t,runId:e.id,sessionOpen:f}),[e.id,f]),ce=(0,Q.useMemo)(()=>{if(z===void 0)return;let t={task:{onEdit:z.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>z.onEditMessage(n.id,e),onRemove:()=>z.onRemoveMessage(n.id)};return t},[z,e.queuedMessages]),de=ve(e,se()),{search:fe}=he(),pe=kr(fe,H.length),W=co(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:H.map(({key:e})=>e)}),{pinnedAsk:ge,pendingQuestions:_e}=ul(V),ye=rl({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:H,history:r,jumpToRow:W.jumpToRow}),be=(0,Q.useRef)(c);l||(be.current=c);let xe=(0,Q.useRef)({rows:H,jumpToRow:W.jumpToRow,reveal:ye.reveal});xe.current={rows:H,jumpToRow:W.jumpToRow,reveal:ye.reveal};let Se=(0,Q.useCallback)(t=>t.placement===`origin`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,$.jsx)(Wc,{text:t.context}):null,t.resolved?null:(0,$.jsx)(no,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=xe.current,r=So(e,t.id,`pinned`);r&&n(r.key,r.index,e=>Za(e))}})]}):(0,$.jsx)(Hc,{ask:t,run:e,onShowOrigin:()=>xe.current.reveal()}),[e]);St(W.restickIfStuck);let Ce=ro();return(0,$.jsxs)(Nt,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,flushPadding:!0,rootRef:Ce,rootProps:{"data-run-id":e.id},children:[(0,$.jsx)(tt,{run:e,onMarkedUnread:()=>i?.(e.id)}),(0,$.jsx)(dl,{run:e,thread:t,history:r,footer:d,issueUrl:de,sections:V,renderAsk:Se,renderPermission:oe,messageActions:ce,scroll:W,mode:pe,taskTitles:ie,recipientBackends:ae}),(0,$.jsx)(is,{status:e.status}),(0,$.jsx)(Po,{runId:e.id,renderAsk:Se,renderPermission:oe,agent:O,entries:k,taskTitles:ie,recipientBackends:ae,onClose:()=>T(void 0)}),(0,$.jsx)(fl,{run:e,thread:t,currentThread:n,currentComplete:r?.currentComplete??!0,scroll:W,pendingQuestions:_e,onJump:()=>{let e=_e>0?ge?.id:void 0;W.jumpToLatest(e===void 0?void 0:Qa(e,()=>be.current===e))},onOpenWorker:T,sessionOpen:f,attention:u,queued:m,continuable:C,continueAction:h,stopAction:v,finishAction:y,needsAnswer:x,sendMessage:A,reply:j,providerBlocked:M,providerReason:te}),(0,$.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function sl(e,t){let n=e?ct(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 cl(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function ll(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function ul(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function dl({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:s,renderAsk:c,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,$.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,$.jsx)(_l,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,$.jsx)(Eo,{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,$.jsx)(vl,{run:e}):(0,$.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,$.jsx)(di,{}):null,r&&r.state===`closed`?(0,$.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:o(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,a(ye(e))?(0,$.jsx)(`a`,{"data-slot":`pr-link`,href:ye(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,a(i)?(0,$.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,$.jsx)($o,{run:e}):null]})}function fl({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:_,providerBlocked:y,providerReason:b}){let x=eo(h&&a>0,i.scrollElRef);return(0,$.jsxs)(`div`,{"data-slot":`thread-dock`,"data-pending-ask":h||void 0,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible&&!x?(0,$.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,$.jsx)(po,{pendingQuestions:a,onJump:o})}):null,(0,$.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,$.jsx)(vc,{pendingAsk:h,run:e,thread:t,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},`${e.id}:${h}`),(0,$.jsx)(Wn,{run:e}),e.status===`waiting`&&c?(0,$.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Mt,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,$.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(Mt,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&e.removedRunner!==void 0?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:v(e.removedRunner)}):d&&f.startsNewConversation?(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,$.jsx)(ml,{run:e,thread:t,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:_,providerBlocked:y,providerReason:b,sessionOpen:c})]})]})}function pl(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 ml({run:e,thread:t,stopAction:n,finishAction:r,attention:i,needsAnswer:a,continuable:o,continueAction:s,queued:c,sendMessage:l,reply:u,providerBlocked:d,providerReason:f,sessionOpen:p}){let m=ds(e);return(0,$.jsx)($t,{...pl(e,o,s),onStop:on(e,m).cancel?n.stop:void 0,onFinish:fn(e)?()=>r.mutateAsync().catch(()=>void 0):void 0,finishing:r.isPending,stopOnEmpty:hl(e,i,a),stopping:n.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:o?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:o?s.pills:void 0,onSubmit:o?(e,t)=>s.continueWith(e,t):c?(e,t)=>l.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await u.send(e,t);if(n!==void 0)throw Error(n)},disabled:d||!p&&!c&&!o,disabledReason:d?f:`Session closed — no session to resume.`,footerEnd:d&&!s.providerPending?(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:o&&!a,emptySubmitVariant:e.status===`review`?`outline`:`primary`,emptySubmitLabel:o&&!a?`Continue`:void 0,placeholder:gl(e,c,o),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>mt(t)})}function hl(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function gl(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 _l({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,$.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,$.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,$.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function vl({run:e}){let t=xn(de().data??[],e.id);return(0,$.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,$.jsx)(Mt,{tone:`neutral`,shape:`ring`}),(0,$.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,$.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{il as TaskThreadRoute};
@@ -1 +0,0 @@
1
- import{$n as e}from"./project-scope-context-DIcqj4jJ.js";import{C as t,f as n,o as r}from"./task-groups-DK0I9p71.js";function i(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}function a(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function o(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?a(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var s=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:o},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function c(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function l(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function u(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:l(e,t.automationNames)},i=[],a=[],o=[],c={text:i,identifier:a,link:o},u=[];for(let t of s)if(t.scopes.includes(n)){if(t.kind===`reference`){u.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let d;return{prose:i,ids:a,links:o,references:()=>d??=new Set(u.flatMap(e=>e().map(String)))}}function d(e,t,n={}){let r=c(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=u(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var f=new Set([`running`,`waiting`]);function p(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function m(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function h(t,n=new Date){if(!e(t))return;let r=new Date(t.autoResumeAt);if(!Number.isFinite(r.getTime()))return;let i=r.toDateString()===n.toDateString(),a=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(r);return{label:i?a:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(r)} ${a}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r)}`}}function g(e){return e.steps?i({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function _(e,t,i=()=>``){let a=e.filter(e=>!r(e));return t.trim()?a.filter(e=>d(e,t,{scope:`shown`,extras:{displayTitle:n(e),automation:i(e),references:()=>v(e)}})):[...a]}function v(e){return T(e).map(e=>e.number)}function y(e,n){return e.filter(e=>t(e,n)).length}function b(e){return y(e)}function x(e){return S(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function S(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function C(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function w(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function T(e,t,n=e.projectId){let r=S(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>M(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:C(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(M(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??E(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=w(a);o.has(c)||(o.add(c),s.push(a))}return s}function E(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function D(e){return T(e)[0]}function O(e,t){if(!e.url)return!0;if(!t)return!1;let n=k(t);return n!==void 0&&k(e.url)===n}function k(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function A(e,t){let n=[];for(let r of T(e,t)){if(!O(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function j(e,t,n,r){if(O(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function M(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function N(e,t){let n=f.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:p(n.rssBytes),kind:`live`}};let r=p(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}export{N as _,O as a,h as c,C as d,j as f,T as g,D as h,p as i,v as l,x as m,b as n,M as o,A as p,m as r,w as s,_ as t,y as u,g as v,d as y};