@open-mercato/cezar 0.15.0 → 0.15.1

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 (212) hide show
  1. package/dist/automations/github-poller.d.ts +8 -1
  2. package/dist/automations/github-poller.js +78 -13
  3. package/dist/automations/github-poller.js.map +1 -1
  4. package/dist/automations/pr-head.js +15 -1
  5. package/dist/automations/pr-head.js.map +1 -1
  6. package/dist/automations/prompts.js +2 -2
  7. package/dist/automations/types.d.ts +10 -0
  8. package/dist/automations/types.js +12 -1
  9. package/dist/automations/types.js.map +1 -1
  10. package/dist/config.d.ts +1 -0
  11. package/dist/config.js +6 -0
  12. package/dist/config.js.map +1 -1
  13. package/dist/contract/automations.d.ts +31 -1
  14. package/dist/contract/index.d.ts +1 -0
  15. package/dist/contract/index.js +161 -17
  16. package/dist/contract/projects.d.ts +46 -0
  17. package/dist/contract/runs.d.ts +15 -0
  18. package/dist/contract/skills.d.ts +1 -0
  19. package/dist/contract/telemetry.d.ts +124 -0
  20. package/dist/contract/workspace.d.ts +3 -0
  21. package/dist/core/cursor-agent-runner.d.ts +11 -0
  22. package/dist/core/cursor-agent-runner.js +48 -4
  23. package/dist/core/cursor-agent-runner.js.map +1 -1
  24. package/dist/core/disclaim-spawn.d.ts +10 -0
  25. package/dist/core/disclaim-spawn.js +105 -8
  26. package/dist/core/disclaim-spawn.js.map +1 -1
  27. package/dist/git-diff-base.js +26 -19
  28. package/dist/git-diff-base.js.map +1 -1
  29. package/dist/git-remotes.d.ts +43 -0
  30. package/dist/git-remotes.js +127 -0
  31. package/dist/git-remotes.js.map +1 -0
  32. package/dist/git-worktree.d.ts +43 -19
  33. package/dist/git-worktree.js +138 -54
  34. package/dist/git-worktree.js.map +1 -1
  35. package/dist/index.js +46 -6
  36. package/dist/index.js.map +1 -1
  37. package/dist/runs/auto-name.d.ts +17 -0
  38. package/dist/runs/auto-name.js +47 -2
  39. package/dist/runs/auto-name.js.map +1 -1
  40. package/dist/runs/event-history.d.ts +10 -2
  41. package/dist/runs/event-history.js +290 -120
  42. package/dist/runs/event-history.js.map +1 -1
  43. package/dist/runs/retention.js +1 -1
  44. package/dist/runs/retention.js.map +1 -1
  45. package/dist/runs/store.d.ts +16 -3
  46. package/dist/runs/store.js +89 -10
  47. package/dist/runs/store.js.map +1 -1
  48. package/dist/server/checkout.d.ts +4 -0
  49. package/dist/server/checkout.js +9 -5
  50. package/dist/server/checkout.js.map +1 -1
  51. package/dist/server/create-project.d.ts +77 -0
  52. package/dist/server/create-project.js +342 -0
  53. package/dist/server/create-project.js.map +1 -0
  54. package/dist/server/forge/github.d.ts +2 -0
  55. package/dist/server/forge/github.js +32 -10
  56. package/dist/server/forge/github.js.map +1 -1
  57. package/dist/server/forge/index.d.ts +1 -12
  58. package/dist/server/forge/index.js +7 -29
  59. package/dist/server/forge/index.js.map +1 -1
  60. package/dist/server/forge/types.d.ts +2 -0
  61. package/dist/server/git-changes.d.ts +15 -0
  62. package/dist/server/git-changes.js +51 -1
  63. package/dist/server/git-changes.js.map +1 -1
  64. package/dist/server/git.d.ts +3 -2
  65. package/dist/server/git.js +4 -3
  66. package/dist/server/git.js.map +1 -1
  67. package/dist/server/project-context.js +1 -1
  68. package/dist/server/project-context.js.map +1 -1
  69. package/dist/server/server.d.ts +609 -302
  70. package/dist/server/server.js +191 -12
  71. package/dist/server/server.js.map +1 -1
  72. package/dist/server/star-count.d.ts +27 -11
  73. package/dist/server/star-count.js +57 -28
  74. package/dist/server/star-count.js.map +1 -1
  75. package/dist/telemetry-cli.d.ts +10 -0
  76. package/dist/telemetry-cli.js +54 -0
  77. package/dist/telemetry-cli.js.map +1 -0
  78. package/dist/telemetry-service.json +1 -0
  79. package/dist/telemetry.d.ts +79 -0
  80. package/dist/telemetry.js +453 -0
  81. package/dist/telemetry.js.map +1 -0
  82. package/dist/workflows/run.d.ts +28 -0
  83. package/dist/workflows/run.js +111 -16
  84. package/dist/workflows/run.js.map +1 -1
  85. package/dist/workspace/config.d.ts +10 -0
  86. package/dist/workspace/config.js +16 -0
  87. package/dist/workspace/config.js.map +1 -1
  88. package/dist/workspace/projects-cli.js +3 -0
  89. package/dist/workspace/projects-cli.js.map +1 -1
  90. package/package.json +3 -3
  91. package/scripts/mock-claude.mjs +32 -17
  92. package/scripts/stamp-telemetry-service.mjs +20 -0
  93. package/web/dist/assets/agent-task-pickers-mJzYn0UB.js +1 -0
  94. package/web/dist/assets/{alert-dialog-CF_-dmQ1.js → alert-dialog-Dd1WPOaz.js} +1 -1
  95. package/web/dist/assets/arrow-left-fsST4JqT.js +1 -0
  96. package/web/dist/assets/{automation-format-D1nqk0ID.js → automation-format-BTIFWfjt.js} +1 -1
  97. package/web/dist/assets/automations-route-DJjhwqug.js +1 -0
  98. package/web/dist/assets/button-BNnH7COh.js +100 -0
  99. package/web/dist/assets/{centered-state-T0J7VmBb.js → centered-state-sEYB3bgq.js} +1 -1
  100. package/web/dist/assets/check-DA37PQLT.js +1 -0
  101. package/web/dist/assets/chevron-left-zbXV2Qbu.js +1 -0
  102. package/web/dist/assets/chevron-right-Beu1pd6H.js +1 -0
  103. package/web/dist/assets/{collapsible-RD4hkew7.js → collapsible-MuXfYnM8.js} +1 -1
  104. package/web/dist/assets/commit-list-Bps23fvP.js +1 -0
  105. package/web/dist/assets/compare-variants-CQskdfDW.js +1 -0
  106. package/web/dist/assets/composer-DKWLJeo9.js +18 -0
  107. package/web/dist/assets/dashboard-BCNe_6p7.js +44 -0
  108. package/web/dist/assets/diff-CrLUECGW.js +3 -0
  109. package/web/dist/assets/{diff-stat-CFoeFye2.js → diff-stat-SpfygteL.js} +1 -1
  110. package/web/dist/assets/diff-view-DP4Gw3QJ.js +13 -0
  111. package/web/dist/assets/{download-BFQEsJRY.js → download-CBwSbmy_.js} +1 -1
  112. package/web/dist/assets/dropdown-menu-CxPGHgWX.js +1 -0
  113. package/web/dist/assets/ellipsis-BmusVE8U.js +1 -0
  114. package/web/dist/assets/{file-Df5WtpM_.js → file-DkvcUwxT.js} +1 -1
  115. package/web/dist/assets/file-preview-DxFusXAO.js +2 -0
  116. package/web/dist/assets/file-text-DBeC0yKb.js +1 -0
  117. package/web/dist/assets/file-tree-BTJZXRkM.js +1 -0
  118. package/web/dist/assets/{git-commit-horizontal-DawNm4qg.js → git-commit-horizontal-BM9_nEW7.js} +1 -1
  119. package/web/dist/assets/git-toolbar-DXyPCDkQ.js +1 -0
  120. package/web/dist/assets/github-G5fU4gJd.js +1 -0
  121. package/web/dist/assets/index-BN3w52uE.js +21 -0
  122. package/web/dist/assets/index-CAvSSpvF.css +2 -0
  123. package/web/dist/assets/{markdown-Bmfy_1Ll.js → markdown-BpZ4p95p.js} +1 -1
  124. package/web/dist/assets/{markdown-B_O1ys3h.js → markdown-C5F95Rt-.js} +1 -1
  125. package/web/dist/assets/{message-square-BOO9s3qX.js → message-square-BFQln9c4.js} +1 -1
  126. package/web/dist/assets/{pill-bO5OcHuK.js → pill-BcIQGDbn.js} +1 -1
  127. package/web/dist/assets/project-router-CWMOKp_H.js +3 -0
  128. package/web/dist/assets/reference-chip-B7lU_Pyh.js +1 -0
  129. package/web/dist/assets/reference-overflow-ClRRXWez.js +1 -0
  130. package/web/dist/assets/{refresh-cw-BaFyjVUz.js → refresh-cw-BBEYC6z2.js} +1 -1
  131. package/web/dist/assets/repo-git-CgxxZ7cO.js +1 -0
  132. package/web/dist/assets/{run-diff-GZbNs8fA.js → run-diff-BTB7nBeD.js} +1 -1
  133. package/web/dist/assets/run-header-BPNBEaOy.js +1 -0
  134. package/web/dist/assets/{image-preview-4SVDrBvn.js → scroll-within-DRt7mAnQ.js} +1 -1
  135. package/web/dist/assets/{search-x-bpAfQtVY.js → search-x-6BavY3mg.js} +1 -1
  136. package/web/dist/assets/sheet-D9PeyyRZ.js +1 -0
  137. package/web/dist/assets/skills-SIMzpL0l.js +1 -0
  138. package/web/dist/assets/square-DsFAQaY9.js +1 -0
  139. package/web/dist/assets/tab-link-DEUSZU49.js +1 -0
  140. package/web/dist/assets/{tag-DLwUkUsN.js → tag-DvCVnA6I.js} +1 -1
  141. package/web/dist/assets/task-changes-D-aajoMU.js +1 -0
  142. package/web/dist/assets/task-commits-BYD1GVkS.js +1 -0
  143. package/web/dist/assets/task-composer-7bdNNMP_.js +12 -0
  144. package/web/dist/assets/task-files-BfIOz-eN.js +1 -0
  145. package/web/dist/assets/task-graph-B5-5_IPh.js +1 -0
  146. package/web/dist/assets/task-notes-CfkTBgo8.js +1 -0
  147. package/web/dist/assets/task-thread-eEkjTDxr.js +10 -0
  148. package/web/dist/assets/{terminal-CwrL1hAi.js → terminal-xRHwWarr.js} +1 -1
  149. package/web/dist/assets/textarea-rKUFh5lI.js +1 -0
  150. package/web/dist/assets/thread-loading-DLlbK51g.js +1 -0
  151. package/web/dist/assets/{token-metrics-C149OWmd.js → token-metrics-BcPjL36-.js} +1 -1
  152. package/web/dist/assets/tooltip-BVqBAGNb.js +1 -0
  153. package/web/dist/assets/tracker-2DfMzsIE.js +4 -0
  154. package/web/dist/assets/triangle-alert-CP3Xp0FU.js +1 -0
  155. package/web/dist/assets/upload-bwO_2kok.js +1 -0
  156. package/web/dist/assets/use-automations-PceYR6ss.js +5 -0
  157. package/web/dist/assets/use-now-BAKdIYLG.js +1 -0
  158. package/web/dist/assets/use-submit-shortcut-BA4NVpJl.js +1 -0
  159. package/web/dist/assets/workflow-graph-HopaWPea.js +13 -0
  160. package/web/dist/assets/x-HaVPcg_B.js +1 -0
  161. package/web/dist/index.html +28 -31
  162. package/web/dist/assets/agent-task-pickers-C3ydGatB.js +0 -1
  163. package/web/dist/assets/arrow-left-BxBdc5DC.js +0 -1
  164. package/web/dist/assets/automations-route-BsflncpV.js +0 -1
  165. package/web/dist/assets/button-CjSjKnkd.js +0 -100
  166. package/web/dist/assets/check-DAAMuI4o.js +0 -1
  167. package/web/dist/assets/chevron-left-CvcqxpQZ.js +0 -1
  168. package/web/dist/assets/chevron-right-DKiL3NWw.js +0 -1
  169. package/web/dist/assets/commit-list-BJac2uO6.js +0 -1
  170. package/web/dist/assets/compare-variants-CfqICvRy.js +0 -1
  171. package/web/dist/assets/composer-DZx3cwQW.js +0 -18
  172. package/web/dist/assets/dashboard-CpCDiZdE.js +0 -44
  173. package/web/dist/assets/diff-LG2cl0PE.js +0 -3
  174. package/web/dist/assets/diff-controls-QgdH-r3F.js +0 -1
  175. package/web/dist/assets/diff-view-BVwSaBb2.js +0 -13
  176. package/web/dist/assets/dropdown-menu-DkEK7m00.js +0 -1
  177. package/web/dist/assets/editable-title-CJSWyCcL.js +0 -1
  178. package/web/dist/assets/ellipsis-vertical-CB0adfr7.js +0 -1
  179. package/web/dist/assets/external-link-DPKRidDg.js +0 -1
  180. package/web/dist/assets/eye-CEHQ0c-s.js +0 -1
  181. package/web/dist/assets/file-preview-kYsqZiLU.js +0 -2
  182. package/web/dist/assets/file-text-m0tZu8sU.js +0 -1
  183. package/web/dist/assets/git-merge-B7oVXcKc.js +0 -1
  184. package/web/dist/assets/git-toolbar-B0K4Q5Zv.js +0 -1
  185. package/web/dist/assets/github-C4WaHPni.js +0 -1
  186. package/web/dist/assets/index-CiQrbvAq.js +0 -21
  187. package/web/dist/assets/index-WWaEax-B.css +0 -2
  188. package/web/dist/assets/pencil-CCR9uUZ1.js +0 -1
  189. package/web/dist/assets/reference-chip-Bx_mG9QG.js +0 -1
  190. package/web/dist/assets/repo-git-Mn3_jrGP.js +0 -1
  191. package/web/dist/assets/run-header-i1D5Lvfs.js +0 -1
  192. package/web/dist/assets/sheet-DCdZVHFk.js +0 -1
  193. package/web/dist/assets/skills-Dea5ynJK.js +0 -1
  194. package/web/dist/assets/tab-link-BVItTl_Y.js +0 -1
  195. package/web/dist/assets/task-changes-xNbBM7FO.js +0 -1
  196. package/web/dist/assets/task-commits-BYozE_X3.js +0 -1
  197. package/web/dist/assets/task-composer-Brx0sa7_.js +0 -12
  198. package/web/dist/assets/task-files-MAPO-efK.js +0 -1
  199. package/web/dist/assets/task-graph-BSLCUr1E.js +0 -1
  200. package/web/dist/assets/task-thread-CRVmwchQ.js +0 -9
  201. package/web/dist/assets/textarea-Bb0_Hz53.js +0 -1
  202. package/web/dist/assets/thread-loading-Bo6IOu3Y.js +0 -1
  203. package/web/dist/assets/toaster-Hj_czp_o.js +0 -3
  204. package/web/dist/assets/tooltip--PYfu68E.js +0 -1
  205. package/web/dist/assets/tracker-DM5WtYD0.js +0 -4
  206. package/web/dist/assets/trash-2-EdjdGvEo.js +0 -1
  207. package/web/dist/assets/triangle-alert-DpH3QFz6.js +0 -1
  208. package/web/dist/assets/use-automations-XKvBTPM-.js +0 -5
  209. package/web/dist/assets/use-now-CrM50BFB.js +0 -1
  210. package/web/dist/assets/use-submit-shortcut-BJ10ZshV.js +0 -1
  211. package/web/dist/assets/workflow-graph-Y2Pr7ubb.js +0 -13
  212. package/web/dist/assets/x-BkwTUDpG.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{At as r,Br as i,Dt as a,Fn as o,G as s,Hi as c,In as l,J as u,Jn as d,K as f,Kr as p,Pn as m,S as h,Sn as g,T as _,Tt as v,V as y,Wn as b,X as x,Xn as S,Y as C,Yr as ee,Z as w,aa as T,at as E,bn as D,c as O,dr as te,f as k,gn as A,h as j,hn as M,jn as N,jt as P,kn as F,mr as ne,mt as re,na as I,nt as ie,pn as ae,qr as oe,sr as se,t as L,tr as ce,ur as le,wn as ue,wr as de,yn as fe,zr as pe}from"./project-router-CWMOKp_H.js";import{F as R,Tt as me,i as he,r as z,t as B}from"./button-BNnH7COh.js";import{A as ge,B as _e,E as ve,I as ye,K as be,L as xe,M as Se,N as Ce,R as V,V as we,at as Te,c as Ee,ct as De,i as Oe,k as ke,n as Ae,r as je,rt as Me,t as Ne,v as Pe,z as Fe}from"./reference-overflow-ClRRXWez.js";import{_ as Ie,c as Le,f as Re,g as ze,h as Be,m as Ve,p as He,t as Ue,u as We,y as Ge}from"./reference-chip-B7lU_Pyh.js";import{i as Ke,n as qe,t as Je}from"./textarea-rKUFh5lI.js";import{t as Ye}from"./check-DA37PQLT.js";import{i as Xe,n as Ze,p as H,r as Qe,t as $e}from"./tooltip-BVqBAGNb.js";import{n as et}from"./x-HaVPcg_B.js";import{_ as tt,c as U,i as W,n as G,r as K,s as q,t as J}from"./dropdown-menu-CxPGHgWX.js";import{n as nt,t as rt}from"./ellipsis-BmusVE8U.js";import{r as it}from"./centered-state-sEYB3bgq.js";import{r as at,t as ot}from"./use-submit-shortcut-BA4NVpJl.js";import{n as st,r as ct}from"./git-toolbar-DXyPCDkQ.js";import{n as lt,r as ut,t as dt}from"./collapsible-MuXfYnM8.js";import{a as ft,c as pt,i as mt,n as ht,o as gt,r as _t,s as vt,t as yt}from"./alert-dialog-Dd1WPOaz.js";import{i as bt,t as xt}from"./token-metrics-BcPjL36-.js";import{t as St}from"./diff-stat-SpfygteL.js";import{n as Ct,t as wt}from"./pill-BcIQGDbn.js";import{t as Y}from"./tab-link-DEUSZU49.js";var Tt=R(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Et=R(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Dt=R(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),X=e(t(),1),Ot=e=>e===`running`||e===`queued`||e===`waiting`,kt=`no worktree — this task ran directly in the repo working tree`;function At(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.uncommitted===void 0?t(`Commit unavailable — changes are still loading`):e.uncommitted===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${kt}`)}function jt(e){let t=At(e);return Mt({...e,unpushed:void 0,status:`done`}).enabled?{...t,id:`commit-push`,label:`Commit and push`,...t.reason?{reason:t.reason.replace(/^Commit unavailable/,`Commit and push unavailable`)}:{}}:t}function Mt(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):e.unpushed===0?t(`Push unavailable — the remote already has every commit`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${kt}`)}function Nt(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${kt}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?Ot(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0,alternatives:[{id:`create-draft-pr`,label:`Create draft PR`,enabled:!0}]}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function Pt(e){if(!e.hasWorktree||e.prStatus===`merged`||e.prStatus===`closed`)return null;let t=e.behind!==void 0&&e.behind!==null&&e.behind>0&&!e.agentBlocked?Ft(e,`update-branch`,`Update branch`):null;if(!e.prUrl&&e.forge!==null)return t??Nt(e);if(e.uncommitted===void 0)return null;let n=e.uncommitted>0;return e.prUrl?n?jt(e):e.unpushed!==void 0&&e.unpushed!==null&&e.unpushed>0?Mt(e):e.prConflicting===!0?Ft(e,`resolve-conflicts`,`Resolve conflicts`):t||(e.prStatus===`checks-failing`?Ft(e,`fix-checks`,`Fix errors`):null):n?jt(e):e.unpushed===0?t:Mt(e)}function Ft(e,t,n){return e.agentBlocked?{id:t,label:n,enabled:!1,reason:`${n} unavailable — ${e.agentBlocked}`}:{id:t,label:n,enabled:!0}}var Z=n();function It({run:e,confirming:t,onOpenChange:n,onConfirm:r}){return(0,Z.jsx)(yt,{open:t!==null,onOpenChange:n,children:(0,Z.jsxs)(mt,{children:[(0,Z.jsxs)(vt,{children:[(0,Z.jsx)(pt,{children:t===`delete`?`Delete this task?`:`Stop this task?`}),(0,Z.jsx)(ft,{children:t===`delete`?(0,Z.jsxs)(Z.Fragment,{children:[`This removes the run, its transcript, its worktree and its branch. There is no undo.`,(0,Z.jsx)(`span`,{className:`mt-1 block truncate font-medium text-foreground`,title:N(e),children:N(e)})]}):e.status===`queued`?`The task leaves the queue before it starts and completes as cancelled.`:`The agent is stopped and the run completes as cancelled. The worktree stays.`})]}),(0,Z.jsxs)(gt,{children:[(0,Z.jsx)(_t,{children:`Keep it`}),(0,Z.jsx)(ht,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t&&r(t),n(!1)},children:t===`delete`?`Delete`:`Stop the run`})]})]})})}function Lt(e){let t=T(),[n,r]=(0,X.useState)(null),i=()=>t.invalidateQueries({queryKey:j.runs.all}),a=I({mutationFn:()=>S(e.id),onSuccess:i,onError:e=>{e instanceof b&&e.status===409&&i(),k(e.message,{tone:`danger`})}});return{request:()=>r(`cancel`),pending:a.isPending,dialog:(0,Z.jsx)(It,{run:e,confirming:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>a.mutate()})}}function Rt(e){let t=_(),n=h(),r=e.runner??t.data?.defaultRunner??`claude`,i=e.model??`auto`,a=[...e.steps].reverse().find(e=>e.profileId)?.profileId,o=a===void 0?void 0:a==="default"?`default`:n.data?.profiles.find(e=>e.id===a)?.label??`${a} (removed)`;return{runner:r,account:o,model:i,identity:e.modelIdentity&&e.modelIdentity!==i?e.modelIdentity:void 0,summary:[r,o,i].filter(Boolean).join(` · `)}}function zt({run:e}){let t=Rt(e),n=r(t.runner),i=Pe(t.runner,n.data,[e.model]).find(e=>e.id===t.model)?.label??t.model,a=`The session’s engine — pick another when you continue it`;return(0,Z.jsxs)(`div`,{"data-slot":`run-engine`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(Ee,{slot:`run-engine-runner`,ariaLabel:`Agent`,label:t.account&&t.account!=="default"?`${t.runner} · ${t.account}`:t.runner,value:t.runner,options:[],onPick:()=>{},readOnly:!0,hint:a}),(0,Z.jsx)(Ee,{slot:`run-engine-model`,ariaLabel:`Model`,label:i,value:t.model,options:[],onPick:()=>{},readOnly:!0,hint:t.identity?`${a} (served as ${t.identity})`:a})]})}function Bt(e){let t=[];for(let n of e)n.id!==void 0&&t.push({id:n.id,mediaType:n.mediaType,name:n.name,bytes:0});return t}function Vt(e,t,{enabled:n=!0}={}){let r=T(),i=n&&e!==``&&t!==``,a=v(i?e:void 0),o=a.data?.surfaces?.[t],[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)([]),d=`${e} ${t}`,[f,m]=(0,X.useState)(d),h=(0,X.useRef)(!1),g=(0,X.useRef)(void 0),_=(0,X.useRef)(!1),y=(0,X.useRef)(null),b=(0,X.useRef)(Promise.resolve()),x=(0,X.useRef)({runId:e,surface:t,text:s,images:l});x.current.text=s,x.current.images=l;let S=(0,X.useRef)([]);if(f!==d){if(m(d),y.current!==null){clearTimeout(y.current),y.current=null;let e=x.current;S.current=[...S.current.filter(t=>t.runId!==e.runId||t.surface!==e.surface),{runId:e.runId,surface:e.surface,text:e.text,images:e.images.map(e=>e.id).filter(e=>e!==void 0)}]}c(``),u([]),h.current=!1,_.current=!1,x.current={runId:e,surface:t,text:``,images:[]}}let C=(0,X.useCallback)((e,t,n)=>{r.setQueryData(j.runs.drafts(e),e=>{let r={...e?.surfaces??{}};return n===null||n.text===``&&n.images.length===0?delete r[t]:r[t]={...n,updatedAt:new Date().toISOString()},{surfaces:r}})},[r]),w=(0,X.useRef)(C);w.current=C;let E=(0,X.useRef)(i);E.current=i;let D=(0,X.useCallback)((e,t,n,r)=>{E.current&&(b.current=b.current.catch(()=>{}).then(()=>ee(e,t,n,r?{keepalive:!0}:void 0)).then(n=>w.current(e,t,n)).catch(()=>{}))},[]),O=(0,X.useCallback)(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null)},[]),k=(0,X.useCallback)(e=>{O();let t=x.current;D(t.runId,t.surface,{text:t.text,images:t.images.map(e=>e.id).filter(e=>e!==void 0)},e)},[O,D]),A=(0,X.useCallback)(()=>{O(),y.current=setTimeout(()=>{y.current=null,!_.current&&k()},500)},[O,k]),M=(0,X.useCallback)((n,r)=>{h.current=!0,E.current&&(C(e,t,{text:n,images:Bt(r)}),A())},[C,e,A,t]),N=(0,X.useCallback)(e=>{c(e),x.current={...x.current,text:e},M(e,x.current.images)},[M]),P=(0,X.useCallback)((n,r=`edit`)=>{let i=x.current.images.map(e=>e.id).filter(e=>e!==void 0&&!n.some(t=>t.id===e));if(u(n),x.current={...x.current,images:n},M(x.current.text,n),r!==`submit`&&E.current)for(let n of i)te(e,t,n).catch(()=>{});let a=e,o=t;for(let e of n)e.id!==void 0||!E.current||p(a,o,{mediaType:e.mediaType,data:e.data,name:e.name}).then(t=>{x.current.runId!==a||x.current.surface!==o||(u(n=>{let r=n.map(n=>n===e?{...n,id:t.id}:n);return x.current={...x.current,images:r},r}),M(x.current.text,x.current.images))}).catch(()=>{})},[M,e,t]),F=(0,X.useCallback)(()=>{O(),_.current=!1,c(``),u([]),x.current={...x.current,text:``,images:[]},h.current=!1,g.current=d,C(e,t,null),D(e,t,{text:``,images:[]})},[C,O,d,e,t,D]),ne=(0,X.useCallback)(async e=>{_.current=!0,O();try{let t=await e();return _.current=!1,F(),t}catch(e){throw _.current=!1,A(),e}},[O,F,A]);return(0,X.useEffect)(()=>{if(S.current.length===0)return;let e=S.current;S.current=[];for(let t of e)D(t.runId,t.surface,{text:t.text,images:t.images})}),(0,X.useEffect)(()=>{if(g.current===d||o===void 0||(g.current=d,h.current))return;let n=typeof o.text==`string`?o.text:``,r=Array.isArray(o.images)?o.images:[];if(c(n),x.current={...x.current,text:n},r.length===0)return;let i=!0;return Promise.all(r.slice(0,4).map(async n=>{try{let r=await de(e,t,n.id),i=me(r.mediaType),a=r.name!==``&&r.name!==Oe(r.mediaType,i);return{id:r.id,mediaType:r.mediaType,data:r.data,name:r.name||Oe(r.mediaType,i),...a?{originalName:r.name}:{},...i?{preview:`data:${r.mediaType};base64,${r.data}`}:{},isImage:i}}catch{return null}})).then(e=>{let t=e.filter(e=>e!==null);!i||t.length===0||h.current||(u(t),x.current={...x.current,images:t})}),()=>{i=!1}},[o,d,e,t]),(0,X.useEffect)(()=>{let e=()=>{y.current===null||_.current||k(!0)},t=()=>{document.visibilityState===`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,e)}},[k]),(0,X.useEffect)(()=>()=>{y.current!==null&&k()},[k]),{ready:!i||a.isSuccess||a.isError,hasDraft:s!==``||l.length>0,text:s,setText:N,images:l,setImages:P,submit:ne,clear:F}}function Ht({run:e,open:t,onOpenChange:n,andPush:r=!1,onCommitted:i}){let a=T(),[o,s]=(0,X.useState)(``),c=N(e),l=(0,X.useRef)(c);l.current=c,(0,X.useEffect)(()=>{t&&s(l.current)},[t]);let u=I({mutationFn:t=>ce(e.id,t),onSuccess:t=>{k(`Committed ${t.sha.slice(0,7)}${r?` — pushing…`:``}`),i?.(),n(!1),a.invalidateQueries({queryKey:j.runs.changes(e.id)}),a.invalidateQueries({queryKey:j.runs.gitStatus(e.id)}),a.invalidateQueries({queryKey:j.runs.all})},onError:e=>k(e.message,{tone:`danger`})}),d=()=>{let e=o.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Z.jsx)(Re,{open:t,onOpenChange:n,children:(0,Z.jsxs)(He,{"data-slot":`commit-dialog`,children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Ie,{children:r?`Commit and push`:`Commit changes`}),(0,Z.jsxs)(Ve,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Z.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,r?`, then pushes it`:``,`.`]})]}),(0,Z.jsx)(Je,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{ot({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(),d())}}),(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(B,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Z.jsx)(B,{"data-slot":`commit-confirm`,disabled:o.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:r?`Commit and push`:`Commit`})]})]})})}function Ut(e){let t=M(e),n=t?.url??(t?.number===void 0?void 0:`#${t.number}`),r=t?.number,i=We(`PR`,r),o=i.status,s=o===`merged`||o===`closed`,c=y(),l=re(),u=a(e.id,!!e.worktreePath&&!s,Ce(e.status)),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),h=ke(e),[g,_]=(0,X.useState)(!1),v=async(e,t)=>{if(g||h.isPending||h.blockedBy)return;let n=h.mode===`resume`;_(!0);try{let i=await h.send(e);i?k(i,{tone:`danger`}):k(`${n?`Task reopened`:`Sent to the task`} — ${t}${r?` in PR #${r}`:``}`)}finally{_(!1)}},x=T(),S=()=>x.invalidateQueries({queryKey:j.runs.all}),C=e=>k(e.message,{tone:`danger`}),ee=I({mutationFn:()=>oe(e.id),onSuccess:t=>{k(t.upstreamSet?`Pushed ${t.branch} to ${t.remote} (upstream set)`:`Pushed ${t.branch} to ${t.remote}`),x.invalidateQueries({queryKey:j.runs.gitStatus(e.id)})},onError:C}),w=I({mutationFn:t=>se(e.id,{draft:t}),onSuccess:(e,t)=>{k(`${t?`Draft PR`:`PR`} created — ${e.url}`),S()},onError:C}),E=u.isError&&u.error instanceof b&&u.error.status===409,D=Pt({status:e.status,hasWorktree:!E,branch:e.branch,uncommitted:u.data?.uncommitted,unpushed:u.data?.unpushed,behind:u.data?.behind,remote:l.data?.info?.remote,forge:c.data?.forge??null,prUrl:n,prStatus:o,prConflicting:i.conflicting,agentBlocked:h.blockedBy?h.reason??`the agent cannot be reached`:void 0});return{action:e.worktreePath?D:null,onAction:t=>{switch(t){case`commit`:m(!1),f(!0);break;case`commit-push`:m(!0),f(!0);break;case`push`:ee.mutate();break;case`create-pr`:w.mutate(!1);break;case`create-draft-pr`:w.mutate(!0);break;case`update-branch`:v(Fe(e.baseBranch),`updating the branch`);break;case`resolve-conflicts`:v(ye(r),`resolving conflicts`);break;case`fix-checks`:v(Se(r),`fixing the errors`);break}},dialogs:(0,Z.jsx)(Ht,{run:e,open:d,onOpenChange:f,andPush:p,onCommitted:p?()=>ee.mutate():void 0})}}function Q(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 Wt(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 Gt({steps:e}){if(e.length===0)return null;let t=Wt(e)*100;return(0,Z.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,Z.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Q(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,Z.jsx)(Kt,{visual:Q(t.status)}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,Z.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11.5px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,Z.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function Kt({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Z.jsx)(et,{"aria-hidden":!0,className:z(t,`text-success`)});case`active`:return(0,Z.jsx)(it,{role:`status`,"aria-label":`Step running`,className:z(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,Z.jsx)(Ge,{"aria-hidden":!0,className:z(t,`text-danger`)});case`pending`:return(0,Z.jsx)(tt,{"aria-hidden":!0,className:z(t,`text-soft-foreground`)})}}function qt(e){let t=e.findIndex(e=>Q(e.status)===`active`);if(t>=0)return t;let n=e.findIndex(e=>Q(e.status)===`pending`);return n>=0?n:Math.max(0,e.length-1)}function Jt({visual:e}){return(0,Z.jsx)(`span`,{"aria-hidden":!0,"data-slot":`step-dot`,"data-visual":e,className:z(`size-1.5 rounded-full`,e===`done`?`bg-success`:e===`failed`?`bg-danger`:e===`active`?`bg-pending`:`bg-soft-foreground`,e===`active`&&`animate-pulse motion-reduce:animate-none`)})}var Yt=new Map;function Xt({runId:e,steps:t}){let[n,r]=(0,X.useState)(()=>Yt.get(e)??!1);if(t.length===0)return null;let i=t=>{Yt.set(e,t),r(t)},a=qt(t),o=t[a],s=Wt(t)*100;return(0,Z.jsxs)(dt,{"data-slot":`workflow-steps`,open:n,onOpenChange:i,className:`min-w-0`,children:[(0,Z.jsxs)(ut,{"aria-label":`Workflow: ${o.name}, step ${a+1} of ${t.length}`,className:`group -my-2 flex min-h-11 w-full items-center gap-2 text-left text-xs text-muted-foreground hover:text-foreground md:my-0 md:min-h-[30px] md:gap-2.5`,children:[(0,Z.jsx)(`span`,{"data-slot":`step-dots`,className:`flex shrink-0 items-center gap-1`,children:t.map(e=>(0,Z.jsx)(Jt,{visual:Q(e.status)},e.id))}),(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[45%] shrink truncate font-semibold text-foreground`,children:o.name}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-soft-foreground tabular-nums`,children:[`step `,a+1,` of `,t.length]}),(0,Z.jsx)(`span`,{"data-slot":`step-summary-progress`,className:`h-0.5 min-w-[36px] flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`span`,{className:`block h-full rounded-full bg-pending`,style:{width:`${s}%`}})}),(0,Z.jsx)(H,{"aria-hidden":!0,className:`size-4 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(lt,{children:(0,Z.jsx)(`div`,{className:`pt-2`,children:(0,Z.jsx)(Gt,{steps:t})})})]})}function Zt(e){let t=T();return I({mutationFn:()=>ne(e),onSuccess:()=>t.invalidateQueries({queryKey:j.runs.all}),onError:e=>k(e.message,{tone:`danger`})})}var Qt=new Map,$t=Object.values({run:(e,t)=>e.run===t.run,tab:(e,t)=>e.tab===t.tab,onMarkedUnread:(e,t)=>e.onMarkedUnread===t.onMarkedUnread,continuationEngine:(e,t)=>e.continuationEngine===t.continuationEngine,planTally:(e,t)=>e.planTally?.done===t.planTally?.done&&e.planTally?.total===t.planTally?.total}),en=(0,X.memo)(tn,(e,t)=>$t.every(n=>n(e,t)));function tn({run:e,planTally:t,tab:n=`session`,onMarkedUnread:r,continuationEngine:i}){let a=l(e),s=o(e),c=V(e),u=xe(e),d=cn(e,r),f=n===`session`,[,p]=(0,X.useReducer)(e=>e+1,0),m=(0,X.useId)(),h=Qt.get(e.id)??!1,g=()=>{Qt.set(e.id,!h),p()},_=P((0,X.useMemo)(()=>t=>e.status===`queued`?F(t).get(e.id):void 0,[e.id,e.status])).data,v=y(),b=xt(v.data),x=pn(e);return(0,Z.jsx)(Le,{projectId:x.projectId,requests:x.requests,children:(0,Z.jsxs)(`header`,{"data-slot":`run-header`,className:`relative z-20 border-b border-border bg-background/95 px-3 pt-2 backdrop-blur md:sticky md:top-0 md:px-6 md:pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[var(--measure)]`,children:[(0,Z.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-h-[30px] min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(`span`,{"data-slot":`run-identity`,className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,Z.jsx)(un,{run:e}),(0,Z.jsx)(rn,{planTally:t,budget:s})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2.5`,children:[(0,Z.jsx)(nn,{attention:a,queuePosition:_}),(0,Z.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`md:hidden`,"aria-label":h?`Hide run details`:`Show run details`,"aria-controls":m,"aria-expanded":h,onClick:g,children:(0,Z.jsx)(H,{"aria-hidden":`true`,className:z(`transition-transform`,h&&`rotate-180`)})}),(0,Z.jsx)(Cn,{run:e,actions:d,showRunControls:!f})]})]}),(0,Z.jsx)(`div`,{id:m,"data-slot":`run-details`,className:z(h?`block`:`hidden`,`md:block`),children:(0,Z.jsx)(fn,{run:e,references:x.references,actions:(0,Z.jsxs)(`div`,{"data-slot":`run-actions`,className:`ml-auto hidden items-center gap-1 md:flex`,children:[(0,Z.jsx)(on,{run:e,actions:d,showRunControls:!f}),(0,Z.jsx)(sn,{run:e,canResume:c.terminal,onResume:()=>d.terminal.mutate()})]}),continuationEngine:i,showTokens:b.tokens,showCost:b.cost,automationsAvailable:v.data?.capabilities?.automations===!0})}),(0,Z.jsx)(xn,{run:e}),(0,Z.jsx)(gn,{run:e}),(0,Z.jsx)(yn,{run:e}),(0,Z.jsxs)(`div`,{"data-slot":`run-tabs`,className:`mt-1.5 flex items-end gap-1 overflow-x-auto md:mt-2.5 md:overflow-x-visible`,children:[(0,Z.jsx)(Y,{to:`/tasks/${e.id}`,active:n===`session`,children:`Session`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/changes`,active:n===`changes`,children:`Changes`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/commits`,active:n===`commits`,children:`Commits`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/files`,active:n===`files`,children:`Files`}),e.workflowDef?(0,Z.jsx)(Y,{to:`/tasks/${e.id}/graph`,active:n===`graph`,children:`Graph`}):null,(0,Z.jsx)(Y,{to:`/tasks/${e.id}/notes`,active:n===`notes`,children:`Notes`}),(0,Z.jsx)(hn,{run:e,showTokens:b.tokens,showCost:b.cost,continuationEngine:i,className:`ml-auto hidden pb-1.5 md:flex`})]}),e.steps.length>0?(0,Z.jsx)(`div`,{className:`border-t border-border pt-1 pb-0 md:pt-2 md:pb-1`,children:(0,Z.jsx)(Xt,{runId:e.id,steps:e.steps})}):null,u?(0,Z.jsx)(Tn,{hint:u}):null]}),(0,Z.jsx)(It,{run:e,confirming:d.confirming,onOpenChange:e=>!e&&d.setConfirming(null),onConfirm:e=>e===`delete`?d.delete.mutate():d.cancel.mutate()})]})})}function nn({attention:e,queuePosition:t}){return(0,Z.jsxs)(wt,{className:`shrink-0`,dot:e.tone,pulse:e.pulse,children:[e.label,t===void 0?``:` #${t}`]})}function rn({planTally:e,budget:t}){return(0,Z.jsxs)(Z.Fragment,{children:[e?(0,Z.jsxs)(`span`,{"data-slot":`plan-mirror`,className:`hidden shrink-0 text-[11px] text-soft-foreground tabular-nums md:inline`,children:[`Plan `,e.done,`/`,e.total]}):null,t?(0,Z.jsxs)(`span`,{"data-slot":`budget-stop`,className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[`Spent `,ae(t.spent)||`$0.00`,` of `,ae(t.ceiling)||`$0.00`]}):null]})}function an(e){return Ce(e.status)?`Stop the task first`:void 0}function on({run:e,actions:t,showRunControls:n}){let r=V(e),i=an(e),a=n&&r.cancel,o=n&&e.status===`waiting`;return(0,Z.jsxs)(`span`,{"data-slot":`task-item-actions`,className:`mx-1 flex items-center gap-0.5`,children:[r.markRead||r.markUnread?(0,Z.jsx)($,{slot:`unread-toggle`,label:r.markRead?`Mark read`:`Mark unread`,title:r.markRead?`Unread — mark it read`:`Mark unread — put it back in your unread list`,pressed:r.markRead,pending:t.markRead.isPending||t.markUnread.isPending,onClick:()=>r.markRead?t.markRead.mutate():t.markUnread.mutate(),className:z(r.markRead&&`text-violet hover:text-violet [&_svg]:fill-violet/25`),children:(0,Z.jsx)(Dt,{"aria-hidden":`true`})}):null,(0,Z.jsx)($,{slot:`pin-run`,label:e.pinned?`Unpin`:`Pin`,title:e.pinned?`Pinned — unpin from the top of this project’s task list`:`Pin to the top of this project’s task list`,pressed:!!e.pinned,unavailable:r.pin?void 0:`Archived tasks can’t be pinned`,pending:t.pin.isPending,onClick:t.pin.mutate,className:z(e.pinned&&`text-violet hover:text-violet [&_svg]:fill-violet/25`),children:(0,Z.jsx)(Te,{"aria-hidden":`true`})}),(0,Z.jsx)($,{slot:`archive-run`,label:e.archived?`Unarchive`:`Archive`,title:e.archived?`Archived — move it back to the active list`:`Move to the archived list`,pressed:!!e.archived,unavailable:i,pending:t.archive.isPending,onClick:()=>t.archive.mutate(),className:z(e.archived&&`text-violet hover:text-violet [&_svg]:fill-violet/25`),children:(0,Z.jsx)(De,{"aria-hidden":`true`})}),(0,Z.jsx)($,{slot:`delete-run`,label:`Delete`,title:`Delete the task, its worktree and its branch`,unavailable:i,danger:!0,onClick:()=>t.setConfirming(`delete`),className:`ml-1`,children:(0,Z.jsx)(qe,{"aria-hidden":`true`})}),a||o?(0,Z.jsxs)(J,{children:[(0,Z.jsx)(be,{label:`More actions`,children:(0,Z.jsx)(U,{asChild:!0,children:(0,Z.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,children:(0,Z.jsx)(rt,{"aria-hidden":`true`})})})}),(0,Z.jsxs)(G,{align:`end`,"data-slot":`run-more-menu`,children:[o?(0,Z.jsxs)(K,{onSelect:()=>t.finish.mutate(),children:[(0,Z.jsx)(Ye,{"aria-hidden":`true`}),` End session`]}):null,a?(0,Z.jsxs)(K,{variant:`destructive`,onSelect:()=>t.setConfirming(`cancel`),children:[(0,Z.jsx)(Tt,{"aria-hidden":`true`}),` Stop`]}):null]})]}):null]})}function $({slot:e,label:t,title:n,unavailable:r,pending:i=!1,pressed:a,danger:o=!1,onClick:s,className:c,children:l}){let u=r!==void 0;return(0,Z.jsx)(be,{label:r??n,children:(0,Z.jsx)(B,{variant:`ghost`,size:`icon-sm`,"data-slot":e,"aria-label":t,"aria-pressed":a,"aria-disabled":u||void 0,disabled:i,onClick:u?void 0:s,className:z(c,o&&`hover:bg-danger/10 hover:text-danger`,u&&`cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground`),children:l})})}function sn({run:e,canResume:t,onResume:n}){let r=u(),i=ie(),a=I({mutationFn:t=>pe(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),o=c(i.data),s=e=>!i.isSuccess||o.includes(e??`claude`),l=t&&s(e.runner),d=e.worktreePath?(r.data?.targets??[]).filter(e=>{let t=we(e.id);return t===void 0||s(t)}).map(t=>({target:t,...ge(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[];return!l&&d.length===0?null:(0,Z.jsx)(_e,{choices:d,onPick:e=>a.mutate(e),title:`Resume in a terminal, or open the worktree locally`,leading:l?(0,Z.jsxs)(K,{"data-target":`terminal-resume`,onSelect:n,children:[(0,Z.jsx)(Me,{"aria-hidden":`true`}),`Terminal (resume session)`]}):null,trailing:e.worktreePath?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{}),(0,Z.jsxs)(K,{onSelect:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,Z.jsx)(nt,{"aria-hidden":`true`}),`Copy worktree path`]})]}):null})}function cn(e,t){let n=T(),r=O(),[a,o]=(0,X.useState)(null),c=()=>n.invalidateQueries({queryKey:j.runs.all}),l=e=>{e instanceof b&&e.status===409&&c(),k(e.message,{tone:`danger`})},u=Zt(e.id),p=I({mutationFn:()=>d(e.id,!e.archived),onSuccess:c,onError:l}),m=x(),h={isPending:m.isPending,mutate:()=>m.mutate({id:e.id,pinned:!e.pinned},{onError:l})},g=f(),_={isPending:g.isPending,mutate:()=>{t?.(),g.mutate(e.id,{onError:l})}},v=s();return{finish:u,archive:p,pin:h,markUnread:_,markRead:{isPending:v.isPending,mutate:()=>v.mutate(e.id,{onError:l})},cancel:I({mutationFn:()=>S(e.id),onSuccess:c,onError:l}),delete:I({mutationFn:()=>le(e.id),onSuccess:()=>{c(),r(`/`)},onError:l}),terminal:I({mutationFn:()=>i(e.id),onError:e=>{if(e instanceof b&&e.command){ln(e.command,`No terminal found — command copied to clipboard.`);return}l(e)}}),confirming:a,setConfirming:o}}async function ln(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function un({run:e}){let t=C(e.id),n=N(e),r=Vt(e.id,`title`),i=je(n,e=>t.mutate({title:e},{onError:e=>k(e.message,{tone:`danger`})})),a={...i,setDraft:e=>{i.setDraft(e),r.setText(e)},commit:()=>{i.commit(),r.clear()},cancel:()=>{i.cancel(),r.clear()}},o=(0,X.useRef)(i.beginWith);o.current=i.beginWith;let s=i.editing;return(0,X.useEffect)(()=>{s||!r.ready||!r.hasDraft||o.current(r.text)},[r.hasDraft,r.ready,r.text,s]),i.editing?(0,Z.jsx)(Ae,{editor:a,className:`flex-1 text-[15px] font-semibold`}):(0,Z.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(`h1`,{className:`min-w-0 truncate text-[15px] font-semibold`,title:e.task,children:n}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:i.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Z.jsx)(at,{className:`size-3.5`,"aria-hidden":`true`})})]})}function dn({branch:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(null);return(0,X.useEffect)(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),(0,Z.jsx)(Qe,{children:(0,Z.jsxs)($e,{open:r,onOpenChange:e=>{e&&a.current===null&&n(!1),i(e)},children:[(0,Z.jsx)(Xe,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`branch-chip`,className:`cursor-copy rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,"aria-label":`Copy branch name ${e}`,onClick:()=>{if(!navigator.clipboard){k(`Branch: ${e}`);return}navigator.clipboard.writeText(e).then(()=>{n(!0),i(!0),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,i(!1)},1500)}).catch(()=>k(`Branch: ${e}`))},children:[e,(0,Z.jsx)(`span`,{className:`sr-only`,role:`status`,children:t?`Branch name copied`:``})]})}),(0,Z.jsx)(Ze,{children:t?`Copied`:`Copy branch name`})]})})}function fn({run:e,references:t,actions:n,showTokens:r,showCost:i,automationsAvailable:a,continuationEngine:o}){let s=w(),c=[(0,Z.jsx)(`span`,{children:ue(e)},`workflow`)],l=e.branch;l&&c.push((0,Z.jsx)(dn,{branch:l},`branch`)),e.diffStat&&c.push((0,Z.jsx)(St,{stat:e.diffStat},`diff`)),c.push(...mn(e,t));let u=fe(e,s);if(u&&he(u)){let t=A(u);c.push((0,Z.jsx)(Ue,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:u},taskTitle:N(e),className:`h-5`},`issue`))}return e.automation&&c.push(a?(0,Z.jsx)(L,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:`rounded-sm border border-border bg-card px-1.5 py-px text-[11px] font-medium hover:text-foreground`,children:`Automation`},`automation`):(0,Z.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:`rounded-sm border border-border bg-card px-1.5 py-px text-[11px] font-medium`,children:`Automation`},`automation`)),(0,Z.jsxs)(`div`,{"data-slot":`run-meta`,className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground md:mt-1.5 md:gap-y-1`,children:[c.map((e,t)=>(0,Z.jsxs)(X.Fragment,{children:[t>0?(0,Z.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),n,(0,Z.jsx)(hn,{run:e,showTokens:r,showCost:i,continuationEngine:o,className:`ml-auto md:hidden`})]})}function pn(e){let t=w(),n=E(),r=(0,X.useMemo)(()=>g(e,t),[e,t]);return{projectId:n,references:r,requests:(0,X.useMemo)(()=>n===void 0?[]:r.map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n])}}function mn(e,t){let n=[],r=t.filter(e=>e.kind===`PR`),i=D(e);i&&he(i)&&!r.some(e=>e.url===i)&&r.push({kind:`PR`,url:i});let[a]=r;return a&&n.push((0,Z.jsxs)(`span`,{"data-slot":`run-pr-refs`,className:`flex flex-nowrap items-center gap-1`,children:[(0,Z.jsx)(Ue,{reference:a,taskTitle:N(e),className:`h-5 shrink-0`,conflictAction:(0,Z.jsx)(ve,{run:e,prNumber:a.number})}),r.length>1?(0,Z.jsx)(Ne,{references:r,taskTitle:N(e),hidden:r.length-1}):null]},`pr`)),n}function hn({run:e,showTokens:t,showCost:n,continuationEngine:r,className:i}){let a=[];return t&&(e.inputTokens!==void 0||e.outputTokens!==void 0)&&a.push((0,Z.jsx)(Ct,{inputTokens:e.inputTokens,outputTokens:e.outputTokens},`tokens`)),n&&e.costUsd&&a.push((0,Z.jsx)(`span`,{className:`tabular-nums`,children:ae(e.costUsd)},`cost`)),(0,Z.jsxs)(`span`,{"data-slot":`run-usage`,className:z(`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,i),children:[a.map((e,t)=>(0,Z.jsxs)(X.Fragment,{children:[t>0?(0,Z.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),(0,Z.jsx)(Sn,{run:e,continuationEngine:r})]})}function gn({run:e}){let t=P(),n=e.dispatch?.parentRunId;if(n===void 0)return null;let r=(t.data??[]).find(e=>e.id===n),i=r?l(r):null;return(0,Z.jsxs)(`div`,{"data-slot":`dispatch-parent-line`,className:`mt-1 flex min-w-0 items-center gap-2 overflow-hidden text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Dispatched by`}),(0,Z.jsxs)(L,{to:`/tasks/${n}`,"data-slot":`dispatch-parent`,"data-run-id":n,className:`inline-flex min-w-0 items-center gap-1.5 truncate hover:text-foreground`,children:[i?(0,Z.jsx)(bt,{tone:i.tone,pulse:i.pulse}):null,(0,Z.jsx)(`span`,{className:`truncate`,children:r?N(r):n})]})]})}var _n=4,vn=new Map;function yn({run:e}){let t=P(),[,n]=(0,X.useReducer)(e=>e+1,0),r=(0,X.useId)(),i=(t.data??[]).filter(t=>t.dispatch?.parentRunId===e.id);if(i.length===0)return null;let a=vn.get(e.id)??i.length<=_n;return(0,Z.jsxs)(`div`,{"data-slot":`dispatch-children`,className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`dispatch-children-toggle`,"aria-controls":r,"aria-expanded":a,onClick:()=>{vn.set(e.id,!a),n()},className:`flex min-w-0 max-w-full items-center gap-1.5 overflow-hidden hover:text-foreground`,children:[(0,Z.jsx)(H,{"aria-hidden":`true`,className:z(`size-3 shrink-0 transition-transform`,!a&&`-rotate-90`)}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Subtasks`}),(0,Z.jsx)(`span`,{"data-slot":`dispatch-children-count`,className:`shrink-0 tabular-nums`,children:i.length}),(0,Z.jsx)(bn,{subtasks:i})]}),a?(0,Z.jsx)(`div`,{id:r,"data-slot":`dispatch-children-list`,className:`mt-0.5 flex max-h-28 min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 overflow-y-auto overscroll-contain pl-[1.125rem]`,children:i.map(e=>{let t=l(e);return(0,Z.jsxs)(L,{to:`/tasks/${e.id}`,"data-slot":`dispatch-child`,"data-run-id":e.id,title:`${N(e)} — ${t.label}`,className:`inline-flex max-w-52 items-center gap-1.5 truncate hover:text-foreground`,children:[(0,Z.jsx)(bt,{tone:t.tone,pulse:t.pulse}),(0,Z.jsx)(`span`,{className:`truncate`,children:N(e)})]},e.id)})}):null]})}function bn({subtasks:e}){let t=new Map;for(let n of e){let e=l(n),r=t.get(e.label);if(r){r.count+=1;continue}t.set(e.label,{tone:e.tone,pulse:e.pulse,rank:m[e.bucket],count:1})}return(0,Z.jsx)(`span`,{"data-slot":`dispatch-children-tally`,className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:[...t.entries()].sort(([,e],[,t])=>e.rank-t.rank||t.count-e.count).map(([e,t])=>(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(bt,{tone:t.tone,pulse:t.pulse}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:t.count}),(0,Z.jsx)(`span`,{children:e})]},e))})}function xn({run:e}){if(e.status!==`running`||e.activity!==`monitoring`)return null;if(e.monitoringWakeCapReached)return(0,Z.jsx)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:`Automatic checks paused — 40/40 reached`});let t=e.monitoringWakeAt?new Date(e.monitoringWakeAt):null,n=t&&Number.isFinite(t.getTime())?t:null;if(!n)return(0,Z.jsx)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:`Parked — no automatic check scheduled`});let r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n);return(0,Z.jsxs)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:[`Next automatic check`,` `,(0,Z.jsx)(`time`,{dateTime:e.monitoringWakeAt,className:`font-medium text-foreground`,children:r})]})}function Sn({run:e,continuationEngine:t}){let{runner:n,account:r,model:i,identity:a,summary:o}=Rt(e);return(0,Z.jsxs)(J,{children:[(0,Z.jsx)(be,{label:o,children:(0,Z.jsx)(U,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-slot":`agent-badge`,"aria-label":`Agent: ${n}, ${r?`account ${r}, `:``}model ${i}`,className:`flex shrink-0 items-center rounded-sm p-1 text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Z.jsx)(Ke,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})})})}),(0,Z.jsxs)(G,{align:`end`,className:`min-w-[9rem]`,children:[(0,Z.jsxs)(W,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`runner: `,n]}),r?(0,Z.jsxs)(W,{"data-slot":`agent-badge-account`,className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`account: `,r]}):null,(0,Z.jsxs)(W,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`model: `,i]}),a?(0,Z.jsxs)(W,{"data-slot":`agent-badge-identity`,className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`identity: `,a]}):null,t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{}),(0,Z.jsx)(W,{className:`pb-1 text-[11px] font-normal text-muted-foreground`,children:`Next continuation`}),(0,Z.jsx)(`div`,{"data-slot":`agent-badge-engine-picker`,className:`px-2 pb-1`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:t})]}):null]})]})}function Cn({run:e,actions:t,showRunControls:n}){let r=Ut(e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`hidden md:contents`,children:(0,Z.jsx)(ct,{action:r.action,onAction:r.onAction})}),(0,Z.jsx)(wn,{run:e,actions:t,git:r,showRunControls:n}),r.dialogs]})}function wn({run:e,actions:t,git:n,showRunControls:r}){let i=V(e),a=an(e),o=n.action,s=i.markRead;return(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{asChild:!0,children:(0,Z.jsx)(B,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run actions`,className:`md:hidden`,children:(0,Z.jsx)(Et,{"aria-hidden":`true`})})}),(0,Z.jsxs)(G,{align:`end`,"data-slot":`run-actions-menu`,children:[o?(0,Z.jsxs)(Z.Fragment,{children:[[o,...o.alternatives??[]].map(e=>(0,Z.jsxs)(K,{"data-action":e.id,disabled:!e.enabled,title:e.reason,onSelect:()=>n.onAction(e.id),children:[st[e.id],e.label]},e.id)),(0,Z.jsx)(q,{})]}):null,r&&e.status===`waiting`?(0,Z.jsxs)(K,{onSelect:()=>t.finish.mutate(),children:[(0,Z.jsx)(Ye,{"aria-hidden":`true`}),` End session`]}):null,i.terminal?(0,Z.jsxs)(K,{onSelect:()=>t.terminal.mutate(),children:[(0,Z.jsx)(Me,{"aria-hidden":`true`}),` Terminal`]}):null,i.markRead||i.markUnread?(0,Z.jsxs)(K,{"data-slot":`unread-toggle`,"aria-pressed":s,disabled:t.markRead.isPending||t.markUnread.isPending,onSelect:()=>s?t.markRead.mutate():t.markUnread.mutate(),children:[(0,Z.jsx)(Dt,{"aria-hidden":`true`,className:z(s&&`text-violet fill-violet/25`)}),s?`Mark read`:`Mark unread`]}):null,i.pin?(0,Z.jsxs)(K,{"data-slot":`pin-run`,"aria-pressed":!!e.pinned,disabled:t.pin.isPending,onSelect:()=>t.pin.mutate(),children:[(0,Z.jsx)(Te,{"aria-hidden":`true`,className:z(e.pinned&&`text-violet fill-violet/25`)}),e.pinned?`Unpin`:`Pin`]}):null,i.archive?(0,Z.jsxs)(K,{"aria-pressed":!!e.archived,onSelect:()=>t.archive.mutate(),children:[(0,Z.jsx)(De,{"aria-hidden":`true`,className:z(e.archived&&`text-violet fill-violet/25`)}),e.archived?`Unarchive`:`Archive`]}):null,r&&i.cancel||i.deleteRun?(0,Z.jsx)(q,{}):null,r&&i.cancel?(0,Z.jsxs)(K,{variant:`destructive`,onSelect:()=>t.setConfirming(`cancel`),children:[(0,Z.jsx)(Tt,{"aria-hidden":`true`}),` Stop`]}):null,i.deleteRun?(0,Z.jsxs)(K,{variant:`destructive`,disabled:a!==void 0,onSelect:()=>t.setConfirming(`delete`),children:[(0,Z.jsx)(qe,{"aria-hidden":`true`}),` Delete`]}):null]})]})}function Tn({hint:e}){return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`resume-hint`,title:`Copy the command`,onClick:()=>void ln(e,`Command copied to clipboard.`),className:`mb-2 flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,Z.jsx)(nt,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[`take over interactively: `,e]})]})}export{Lt as a,zt as i,Zt as n,Vt as r,en as t};
@@ -1 +1 @@
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{V as i,r as a}from"./button-CjSjKnkd.js";var o=e(t(),1),s=e(n(),1),c=r();function l({src:e,alt:t=``,className:n,...r}){let[l,u]=(0,o.useState)(!1),d=i(e);return(0,o.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`img`,{...r,src:d,alt:t,loading:`lazy`,onClick:()=>u(!0),className:a(`cursor-zoom-in`,n)}),l?(0,s.createPortal)((0,c.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Image preview`,"data-slot":`image-lightbox`,onClick:()=>u(!1),className:`fixed inset-0 z-[100] flex cursor-zoom-out items-center justify-center bg-black/80 p-4 backdrop-blur-sm`,children:(0,c.jsx)(`img`,{src:d,alt:t,className:`max-h-full max-w-full rounded-md object-contain shadow-2xl`})}),document.body):null]})}function u(e){return e.image===!0&&(e.binary===!0||e.patch===``)}function d({file:e,imageSrc:t,onOpenInApp:n}){return e.status===`deleted`?(0,c.jsx)(f,{children:`Image deleted — only the new side can be previewed.`}):t?(0,c.jsxs)(`div`,{"data-slot":`diff-image-preview`,className:`flex flex-col items-center gap-2 p-4`,children:[(0,c.jsx)(l,{src:t(e.path),alt:e.path,className:`max-h-[60vh] max-w-full rounded-sm`}),n?(0,c.jsx)(`button`,{type:`button`,"data-slot":`diff-image-open`,onClick:()=>n(e.path),className:`text-[11px] font-medium text-soft-foreground hover:text-foreground hover:underline`,children:`Open in default app`}):null]}):(0,c.jsx)(f,{children:`Binary file — no text diff.`})}function f({children:e}){return(0,c.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}export{u as n,l as r,d as t};
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{V as i,r as a}from"./button-BNnH7COh.js";var o=e(t(),1),s=e(n(),1),c=r();function l({src:e,alt:t=``,className:n,...r}){let[l,u]=(0,o.useState)(!1),d=i(e);return(0,o.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`img`,{...r,src:d,alt:t,loading:`lazy`,onClick:()=>u(!0),className:a(`cursor-zoom-in`,n)}),l?(0,s.createPortal)((0,c.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Image preview`,"data-slot":`image-lightbox`,onClick:()=>u(!1),className:`fixed inset-0 z-[100] flex cursor-zoom-out items-center justify-center bg-black/80 p-4 backdrop-blur-sm`,children:(0,c.jsx)(`img`,{src:d,alt:t,className:`max-h-full max-w-full rounded-md object-contain shadow-2xl`})}),document.body):null]})}function u(e){return e.image===!0&&(e.binary===!0||e.patch===``)}function d({file:e,imageSrc:t,onOpenInApp:n}){return e.status===`deleted`?(0,c.jsx)(f,{children:`Image deleted — only the new side can be previewed.`}):t?(0,c.jsxs)(`div`,{"data-slot":`diff-image-preview`,className:`flex flex-col items-center gap-2 p-4`,children:[(0,c.jsx)(l,{src:t(e.path),alt:e.path,className:`max-h-[60vh] max-w-full rounded-sm`}),n?(0,c.jsx)(`button`,{type:`button`,"data-slot":`diff-image-open`,onClick:()=>n(e.path),className:`text-[11px] font-medium text-soft-foreground hover:text-foreground hover:underline`,children:`Open in default app`}):null]}):(0,c.jsx)(f,{children:`Binary file — no text diff.`})}function f({children:e}){return(0,c.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}function p(e){return e.closest(`[data-diff-scroller], [data-slot="main"]`)}function m(e,t,n){let r=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop-n;e.scrollTop=Math.max(0,r)}export{l as a,u as i,m as n,d as r,p as t};
@@ -1 +1 @@
1
- import{F as e}from"./button-CjSjKnkd.js";var t=e(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t};
1
+ import{F as e}from"./button-BNnH7COh.js";var t=e(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{L as r,a as i,c as a,d as o,f as s,l as c,o as l,r as u,s as d,u as f,z as p}from"./button-BNnH7COh.js";import{t as m}from"./x-HaVPcg_B.js";var h=e(t(),1),g=[`run-event`,`ui-event`],_=1e3,v=6e4,y=1e4;function b(e,t){if(e.add(t),e.size<=y)return;let n=e.values().next().value;typeof n==`number`&&e.delete(n)}function x(e,t){return typeof e==`string`?`${e}:${t}`:t}function S(e){let t=e.type===`item.delta`?e.itemId:typeof e.item==`object`&&e.item!==null&&!Array.isArray(e.item)?e.item.id:void 0;return typeof t==`string`&&t!==``?x(e.stepId,t):void 0}function C(e){let t=[],n=new Map;for(let r of e){let e=S(r);if(e!==void 0&&r.type!==`item.delta`)for(let t of[`text`,`reasoning`,`output`])n.delete(`${e}:${t}`);if(r.type===`item.delta`&&e!==void 0&&(r.field===`text`||r.field===`reasoning`||r.field===`output`)&&typeof r.delta==`string`){let i=`${e}:${r.field}`,a=n.get(i);if(a!==void 0){let e=t[a],o={...e,seq:r.seq,ts:r.ts,delta:`${e.delta}${r.delta}`};if(a===t.length-1)t[a]=o;else{t.splice(a,1);for(let[e,t]of n)t>a&&n.set(e,t-1);n.set(i,t.length),t.push(o)}continue}n.set(i,t.length)}t.push(r)}return t}function w(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function T(e,t={}){let[n,i]=(0,h.useState)([]),a=p(),o=(0,h.useRef)(t);o.current=t;let s=(0,h.useRef)(0),c=(0,h.useRef)(0),l=(0,h.useRef)(0),u=(0,h.useRef)(!1),d=(0,h.useRef)(new Set),f=(0,h.useRef)(void 0);(0,h.useEffect)(()=>{let{afterSeq:t=0}=o.current;if(s.current=0,c.current=t,l.current=t,u.current=!1,d.current.clear(),i([]),!e)return;let n=globalThis.EventSource;if(typeof n!=`function`)return;let a=null,p=0,m,h=!1,y=0,x=0,S=0,T=[],E,D=Date.now(),O,k=()=>{y=Math.min(y+1,6),x=Date.now()+Math.min(v,_*2**(y-1))},A=e=>{let t=o.current;if(t.onCompact===void 0||(t.compactAt===void 0||S<t.compactAt)&&(t.compactWhenOver===void 0||e.length<=t.compactWhenOver)||Date.now()<x)return;let n=S;Promise.resolve().then(()=>{if(!h)return o.current.onCompact?.(e)}).then(e=>{if(h)return;if(!Array.isArray(e)||e.length===0){k();return}y=0,x=0,S=Math.max(0,S-n);let t=new Set(e);t.size!==0&&i(e=>e.filter(({seq:e})=>!t.has(e)))},()=>{h||k()})},j=()=>{if(E=void 0,T.length===0)return;let e=T;T=[],i(t=>{let n=o.current;return n.compactAt!==void 0||n.onCompact!==void 0?C([...t,...e]):[...t,...e]})},M=()=>{E===void 0&&(E=setTimeout(j,50))},N=()=>{p+=1;let e=a;e&&(e.close(),a=null)},P=(e,t)=>{if(h||t!==p)return;D=Date.now();let n=w(e.data);!n||d.current.has(n.seq)||n.seq<=s.current&&(!u.current||n.seq<=l.current)||(b(d.current,n.seq),s.current=Math.max(s.current,n.seq),S+=1,T.push(n),M())},F=e=>{h||e!==p||(D=Date.now())},I=()=>{h||m!==void 0||(m=setTimeout(()=>{m=void 0,h||L()},1500))},L=()=>{N();let t=p,{cursor:i,afterSeq:l=0}=o.current;D=Date.now(),c.current=Math.max(c.current,l);let u=new URLSearchParams;i!==void 0&&u.set(`cursor`,i);let d=Math.max(c.current,s.current);(i!==void 0||d>0)&&u.set(`afterSeq`,String(d));let f=u.size>0?`?${u.toString()}`:``,m=new n(r(`/runs/${encodeURIComponent(e)}/events${f}`),{withCredentials:!0});a=m;let _=e=>P(e,t);for(let e of g)m.addEventListener(e,_);m.addEventListener(`ping`,()=>F(t)),m.addEventListener(`error`,()=>{h||t!==p||m.readyState===2&&I()})},R=()=>{document.visibilityState===`visible`&&(!a||a.readyState===2)&&(clearTimeout(m),m=void 0,L())},z=()=>{clearTimeout(m),m=void 0,N()},B=e=>{e.persisted&&L()};return O=setInterval(()=>{h||document.visibilityState!==`visible`||Date.now()-D<=4e4||(clearTimeout(m),m=void 0,L())},1e4),document.addEventListener(`visibilitychange`,R),window.addEventListener(`pagehide`,z),window.addEventListener(`pageshow`,B),f.current=A,L(),()=>{h=!0,clearTimeout(m),clearTimeout(E),E=void 0,T=[],clearInterval(O),document.removeEventListener(`visibilitychange`,R),window.removeEventListener(`pagehide`,z),window.removeEventListener(`pageshow`,B),f.current===A&&(f.current=void 0),N()}},[e,a]),(0,h.useEffect)(()=>{n.length!==0&&f.current?.(n)},[n]);let m=t.afterSeq??0;return(0,h.useEffect)(()=>{e&&(m>c.current&&(u.current=!0),c.current=Math.max(c.current,m))},[m,e]),n}var E=n();function D({...e}){return(0,E.jsx)(i,{"data-slot":`sheet`,...e})}function O({...e}){return(0,E.jsx)(s,{"data-slot":`sheet-trigger`,...e})}function k({...e}){return(0,E.jsx)(l,{"data-slot":`sheet-close`,...e})}function A({...e}){return(0,E.jsx)(f,{"data-slot":`sheet-portal`,...e})}function j({className:e,...t}){return(0,E.jsx)(c,{"data-slot":`sheet-overlay`,className:u(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function M({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,E.jsxs)(A,{children:[(0,E.jsx)(j,{}),(0,E.jsxs)(d,{"data-slot":`sheet-content`,className:u(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,r&&`[&_[data-slot=sheet-header]]:pr-16`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,E.jsxs)(l,{className:`absolute top-4 right-4 grid size-11 place-items-center rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,E.jsx)(m,{className:`size-4`}),(0,E.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function N({className:e,...t}){return(0,E.jsx)(`div`,{"data-slot":`sheet-header`,className:u(`flex flex-col gap-1.5 p-4`,e),...t})}function P({className:e,...t}){return(0,E.jsx)(o,{"data-slot":`sheet-title`,className:u(`font-semibold text-foreground`,e),...t})}function F({className:e,...t}){return(0,E.jsx)(a,{"data-slot":`sheet-description`,className:u(`text-sm text-muted-foreground`,e),...t})}export{N as a,S as c,F as i,x as l,k as n,P as o,M as r,O as s,D as t,T as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,$t as i,Bt as a,Gn as o,U as s,Yt as c,Zr as l,aa as u,c as d,ea as f,f as p,h as m,in as h,na as g,ni as _,or as v,s as y,t as b,zt as x}from"./project-router-CWMOKp_H.js";import{r as S,t as C}from"./button-BNnH7COh.js";import{it as w,tt as T,w as E}from"./reference-overflow-ClRRXWez.js";import{t as D}from"./arrow-left-fsST4JqT.js";import{_ as O,f as k,g as A,h as j,m as M,p as N}from"./reference-chip-B7lU_Pyh.js";import{E as P,_ as F,g as I,y as L}from"./composer-DKWLJeo9.js";import{n as R}from"./x-HaVPcg_B.js";import{t as z}from"./triangle-alert-CP3Xp0FU.js";import{t as B}from"./centered-state-sEYB3bgq.js";import{t as V}from"./refresh-cw-BBEYC6z2.js";import{d as H,j as U,k as W,l as ee}from"./index-BN3w52uE.js";var G=e(t(),1),K=n(),q=[`.ai/cezar/skills/`,`.ai/skills/`,`.agents/skills/`];function J({children:e}){return(0,K.jsx)(`span`,{className:`font-mono`,children:e})}function Y(){return(0,K.jsx)(K.Fragment,{children:q.map((e,t)=>(0,K.jsxs)(`span`,{children:[t>0?t===q.length-1?`, or `:`, `:``,(0,K.jsx)(J,{children:e})]},e))})}function te(){return(0,K.jsxs)(K.Fragment,{children:[`No skills yet. Drop Markdown files into `,(0,K.jsx)(Y,{}),` (agent mirrors like`,` `,(0,K.jsx)(J,{children:`.claude/skills/`}),` work too) — optional frontmatter: `,(0,K.jsx)(J,{children:`name`}),`,`,` `,(0,K.jsx)(J,{children:`description`}),`. Global (`,(0,K.jsx)(J,{children:`~/.agents/skills`}),`) and team-repo skills appear here too — try Refresh.`]})}function X(e){return e===`project`?`Project installation`:`Global installation`}function ne({projectId:e,state:t,loadError:n}){let i=u(),a=d(),s=(0,G.useRef)(0),[c,l]=(0,G.useState)(!1),f=g({mutationFn:()=>v({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{T(`skills_import`),l(!1),a(E(e))},onError:e=>p(e.message,{tone:`danger`})}),_=(t,n)=>{n.seq===s.current&&(i.setQueryData(h.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:m.skills}),p(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),l(!0)))},y=(e,t)=>{t.seq===s.current&&p(e.message,{tone:`danger`})},b=g({mutationFn:t=>r(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>_(e,t),onError:(e,t)=>y(e,t)}),x=g({mutationFn:t=>o(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>_(e,t),onError:(e,t)=>y(e,t)}),w=e=>{let n=++s.current;e===`apply`?x.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):b.mutate({action:e,seq:n})},D=t?.scopes??[],P=D.filter(e=>e.skills.length>0),F=P.length>0,I=t?.status===`error`,L=F&&(t?.available||I),z=x.isPending||t?.status===`updating`,B=D.filter(e=>e.status===`error`||e.status===`unavailable`),H=D.filter(e=>e.updatedAt&&!B.includes(e)),U=`Checking installed Open Mercato skills…`;return n?U=`Update status is unavailable right now.`:t?.status===`available`?U=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?U=`Updating installed Open Mercato skills…`:t?.status===`current`&&!F?U=t.needsUpgradeNotes?`Skill files were updated.`:`No installed Open Mercato skills are tracked for updates.`:t?.status===`current`?U=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?U=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(U=`The update did not finish for every installation.`),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`rounded-lg border border-border bg-muted/30 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:U}),t?.checkedAt?(0,K.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,P.length>0?(0,K.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:P.map(e=>(0,K.jsxs)(`li`,{children:[X(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,B.length>0?(0,K.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,B.map(e=>X(e.scope)).join(`, `),H.length?`; updated: `+H.map(e=>X(e.scope)).join(`, `):``,`.`]}):null]}),L?(0,K.jsxs)(C,{"data-action":`skills-update-apply`,size:`sm`,disabled:z,onClick:()=>w(`apply`),children:[(0,K.jsx)(V,{"aria-hidden":`true`,className:S(`size-3.5`,z&&`motion-safe:animate-spin`)}),z?`Updating…`:I?`Retry`:`Update now`]}):t?.status===`current`?(0,K.jsx)(C,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:b.isPending,onClick:()=>w(`check`),children:`Check again`}):t?.status===`unavailable`||n?(0,K.jsx)(C,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:b.isPending,onClick:()=>w(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,K.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,K.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,K.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,K.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-primary/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,K.jsx)(R,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,K.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,K.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,K.jsx)(k,{open:c,onOpenChange:e=>f.isPending?void 0:l(e),children:(0,K.jsxs)(N,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,K.jsxs)(A,{children:[(0,K.jsx)(O,{children:`Apply the upgrade notes now?`}),(0,K.jsxs)(M,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,K.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,K.jsxs)(j,{children:[(0,K.jsx)(C,{type:`button`,variant:`outline`,disabled:f.isPending,onClick:()=>l(!1),children:`No`}),(0,K.jsx)(C,{type:`button`,disabled:f.isPending,onClick:()=>f.mutate(),children:f.isPending?`Starting…`:`Yes, start session`})]})]})})]})}function Z(e,t){let n=e?.importedSkills;return Array.isArray(n)?n.filter(e=>typeof e==`string`&&!!e):[...t]}function Q(e,t,n,r,i=!1){let a=e.source===`ai`||e.source===`cezar`||e.source===`agents`||e.source===`global`,o=e.source===`team`&&(t.has(e.name)||i);if(!(!a&&!o))return{ariaLabel:a?`${e.name} is always enabled`:`${e.enabled?`Disable`:`Enable`} ${e.name}`,checked:a||e.enabled,disabled:a||n||i,onCheckedChange:()=>r(e.name)}}function re(){return(0,K.jsxs)(`div`,{"data-route":`skills`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:`Skills`}),(0,K.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Markdown playbooks agents can follow.`})]}),(0,K.jsx)($,{})]})}function $(){let e=y()??``,t=a(e,!!e),n=x(),r=i(),o=s(),[d]=f(),[h,v]=(0,G.useState)(``),T=u(),E=c(),O=o.data??[],k=(0,G.useMemo)(()=>O.map(e=>e.name),[O]),A=(0,G.useMemo)(()=>new Set(k),[k]),j=(0,G.useMemo)(()=>new Set(Z(E.data,k)),[E.data,k]),M=(0,G.useRef)(Promise.resolve()),N=(0,G.useRef)(0),F=(0,G.useCallback)(t=>{let n=m.uiState,r=m.skills,i=T.getQueryData(n),a=Z(i,k),o=a.includes(t)?a.filter(e=>e!==t):[...a,t];T.setQueryData(n,{...i,importedSkills:o});let s=++N.current;M.current=M.current.then(async()=>{try{let t=await l({importedSkills:o},e);if(s!==N.current)return;T.setQueryData(n,t),T.invalidateQueries({queryKey:r})}catch(e){if(s!==N.current)return;p(e instanceof Error?e.message:String(e),{tone:`danger`}),T.invalidateQueries({queryKey:n})}})},[k,e,T]),R=g({mutationFn:()=>_(),onSuccess:e=>{T.setQueryData(m.skills,e),p(`Team skills refreshed.`)},onError:e=>p(e.message,{tone:`danger`})});if(n.isError)return(0,K.jsx)(B,{icon:(0,K.jsx)(z,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:n.error.message});let H=L(n.data??[]),W=new Set(H.map(e=>e.name)),q=L([...H.map(e=>({...e,enabled:e.source===`team`&&A.has(e.name)?j.has(e.name):!0})),...O.filter(e=>!W.has(e.name)).map(e=>({...e,enabled:j.has(e.name)}))].sort((e,t)=>e.name.localeCompare(t.name))),J=d.get(`skill`),Y=q.find(e=>e.name===J)??(J===null?q.find(e=>e.enabled):null)??null,X=Y?.name??null,re=Y?Q(Y,A,E.isPending,F,o.isError):void 0,$=I(q,h);return(0,K.jsxs)(`div`,{"data-slot":`skills-section`,className:`flex min-h-full flex-1 items-stretch`,children:[(0,K.jsxs)(`section`,{"data-slot":`skills-list`,className:S(`w-full flex-col border-border md:flex md:w-96 md:shrink-0 md:border-r`,`md:sticky md:top-14 md:max-h-[calc(100dvh-(var(--spacing)*14))]`,J===null||!Y?`flex`:`hidden md:flex`),children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 p-3 pb-2`,children:[(0,K.jsx)(U,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:h,onChange:e=>v(e.target.value),className:`h-8 text-[13px]`}),(0,K.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:R.isPending,onClick:()=>R.mutate(),className:`flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,K.jsx)(V,{"aria-hidden":`true`,className:S(`size-3`,R.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),e?(0,K.jsx)(`div`,{className:`shrink-0 px-3 pb-2`,children:(0,K.jsx)(ne,{projectId:e,state:t.data,loadError:t.error})}):null,o.isError?(0,K.jsxs)(`div`,{"data-slot":`skills-importable-error`,role:`alert`,className:`mx-3 mb-2 flex shrink-0 items-center justify-between gap-3 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[(0,K.jsxs)(`p`,{className:`min-w-0`,children:[`Could not load the Open Mercato skills catalog. Team skills may be missing until it loads.`,` `,o.error.message]}),(0,K.jsx)(C,{type:`button`,"data-action":`skills-importable-retry`,variant:`ghost`,size:`sm`,disabled:o.isFetching,onClick:()=>void o.refetch(),children:`Retry`})]}):null,(0,K.jsx)(`ul`,{"data-slot":`skill-rows`,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-2 pb-2`,children:n.isPending?(0,K.jsx)(`li`,{className:`px-2.5 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):$.length>0?$.map(e=>(0,K.jsx)(ie,{skill:e,active:X===e.name,activation:Q(e,A,E.isPending,F,o.isError)},e.name)):(0,K.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:q.length>0?`(no skills match)`:(0,K.jsx)(te,{})})})]}),(0,K.jsx)(`section`,{"data-slot":`skills-detail`,className:S(`min-w-0 flex-1 flex-col`,J===null||!Y?`hidden md:flex`:`flex`),children:(0,K.jsx)(`div`,{className:`min-w-0 flex-1 px-4 py-4 md:px-7 md:py-5`,children:Y?(0,K.jsxs)(K.Fragment,{children:[J===null?null:(0,K.jsxs)(b,{to:`/skills`,"data-slot":`skills-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),(0,K.jsx)(ee,{skill:Y,enabled:Y.enabled,activation:re,usedBy:P(r.data?.workflows??[],Y.name)})]}):n.isPending?null:(0,K.jsx)(B,{icon:(0,K.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})})})]})}function ie({skill:e,active:t,activation:n}){let r=F(e),i=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:S(`min-w-0 truncate font-mono text-[13px]`,e.enabled?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),(0,K.jsx)(H,{source:e.source,teamRepo:e.team?.repo,className:`ml-auto`})]}),e.description?(0,K.jsx)(`span`,{className:`line-clamp-2 text-xs text-soft-foreground`,children:e.description}):null]});return(0,K.jsxs)(`li`,{className:S(`flex min-w-0 items-start gap-0 rounded-md transition-colors hover:bg-muted`,t&&`bg-muted`),children:[n?(0,K.jsx)(W,{"data-slot":`skill-activation`,"aria-label":n.ariaLabel,checked:n.checked,disabled:n.disabled,onCheckedChange:n.onCheckedChange,size:`sm`,className:`mt-2.5 ml-2 shrink-0`}):null,(0,K.jsx)(b,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-project":r?`true`:void 0,"data-enabled":e.enabled?`true`:`false`,"aria-current":t?`page`:void 0,className:`flex min-w-0 flex-1 flex-col gap-0.5 px-2.5 py-2`,children:i})]})}export{re as SkillsRoute};
@@ -0,0 +1 @@
1
+ import{F as e}from"./button-BNnH7COh.js";var t=e(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./project-router-CWMOKp_H.js";import{r as n}from"./button-BNnH7COh.js";var r=e();function i({to:e,active:i=!1,onClick:a,children:o}){return(0,r.jsx)(t,{to:e,"aria-current":i?`page`:void 0,onClick:a,className:n(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-2 text-[13px] font-medium md:px-3`,i?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:o})}export{i as t};
@@ -1 +1 @@
1
- import{F as e}from"./button-CjSjKnkd.js";var t=e(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]);export{t};
1
+ import{F as e}from"./button-BNnH7COh.js";var t=e(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,Er as i,Rr as a,V as ee,Wn as o,aa as s,bt as c,ea as l,f as u,fi as d,mt as f,na as p,xt as te}from"./project-router-CWMOKp_H.js";import{N as ne,et as re}from"./reference-overflow-ClRRXWez.js";import{s as m}from"./reference-chip-B7lU_Pyh.js";import{r as ie,t as ae}from"./run-header-BPNBEaOy.js";import{t as oe}from"./git-commit-horizontal-BM9_nEW7.js";import{t as h}from"./centered-state-sEYB3bgq.js";import{i as g}from"./git-toolbar-DXyPCDkQ.js";import{B as _,H as se,a as v,i as y}from"./index-BN3w52uE.js";import{t as b}from"./markdown-C5F95Rt-.js";import{t as x}from"./diff-CrLUECGW.js";import{r as S,t as C}from"./file-tree-BTJZXRkM.js";import{a as w,i as ce,n as le,t as T,u as ue}from"./task-composer-7bdNNMP_.js";var E=e(t(),1),D=n();function O(){let{id:e}=r(),t=c(e);return t.isPending?(0,D.jsx)(v,{tab:`changes`}):t.isError?(0,D.jsx)(y,{tab:`changes`,error:t.error}):(0,D.jsx)(k,{run:t.data},t.data.id)}function k({run:e}){let t=ee();f();let n=te(e.id,ne(e.status)),r=se(),[i,c]=(0,E.useState)(`unified`),[m,v]=(0,E.useState)(!1),[y,w]=(0,E.useState)(!1),[T,O]=(0,E.useState)(null),k=(0,E.useRef)(null),M=ue(e.id),{add:N}=M,P=(0,E.useCallback)(e=>{let t=N(e);return t&&re(e.start?`multi_line`:`single_line`),t},[N]),F=M.comments.length,I=ie(e.id,`composer`),[L,R]=(0,E.useState)(!1),[z,B]=(0,E.useState)(!1);F>0&&!z&&B(!0),z&&F===0&&!I.hasDraft&&!L&&B(!1);let V=F>0||L||z&&I.hasDraft,[H,U]=(0,E.useState)(0),de=(0,E.useCallback)(e=>{if(!e){U(0);return}if(U(e.offsetHeight),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>U(e.offsetHeight));return t.observe(e),()=>t.disconnect()},[]),fe=(0,E.useMemo)(()=>{let e=new Map;for(let t of M.comments)e.set(t.path,(e.get(t.path)??0)+1);return e},[M.comments]);s();let pe=p({mutationFn:t=>a(e.id,t),onError:e=>u(e.message,{tone:`danger`})}),W=n.isError&&n.error instanceof o&&n.error.status===409,G=n.data?.files??[],K=!n.isPending&&!n.isError&&G.length>0,me=(0,E.useMemo)(()=>C(G),[G]),q=(0,E.useMemo)(()=>G.some(b),[G]),J=r?i:`unified`,Y=!r||m,he=e=>{O(e),k.current?.scrollToPath(e)},X=(0,E.useCallback)(e=>{O(e.path);let t=k.current;t?.reveal?t.reveal(e):t?.scrollToPath(e.path)},[]),[Z]=l(),Q=(0,E.useMemo)(()=>ce(Z),[Z]),$=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(!Q||!K)return;let e=Z.toString();if($.current===e)return;let t=0,n=setInterval(()=>{!k.current&&++t<40||(clearInterval(n),$.current=e,X(Q))},75);return()=>clearInterval(n)},[K,X,Z,Q]),(0,D.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col md:h-full`,children:[(0,D.jsx)(ae,{run:e,tab:`changes`}),(0,D.jsx)(g,{branch:e.branch,stat:n.data?.stat,mode:J,wrap:Y,preview:y,onModeChange:c,onWrapChange:v,onPreviewChange:q?w:void 0}),n.data?.repointedHead?(0,D.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-6`,children:[`HEAD is on `,(0,D.jsx)(`code`,{children:n.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,D.jsx)(`code`,{children:n.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,n.isPending?(0,D.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):n.isError?(0,D.jsx)(h,{icon:W?(0,D.jsx)(_,{}):(0,D.jsx)(oe,{}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:n.error.message}):G.length===0?(0,D.jsx)(h,{icon:(0,D.jsx)(_,{}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 px-4 py-4 max-md:pb-[calc(1rem_+_var(--changes-dock,0px))] md:px-6 md:py-0`,style:{"--changes-dock":`${V?H:0}px`},children:[(0,D.jsx)(`aside`,{"data-slot":`changes-tree-pane`,className:`hidden w-60 shrink-0 overflow-y-auto overscroll-contain pt-4 pb-[calc(1rem_+_var(--changes-dock,0px))] md:block lg:w-72`,children:(0,D.jsx)(S,{root:me,selected:T,onSelect:he,commentCounts:fe})}),(0,D.jsx)(`div`,{"data-slot":`diff-pane`,"data-diff-scroller":r?``:void 0,className:`min-w-0 flex-1 md:overflow-y-auto md:overscroll-contain`,children:(0,D.jsx)(x,{files:G,viewRef:k,mode:J,wrap:Y,preview:r&&q&&y,loadFileText:t=>j(e.id,t),imageSrc:t=>d(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>pe.mutate(e):void 0,comments:M.comments,onAddComment:M.ready?P:void 0,onEditComment:M.update,onRemoveComment:M.remove,className:`min-w-0 md:pt-4 md:pb-[calc(1rem_+_var(--changes-dock,0px))] [&_[data-slot=diff-comment-editor]]:scroll-mb-[var(--changes-dock,0px)] [&_[data-slot=diff-line-comment]]:scroll-mb-[var(--changes-dock,0px)] [&_[data-slot=diff-line]]:scroll-mb-[var(--changes-dock,0px)]`},e.id)})]}),V?(0,D.jsx)(le,{ref:de,floating:!0,className:`mt-auto`,style:{marginTop:K&&H?-H:void 0},children:(0,D.jsx)(A,{run:e,draft:I,diffComments:M,onSendingChange:R,onOpenComment:e=>X({path:e.path,side:e.side,line:e.line,commentId:e.id}),getMentionCandidates:()=>G.map(e=>e.path)})}):null]})}function A(e){let t=w(e.run);return m(),(0,D.jsx)(T,{...e,continueAction:t})}async function j(e,t){try{let n=await i(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{O as TaskChangesRoute};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,Ct as i,St as a,Wn as o,bt as s,t as c}from"./project-router-CWMOKp_H.js";import{r as l,t as u}from"./button-BNnH7COh.js";import{N as d}from"./reference-overflow-ClRRXWez.js";import{t as f}from"./arrow-left-fsST4JqT.js";import{t as p}from"./run-header-BPNBEaOy.js";import{t as m}from"./git-commit-horizontal-BM9_nEW7.js";import{t as h}from"./triangle-alert-CP3Xp0FU.js";import{t as g}from"./centered-state-sEYB3bgq.js";import{t as _}from"./search-x-6BavY3mg.js";import{o as v}from"./git-toolbar-DXyPCDkQ.js";import{t as y}from"./diff-stat-SpfygteL.js";import{H as b,a as x,i as S}from"./index-BN3w52uE.js";import{t as C}from"./diff-CrLUECGW.js";import{t as w}from"./commit-list-Bps23fvP.js";var T=e(t(),1),E=n();function D(){let{id:e}=r(),t=s(e);return t.isPending?(0,E.jsx)(x,{tab:`changes`}):t.isError?(0,E.jsx)(S,{tab:`changes`,error:t.error}):(0,E.jsx)(O,{run:t.data})}function O({run:e}){let{sha:t}=r(),n=i(e.id,d(e.status));return(0,E.jsxs)(`div`,{"data-route":`task-commits`,className:l(`flex min-h-full flex-col`,t&&`md:h-full`),children:[(0,E.jsx)(p,{run:e,tab:`commits`}),t?(0,E.jsx)(k,{runId:e.id,sha:t},t):n.isPending?(0,E.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):n.isError?(0,E.jsx)(g,{icon:(0,E.jsx)(m,{}),tone:n.error instanceof o&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof o&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,E.jsx)(g,{icon:(0,E.jsx)(m,{}),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,E.jsx)(w,{slot:`task-commits`,className:`mx-auto w-full max-w-[var(--measure)]`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))})]})}function k({runId:e,sha:t}){let n=a(e,t),r=b(),[i,s]=(0,T.useState)(`unified`),[l,d]=(0,T.useState)(!1),p=n.isError&&n.error instanceof o&&n.error.status===409,x=r?i:`unified`,S=!r||l;return(0,E.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,E.jsx)(u,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,E.jsxs)(c,{to:`/tasks/${e}/commits`,children:[(0,E.jsx)(f,{"aria-hidden":`true`}),`All commits`]})}),n.data?(0,E.jsx)(y,{stat:n.data.stat}):null,(0,E.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,E.jsx)(v,{mode:i,wrap:l,onModeChange:s,onWrapChange:d})})]}),n.isPending?(0,E.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):n.isError?(0,E.jsx)(g,{icon:p?(0,E.jsx)(_,{}):(0,E.jsx)(h,{}),tone:p?`neutral`:`danger`,heading:`h2`,title:p?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,E.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,E.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,E.jsx)(g,{icon:(0,E.jsx)(m,{}),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,E.jsx)(`div`,{"data-slot":`diff-pane`,"data-diff-scroller":r?``:void 0,className:`px-4 md:min-h-0 md:flex-1 md:overflow-y-auto md:overscroll-contain md:px-6`,children:(0,E.jsx)(C,{files:n.data.files,mode:x,wrap:S,className:`min-w-0 py-4`})})]})]})}export{D as TaskCommitsRoute};
@@ -0,0 +1,12 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,At as i,Hi as a,Lt as o,T as s,Tr as c,Tt as l,Wn as u,Yr as d,_ as f,aa as p,f as m,h,na as g,nt as _,rr as v,t as y,zt as b}from"./project-router-CWMOKp_H.js";import{r as x}from"./button-BNnH7COh.js";import{H as S,P as C,R as w,b as T,c as E,g as ee,l as te,tt as D,v as ne,x as O}from"./reference-overflow-ClRRXWez.js";import{d as re,t as k,u as ie}from"./composer-DKWLJeo9.js";import{i as A,n as j,r as M,t as N}from"./tooltip-BVqBAGNb.js";import{t as P}from"./x-HaVPcg_B.js";import{a as F,i as I}from"./run-header-BPNBEaOy.js";import{t as L}from"./file-DkvcUwxT.js";import{n as ae,t as R}from"./types-BTlmexWF.js";import"./diff-CrLUECGW.js";var z=n(),B=e(t(),1),V=`diff-comments`;function H(e){if(e===``)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.id!=`string`||typeof t.path!=`string`||t.side!==`old`&&t.side!==`new`||typeof t.line!=`number`||typeof t.body!=`string`||n.push({id:t.id,path:t.path,side:t.side,line:t.line,body:t.body,excerpt:typeof t.excerpt==`string`?t.excerpt:``,...typeof t.oldPath==`string`&&t.oldPath!==``?{oldPath:t.oldPath}:{},...oe(t.start)?{start:{side:t.start.side,line:t.start.line}}:{}})}return n}function oe(e){if(typeof e!=`object`||!e)return!1;let t=e;return(t.side===`old`||t.side===`new`)&&typeof t.line==`number`}function U(e){return ae(e,e.start)}function W(e){let t=e=>e.side===`old`?0:1,n=e=>e.start??e;return[...e].sort((e,r)=>e.path.localeCompare(r.path)||t(n(e))-t(n(r))||n(e).line-n(r).line)}var G=`Review comments on the diff:`;function se(e){return e.length===0?``:`${G}\n\n${W(e).map(e=>{let t=e.side===`old`?`\`${e.oldPath??e.path}\` line ${e.line} (removed line${e.oldPath?`, renamed to \`${e.path}\``:``})`:`\`${e.path}\` line ${e.line}`;return`- ${e.start?fe(e):t}:\n\n${J(pe(e.excerpt))}\n\n${J(e.body)}`}).join(`
2
+
3
+ `)}`}var K=/^- `([^`]+)` (.+):$/;function ce(e){let t=e.indexOf(`${G}\n\n`);if(t===-1||t>0&&e[t-1]!==`
4
+ `)return;let n=e.slice(0,t).trim(),r=e.slice(t+28+2).split(`
5
+ `),i=[],a=0;for(;a<r.length;){let e=K.exec(r[a]??``);if(!e){if((r[a]??``).trim()===``){a++;continue}return}a++;let t=[];for(;a<r.length&&!K.test(r[a]??``);)t.push((r[a]??``).replace(/^ {2}/,``)),a++;i.push(le(e[1],e[2],t))}return i.length>0?{lead:n,items:i}:void 0}function le(e,t,n){let r=/renamed to `([^`]+)`/.exec(t)?.[1],i=/lines? (\d+)/.exec(t),a=t.startsWith(`removed `)||t.includes(`(removed line`)?`old`:`new`,o=n;for(;o[0]?.trim()===``;)o=o.slice(1);let s=``,c=/^(`{3,})\s*$/.exec(o[0]??``);if(c){let e=o.findIndex((e,t)=>t>0&&e.trim()===c[1]);s=o.slice(1,e===-1?void 0:e).join(`
6
+ `),o=e===-1?[]:o.slice(e+1)}else{let e=[];for(;o[0]?.startsWith(`> `);)e.push(o[0].slice(2)),o=o.slice(1);s=e.join(`
7
+ `)}return{path:r??e,label:t,...i?{line:Number(i[1])}:{},side:a,excerpt:s,body:o.join(`
8
+ `).trim()}}function ue(e,t){let n=se(t);return n===``?e:e.trim()===``?n:`${e}\n\n${n}`}function q(e){return/^\/([A-Za-z0-9][A-Za-z0-9._-]*)(?=\s|$)/.exec(e.trimStart())?.[1]}function de(e,t){let n=q(e);return n===void 0||(t?.includes(n)??!1)}function fe(e){let t=e.side===`old`||e.start?.side===`old`,n=e.oldPath&&t?` (removed lines numbered in \`${e.oldPath}\`)`:``;return`\`${e.path}\` ${U(e)}${n}`}function pe(e){let t=Math.max(0,...(e.match(/`+/g)??[]).map(e=>e.length)),n="`".repeat(Math.max(3,t+1));return`${n}\n${Y(e).split(`
9
+ `).map(e=>e.trimEnd()).join(`
10
+ `)}\n${n}`}function J(e){return e.split(`
11
+ `).map(e=>` ${e}`).join(`
12
+ `)}var me=1e3;function he(e,t=200){let n=Y(e);return n.length<=t?n:`${n.slice(0,t)}…`}function Y(e){return e.replace(/^(?:[ \t]*\r?\n)+/,``).replace(/\s+$/,``)}var ge=1e5;function X(e,t){let n=ue(e,t);if(n.length>1e5)throw Error(`Too long with the ${t.length===1?`diff comment`:`${t.length} diff comments`} attached — shorten the message or remove some comments.`);return n}function _e(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}var Z=new WeakMap;function ve(e){let t=Z.get(e);return t||(t={lists:new Map,listeners:new Map,chains:new Map,removed:new Map,base:new Map,pending:new Map},Z.set(e,t)),t}var ye=[];function be(e){let t=p(),n=ve(t),r=l(e===``?void 0:e),i=r.data?.surfaces?.[V]?.text,a=(0,B.useMemo)(()=>H(typeof i==`string`?i:``),[i]),o=(0,B.useSyncExternalStore)((0,B.useCallback)(t=>{let r=n.listeners.get(e)??new Set;return r.add(t),n.listeners.set(e,r),()=>r.delete(t)},[e,n]),()=>n.lists.get(e));(0,B.useEffect)(()=>{if(!r.isSuccess)return;let t=n.lists.get(e);if(t===void 0){n.lists.set(e,a),n.base.set(e,a),n.listeners.get(e)?.forEach(e=>e());return}if((n.pending.get(e)??0)>0)return;let i=$(t,a,n.base.get(e)??[],n.removed.get(e));n.base.set(e,a),i!==t&&(n.lists.set(e,i),n.listeners.get(e)?.forEach(e=>e()))},[r.isSuccess,e,a,n]),(0,B.useEffect)(()=>{if(e===``)return;let n=()=>{document.visibilityState===`visible`&&t.invalidateQueries({queryKey:h.runs.drafts(e)})};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,n)}},[t,e]);let s=o??(r.isSuccess?a:ye),u=(0,B.useCallback)(()=>n.lists.get(e)??a,[e,a,n]),f=(0,B.useCallback)(r=>{n.lists.set(e,r),n.listeners.get(e)?.forEach(e=>e());let i=Q(r);t.setQueryData(h.runs.drafts(e),e=>{let t={...e?.surfaces??{}};return i===``?delete t[V]:t[V]={text:i,images:[],updatedAt:new Date().toISOString()},{surfaces:t}})},[t,e,n]),g=(0,B.useCallback)((t,r=[])=>{if(Q(t).length>1e5)return m(`Too many comments to keep as a draft — send the ones you have first.`,{tone:`danger`}),!1;if(r.length>0){let t=n.removed.get(e)??new Set;for(let e of r)t.add(e);n.removed.set(e,t)}f(t),n.pending.set(e,(n.pending.get(e)??0)+1);let i=(n.chains.get(e)??Promise.resolve()).catch(()=>{}).then(async()=>{let r=n.lists.get(e)??t,i=r;try{let t=(await c(e)).surfaces?.[V]?.text;i=$(r,H(typeof t==`string`?t:``),n.base.get(e)??[],n.removed.get(e))}catch{}i!==r&&f(i);let a=Q(i);a.length>1e5||(await d(e,V,{text:a,images:[]}),n.base.set(e,i))}).catch(()=>{}).finally(()=>{n.pending.set(e,Math.max(0,(n.pending.get(e)??1)-1))});return n.chains.set(e,i),!0},[f,e,n]),_=(0,B.useCallback)(e=>g([...u(),{...e,body:e.body.slice(0,R),excerpt:he(e.excerpt,e.start?me:200),id:_e()}]),[u,g]),v=(0,B.useCallback)((e,t)=>g(u().map(n=>n.id===e?{...n,body:t.slice(0,R)}:n)),[u,g]),y=(0,B.useCallback)(e=>void g(u().filter(t=>t.id!==e),[e]),[u,g]),b=(0,B.useCallback)(()=>void g([],u().map(e=>e.id)),[u,g]),x=(0,B.useCallback)(async e=>{let t=u(),n=await e(t);if(t.length>0){let e=new Map(t.map(e=>[e.id,e.body])),n=u();g(n.filter(t=>e.get(t.id)!==t.body),n.filter(t=>e.get(t.id)===t.body).map(e=>e.id))}return n},[u,g]);return{ready:o!==void 0||r.isSuccess,comments:s,add:_,update:v,remove:y,clear:b,submit:x}}function Q(e){return e.length===0?``:JSON.stringify(e)}function $(e,t,n,r){let i=new Map(n.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e])),o=[];for(let t of e){let e=i.get(t.id),n=a.get(t.id);if(e&&!n)continue;let r=!e||e.body!==t.body;o.push(n&&!r?n:t)}let s=new Set(e.map(e=>e.id));for(let e of t)!s.has(e.id)&&!r?.has(e.id)&&o.push(e);return o.length===e.length&&o.every((t,n)=>t===e[n]||JSON.stringify(t)===JSON.stringify(e[n]))?e:o}function xe(e,t=null){let n=_(),r=a(n.data),i=e.runner??`claude`,o=O(t,r,i),s=r.includes(i),c=n.isSuccess&&r.length>0,l=n.isPending?`Checking agent providers…`:n.isError?`Provider authentication could not be verified.`:c?void 0:`Connect an agent provider to continue.`;return{runners:r,currentRunner:i,runner:o,currentRunnerConnected:s,canContinue:c,providerPending:n.isPending,providerError:n.isError,reason:l,runnerOverride:t!==null||!s?o:void 0}}function Se(e){let t=p(),n=w(e).continueRun,r=s(),[a,o]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),f=xe(e,a),{runners:m,canContinue:_,currentRunner:y,runner:b}=f,x=i(b,n),S=r.data?.modelsLocked===!0,C=b!==y,D=!S&&!C&&e.model?{...r.data?.defaultModels,[b]:e.model}:r.data?.defaultModels,O=S?null:c,k=ne(b,x.data,[O,D?.[b]]),A=T(O,b,D,x.data),{accounts:j,repoAccount:M}=re(),N=[...e.steps].reverse().find(e=>e.profileId)?.profileId??e.agentProfile??`default`,P=C?M:{...M,[y]:N},F=j.some(e=>e.provider===b&&e.id===u)?u:null,I=g({mutationFn:({text:t,images:n})=>_?v(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:f.runnerOverride,model:!S&&c!==null?A:void 0,agentProfile:F??void 0}):Promise.reject(Error(f.reason??`Connect an agent provider to continue.`)),onSuccess:()=>t.invalidateQueries({queryKey:h.runs.all})});return{available:n,canContinue:_,reason:f.reason,providerPending:f.providerPending,pills:(0,z.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`flex flex-wrap items-center gap-1.5`,children:[m.length>1||m.some(e=>ie(j,e))?(0,z.jsx)(te,{runners:m,value:b,accounts:j,account:F,repoAccount:P,onPick:(e,t)=>{d(t),e!==b&&(o(e),l(null))}}):null,(0,z.jsx)(E,{slot:`follow-up-model-pill`,ariaLabel:`Model`,label:k.find(e=>e.id===A)?.label??`auto`,value:A,readOnly:S,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:k.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:ee(b,x.data,x.isError)})]}),continueWith:(e,t)=>I.mutateAsync({text:e,images:t})}}function Ce({items:e}){let{id:t}=r();return(0,z.jsxs)(`div`,{"data-slot":`review-comments`,className:`mt-1 flex flex-col gap-2 text-left`,children:[(0,z.jsxs)(`p`,{className:`text-[12px] font-medium text-muted-foreground`,children:[e.length,` `,e.length===1?`comment`:`comments`,` on the diff`]}),e.map((e,n)=>(0,z.jsxs)(`div`,{"data-slot":`review-comment`,className:`overflow-hidden rounded-lg border border-border bg-background/60`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5 text-[12px]`,children:[(0,z.jsx)(L,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),t?(0,z.jsx)(y,{to:we(t,e),className:`min-w-0 truncate font-mono font-medium text-foreground underline-offset-2 hover:underline`,title:`Open ${e.path} on the Changes tab`,children:e.path}):(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:e.path}),(0,z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`· `,e.label]})]}),e.excerpt===``?null:(0,z.jsx)(`pre`,{"data-slot":`review-comment-code`,className:`max-h-48 overflow-auto border-b border-border/60 bg-muted/40 px-2.5 py-1.5 font-mono text-[12px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.excerpt}),(0,z.jsx)(`p`,{"data-slot":`review-comment-body`,className:`px-2.5 py-2 break-words whitespace-pre-wrap text-foreground`,children:e.body})]},n))]})}function we(e,t){let n=new URLSearchParams({file:t.path,side:t.side});return t.line!==void 0&&n.set(`line`,String(t.line)),t.commentId!==void 0&&n.set(`comment`,t.commentId),`/tasks/${e}/changes?${n.toString()}`}function Te(e){let t=e.get(`file`);if(!t)return;let n=Number(e.get(`line`)),r=e.get(`comment`);return{path:t,side:e.get(`side`)===`old`?`old`:`new`,...Number.isInteger(n)&&n>0?{line:n}:{},...r?{commentId:r}:{}}}function Ee(e){return e===`running`||e===`waiting`||e===`queued`?`live`:`continue`}function De(e,t){let n=p(),{mutateAsync:r}=o(e.id),{continueWith:i}=t;return(0,B.useCallback)(async(t,a)=>{let o=async e=>{let n=await(e===`live`?r({text:t,images:a}):i(t,a));return D(`existing_session`),n},s=Ee(e.status);try{return await o(s)}catch(r){if(!(r instanceof u)||r.status!==409)throw r;let i;try{i=await n.fetchQuery({...f(e.id),staleTime:0})}catch{throw r}let c=Ee(i.status);if(c===s||c===`live`&&t.trim()===``&&a.length===0||c===`continue`&&C(i)===void 0)throw r;return await o(c)}},[i,n,e.id,e.status,r])}function Oe({runId:e,comments:t,onRemove:n,onOpen:r}){return t.length===0?null:(0,z.jsx)(M,{delayDuration:300,children:W(t).map(t=>{let i=t.path.split(`/`).at(-1)??t.path,a=e=>e===`old`?`−`:`+`,o=`${i} ${t.start&&(t.start.side!==t.side||t.start.line!==t.line)?t.start.side===t.side?`${a(t.side)}${t.start.line}–${t.line}`:`${a(t.start.side)}${t.start.line}–${a(t.side)}${t.line}`:`${a(t.side)}${t.line}`}`,s=U(t);return(0,z.jsxs)(N,{children:[(0,z.jsx)(A,{asChild:!0,children:(0,z.jsxs)(`span`,{"data-slot":`diff-comment-chip`,className:`flex h-8 max-w-[260px] items-center overflow-hidden rounded-md border border-border bg-muted/40 text-xs text-foreground`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-full items-center border-r border-border px-2 text-muted-foreground`,children:(0,z.jsx)(L,{className:`size-3.5`})}),r?(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(t),className:`min-w-0 truncate px-2 font-medium hover:underline`,"aria-label":`Show comment on ${t.path} ${s}`,children:o}):(0,z.jsx)(y,{to:we(e,{path:t.path,side:t.side,line:t.line,commentId:t.id}),className:`min-w-0 truncate px-2 font-medium hover:underline`,"aria-label":`Comment on ${t.path} ${s}`,children:o}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`Remove comment on ${i} ${s}`,onClick:()=>n(t.id),className:`flex h-full items-center px-1.5 text-soft-foreground hover:bg-muted hover:text-foreground`,children:(0,z.jsx)(P,{"aria-hidden":`true`,className:`size-3.5`})})]})}),(0,z.jsx)(j,{side:`top`,sideOffset:6,className:`max-w-[320px] text-left`,children:(0,z.jsxs)(`div`,{"data-slot":`diff-comment-tooltip`,className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-[11px] text-contrast-foreground/80`,children:[t.path,` · `,s]}),(0,z.jsx)(`span`,{className:`line-clamp-6 break-words whitespace-pre-wrap`,children:t.body})]})})]},t.id)})})}function ke({run:e,draft:t,diffComments:n,continueAction:r,getMentionCandidates:i,onSendingChange:a,onOpenComment:o}){let s=e.status===`running`||e.status===`waiting`,c=e.status===`queued`,l=!s&&!c&&r.available,u=l&&r.canContinue,d=De(e,r),f=n.comments.length>0,p=b(f),h=(0,B.useMemo)(()=>Array.isArray(p.data)?p.data.map(e=>e.name):void 0,[p.data]),g=S(e),_=s&&!g.usable,v=l&&!r.canContinue,x=_||v,C=_?g.reason:r.reason,w=u?r.pills:(0,z.jsxs)(z.Fragment,{children:[x&&!r.providerPending?(0,z.jsx)(y,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,z.jsx)(I,{run:e})]}),T=F(e),E=e.status===`running`||e.status===`queued`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(k,{value:t.text,onValueChange:t.setText,images:t.images,onImagesChange:t.setImages,onSubmit:async(e,r,i)=>{if(i?.quickReply)return d(e,r);a?.(!0);try{return await t.submit(()=>f&&!de(e,h)?(m(`Diff comments kept — /${q(e)} is a command, so they go with your next message.`),d(e,r)):n.submit(async t=>d(X(e,t),r)))}finally{a?.(!1)}},draftItems:f?(0,z.jsx)(Oe,{runId:e.id,comments:n.comments,onRemove:n.remove,onOpen:o}):void 0,disabled:x||!s&&!c&&!u,disabledReason:x?C:`Session closed — no session to resume.`,footerEnd:w,allowEmptySubmit:u||f,sendAriaLabel:u?`Continue`:`Send`,stop:E?{label:`Stop the run`,onStop:T.request,pending:T.pending}:void 0,placeholder:c?`Add to the prompt — sent when the run starts…`:u?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`,autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:i}),T.dialog]})}function Ae({children:e,overlay:t,floating:n=!1,className:r,style:i,ref:a}){return(0,z.jsxs)(`div`,{ref:a,"data-slot":`thread-dock`,"data-floating":n||void 0,style:i,className:x(`sticky bottom-[var(--kb,0px)] z-10 bg-background px-3 pt-1 pb-2 max-md:border-t max-md:border-border md:px-6 md:pt-1.5 md:pb-4`,n&&`pointer-events-none bg-transparent max-md:border-t-0 [&_[data-slot=composer]]:shadow-lg`,r),children:[t,(0,z.jsx)(`div`,{className:x(`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 md:gap-2.5`,n&&`pointer-events-auto`),children:e})]})}export{Se as a,X as c,Te as i,ce as l,Ae as n,xe as o,Ce as r,ge as s,ke as t,be as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,Et as i,Wn as a,bt as o}from"./project-router-CWMOKp_H.js";import{r as s}from"./button-BNnH7COh.js";import{t as c}from"./chevron-right-Beu1pd6H.js";import{t as l}from"./run-header-BPNBEaOy.js";import{h as u}from"./dropdown-menu-CxPGHgWX.js";import{a as d,i as f,n as p,r as m,t as h}from"./file-preview-DxFusXAO.js";import{t as g}from"./file-DkvcUwxT.js";import{t as _}from"./triangle-alert-CP3Xp0FU.js";import{t as v}from"./centered-state-sEYB3bgq.js";import{H as y,a as b,i as x}from"./index-BN3w52uE.js";var S=e(t(),1),C=n();function w({runId:e,selected:t,onSelect:n}){return(0,C.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,C.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,C.jsx)(T,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function T({runId:e,path:t,depth:n,selected:r,onSelect:a}){let o=i(e,t);return o.isPending?(0,C.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Loading…`}):o.isError?(0,C.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${24+n*14}px`},children:o.error.message}):o.data.type===`dir`?o.data.entries.length===0?(0,C.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Empty directory`}):(0,C.jsx)(C.Fragment,{children:o.data.entries.map(i=>i.type===`dir`?(0,C.jsx)(E,{runId:e,name:i.name,path:t===``?i.name:`${t}/${i.name}`,depth:n,selected:r,onSelect:a},i.name):(0,C.jsx)(D,{name:i.name,path:t===``?i.name:`${t}/${i.name}`,size:i.size,depth:n,selected:r,onSelect:a},i.name))}):null}function E({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[o,l]=(0,S.useState)(!1);return(0,C.jsxs)(`li`,{children:[(0,C.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":o?`open`:`closed`,"aria-expanded":o,onClick:()=>l(e=>!e),className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,C.jsx)(c,{"aria-hidden":`true`,className:s(`size-3.5 shrink-0 transition-transform`,o&&`rotate-90`)}),(0,C.jsx)(u,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,C.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]}),o?(0,C.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,C.jsx)(T,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function D({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,c=m(t)?f:g;return(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:s(`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,o?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+r*14}px`},children:[(0,C.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,C.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,C.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:p(n)})]})})}function O(){let{id:e}=r(),t=o(e);return t.isPending?(0,C.jsx)(b,{tab:`files`}):t.isError?(0,C.jsx)(x,{tab:`files`,error:t.error}):(0,C.jsx)(k,{run:t.data},t.data.id)}function k({run:e}){let t=i(e.id,``),[n,r]=(0,S.useState)(null),o=y(),s=t.isError&&t.error instanceof a&&t.error.status===409;return(0,C.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col md:h-full`,children:[(0,C.jsx)(l,{run:e,tab:`files`}),t.isPending?(0,C.jsx)(`p`,{"data-slot":`files-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading files…`}):t.isError?(0,C.jsx)(v,{icon:s?(0,C.jsx)(d,{}):(0,C.jsx)(_,{}),tone:s?`neutral`:`danger`,heading:`h2`,title:s?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5 px-4 py-4 md:flex-row md:px-6 md:py-0`,children:[(0,C.jsx)(`aside`,{"data-slot":`files-tree-pane`,className:`w-full shrink-0 md:w-60 md:overflow-y-auto md:overscroll-contain md:py-4 lg:w-72`,children:(0,C.jsx)(w,{runId:e.id,selected:n,onSelect:r})}),(0,C.jsx)(`div`,{"data-slot":`file-preview-pane`,...o?{role:`region`,"aria-label":`File preview`,tabIndex:0}:{},className:`min-w-0 flex-1 md:overflow-y-auto md:overscroll-contain`,children:(0,C.jsx)(`div`,{className:`md:py-4`,children:(0,C.jsx)(h,{source:{kind:`run`,runId:e.id},path:n,className:`min-w-0`})})})]})]})}export{O as TaskFilesRoute};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,bt as i,t as a}from"./project-router-CWMOKp_H.js";import{r as o}from"./textarea-rKUFh5lI.js";import{t as s}from"./run-header-BPNBEaOy.js";import{t as c}from"./centered-state-sEYB3bgq.js";import{N as l,a as u,i as d}from"./index-BN3w52uE.js";import{FloatingPanel as f,a as p,c as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,n as S,o as C,p as w,r as T,s as E,t as D,u as O}from"./workflow-graph-HopaWPea.js";var k=e(t(),1),A=n();function j({data:e}){let{node:t,state:n,childRunId:r}=e;return r?(0,A.jsx)(M,{node:t,state:n,childRunId:r}):(0,A.jsx)(D,{node:t,connectable:!1,status:n.status,loopCount:n.loopCount,iterations:n.iterations,costUsd:n.costUsd})}function M({node:e,state:t,childRunId:n}){let r=i(n).data,a=r&&r.steps.length>1?r.steps.map(e=>({id:e.id,name:e.name??e.id,status:e.status})):void 0;return(0,A.jsx)(D,{node:e,connectable:!1,status:t.status,costUsd:r?.costUsd??t.costUsd,inner:a,subtaskTo:`/tasks/${n}/graph`})}var N={live:j};function P(){let{id:e}=r(),t=i(e);return t.isPending?(0,A.jsx)(u,{tab:`changes`}):t.isError?(0,A.jsx)(d,{tab:`changes`,error:t.error}):(0,A.jsx)(x,{children:(0,A.jsx)(F,{run:t.data})})}function F({run:e}){let t=e.workflowDef,n=(0,k.useMemo)(()=>t?p(t):null,[t]),r=(0,k.useMemo)(()=>n?b(n,e):null,[n,e]),[i,a]=(0,k.useState)(null),o=n?.nodes.find(e=>e.id===i),u=(0,k.useMemo)(()=>n&&r?n.nodes.map(t=>({id:t.id,type:`live`,position:n.layout?.[t.id]??{x:0,y:0},draggable:!1,connectable:!1,data:{node:t,state:r.nodes.get(t.id)??{status:`pending`},...I(e,t.id)}})):[],[n,r]),d=(0,k.useMemo)(()=>n?C(n):new Set,[n]),x=(0,k.useMemo)(()=>n?S(n,d):new Map,[n,d]),D=(0,k.useMemo)(()=>!n||!r?[]:n.nodes.flatMap(e=>m(e).flatMap(t=>{let i=O(n,e.id,t);if(!i)return[];let a=`${e.id}.${t}->${i}`,o=r.edges.get(a)??0,s=d.has(`${e.id}.${t}->${i}`),c=(n.layout?.[i]?.x??0)<=(n.layout?.[e.id]?.x??0),l=T({tone:E(e,t),back:s,emphasis:o?`taken`:`dim`});return[{id:a,source:e.id,sourceHandle:t,target:i,type:s||c||x.has(a)?`lane`:`default`,...x.has(a)?{data:{lane:x.get(a)}}:{},label:o>1?`×${o}`:void 0,style:l,markerEnd:{type:_.ArrowClosed,color:l.stroke,width:14,height:14},labelStyle:{fill:`var(--muted-foreground)`,fontSize:10,fontWeight:600},labelBgStyle:{fill:`var(--background)`}}]})),[n,r,d,x]);return(0,A.jsxs)(`div`,{"data-route":`task-graph`,className:`flex h-full min-h-0 flex-col`,children:[(0,A.jsx)(s,{run:e,tab:`graph`}),n?(0,A.jsxs)(`div`,{className:`relative min-h-[420px] flex-1`,children:[(0,A.jsxs)(v,{nodes:u,edges:D,nodeTypes:N,edgeTypes:y,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,onNodeClick:(e,t)=>a(t.id),onPaneClick:()=>a(null),fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},minZoom:.2,colorMode:`system`,proOptions:{hideAttribution:!0},children:[(0,A.jsx)(h,{variant:g.Dots,gap:18,size:1}),(0,A.jsx)(w,{showInteractive:!1})]}),o&&r?(0,A.jsx)(f,{side:`right`,label:`Node details`,title:o.name??o.id,onClose:()=>a(null),children:(0,A.jsx)(L,{state:r.nodes.get(o.id)??{status:`pending`},outputs:e.graphState?.outputs?.[o.id],childRunId:I(e,o.id).childRunId,loopMax:o.type===`loop`?o.max:void 0})}):null]}):(0,A.jsx)(c,{icon:(0,A.jsx)(l,{}),tone:`neutral`,title:`No workflow graph`,subtitle:`This task has no stored workflow definition to draw.`})]})}function I(e,t){let n=e.graphState?.outputs?.[t]?.runId;return typeof n==`string`&&n?{childRunId:n}:{}}function L({state:e,outputs:t,loopMax:n,childRunId:r}){let i=[[`status`,e.status===`reached`?`passed through`:e.status]];e.iterations&&i.push([`runs`,String(e.iterations)]),e.costUsd&&i.push([`cost`,`$${e.costUsd.toFixed(2)}`]),e.loopCount!==void 0&&i.push([`iterations`,`${e.loopCount}${n?` / ${n}`:``}`]);let s=Object.entries(t??{}).filter(([,e])=>e!==``);return(0,A.jsxs)(`div`,{className:`space-y-4 p-4 text-[12px]`,children:[(0,A.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:i.map(([e,t])=>(0,A.jsxs)(`div`,{className:`contents`,children:[(0,A.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,A.jsx)(`dd`,{children:t})]},e))}),r?(0,A.jsxs)(a,{to:`/tasks/${r}`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[`Open the subtask `,(0,A.jsx)(o,{className:`size-3`})]}):null,(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`mb-1 text-[11px] text-muted-foreground uppercase`,children:`Outputs`}),s.length===0?(0,A.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Nothing yet — outputs appear once the node has run.`}):s.map(([e,t])=>(0,A.jsxs)(`div`,{className:`mb-2`,children:[(0,A.jsx)(`code`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,A.jsx)(`pre`,{className:`mt-0.5 max-h-48 overflow-auto rounded-md bg-muted/40 p-2 text-[11px] whitespace-pre-wrap`,children:String(t)})]},e))]})]})}export{P as TaskGraphRoute};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{$i as t,Ot as n,bt as r}from"./project-router-CWMOKp_H.js";import{t as i}from"./run-header-BPNBEaOy.js";import{t as a}from"./markdown-BpZ4p95p.js";import{a as o,i as s}from"./index-BN3w52uE.js";var c=e();function l(){let{id:e}=t(),n=r(e);return n.isPending?(0,c.jsx)(o,{tab:`notes`}):n.isError?(0,c.jsx)(s,{tab:`notes`,error:n.error}):(0,c.jsxs)(`div`,{"data-route":`task-notes`,className:`flex min-h-full flex-col`,children:[(0,c.jsx)(i,{run:n.data,tab:`notes`}),(0,c.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--measure)] px-3 py-3 md:px-6 md:py-5`,children:(0,c.jsx)(u,{runId:n.data.id})})]})}function u({runId:e}){let t=n(e);return(0,c.jsx)(`div`,{"data-slot":`notes-panel`,children:t.isPending?(0,c.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):t.isError?(0,c.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}):t.data.trim().length>0?(0,c.jsx)(a,{children:t.data}):(0,c.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`})})}export{l as TaskNotesRoute};
@@ -0,0 +1,10 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,A as i,Dr as a,Fn as o,G as s,Ln as c,Or as l,Wi as u,Wn as d,Y as f,Yn as p,Z as m,Zi as h,aa as g,bn as _,bt as v,f as y,h as b,j as x,jt as S,na as C,pt as w,ra as T,rr as E,sr as D,t as O,ta as k,yn as A}from"./project-router-CWMOKp_H.js";import{B as j,F as M,i as N,r as P,t as F,wt as I}from"./button-BNnH7COh.js";import{a as L,c as R,i as z,l as B,o as ee,r as te,t as ne,u as re}from"./sheet-D9PeyyRZ.js";import{F as ie,Y as ae,it as oe,j as V,k as se,ot as ce,rt as le,tt as ue}from"./reference-overflow-ClRRXWez.js";import{s as de,v as fe,y as pe}from"./reference-chip-B7lU_Pyh.js";import{D as me}from"./composer-DKWLJeo9.js";import{i as he,n as ge,r as _e,t as ve}from"./textarea-rKUFh5lI.js";import{t as ye}from"./check-DA37PQLT.js";import{p as be}from"./tooltip-BVqBAGNb.js";import{t as xe}from"./chevron-right-Beu1pd6H.js";import{n as Se}from"./x-HaVPcg_B.js";import{n as Ce,r as we,t as Te}from"./run-header-BPNBEaOy.js";import{g as Ee}from"./dropdown-menu-CxPGHgWX.js";import{n as De}from"./ellipsis-BmusVE8U.js";import{t as Oe}from"./file-text-DBeC0yKb.js";import{n as ke}from"./triangle-alert-CP3Xp0FU.js";import{n as Ae,r as je,t as Me}from"./centered-state-sEYB3bgq.js";import{n as Ne,t as Pe}from"./thread-loading-DLlbK51g.js";import{t as Fe}from"./use-submit-shortcut-BA4NVpJl.js";import{t as Ie}from"./search-x-6BavY3mg.js";import{s as Le}from"./git-toolbar-DXyPCDkQ.js";import{n as Re,r as ze,t as Be}from"./collapsible-MuXfYnM8.js";import{i as H}from"./token-metrics-BcPjL36-.js";import{t as U}from"./markdown-BpZ4p95p.js";import{t as Ve}from"./lib-BQXq3kEf.js";import{a as He}from"./scroll-within-DRt7mAnQ.js";import{t as Ue}from"./run-diff-BTB7nBeD.js";import{a as We,c as Ge,l as Ke,n as qe,o as Je,r as Ye,t as Xe,u as Ze}from"./task-composer-7bdNNMP_.js";var Qe=120;function $e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function et(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Qe?`${t.slice(0,Qe-1)}…`:t}function W(e,...t){if($e(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return et(t)}}function tt(e){if(!$e(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return et(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return et(e.join(` `))}}function nt(e){if(!$e(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)$e(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function rt(e){return W(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function G(e,t){return t?`${e} ${t}`:e}function it(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:G(`Ran`,tt(t)),subtitle:W(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:G(`Edit`,W(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:G(`Write`,W(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:G(`Edit`,W(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=nt(t);return{toolKind:`edit`,title:G(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:G(`Read`,W(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:G(`View image`,W(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:G(`Search`,W(t,`pattern`,`query`)),subtitle:W(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:G(`Fetch`,W(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:G(`Web search`,W(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=W(t,`subagent_type`,`subagentType`),i=W(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=W(t,`skill`,`name`,`command`);return{toolKind:`skill`,title:e?`Skill: ${e}`:`Skill`,subtitle:W(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=W(t,`server`),n=W(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:rt(t)}}}if(n.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?et(e):`Tool`,subtitle:rt(t)}}var at=M(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ot=M(`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`}]]),st=M(`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`}]]),ct=M(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),lt=M(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),ut=M(`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`}]]),K=e(t(),1);function dt(e,t,n){let[r,i]=(0,K.useState)({key:n,value:e}),a=(0,K.useRef)(e);a.current=e;let o=(0,K.useRef)(n);o.current=n;let s=(0,K.useRef)(0),c=(0,K.useRef)(void 0),l=(0,K.useRef)(!1),u=!Object.is(r.value,e);return r.key===n?u&&c.current===void 0&&Date.now()-s.current>=t&&i({key:n,value:e}):i({key:n,value:e}),(0,K.useEffect)(()=>{if(!l.current){l.current=!0;return}clearTimeout(c.current),c.current=void 0,s.current=Date.now()},[r]),(0,K.useEffect)(()=>{if(Object.is(r.value,e)||c.current!==void 0)return;let n=Math.max(0,s.current+t-Date.now());c.current=setTimeout(()=>{c.current=void 0,s.current=Date.now(),i({key:o.current,value:a.current})},n)},[r,e,t]),(0,K.useEffect)(()=>()=>clearTimeout(c.current),[]),r.value}var ft=5,pt=120,mt=200,ht=5e3,gt=15e3,_t=[];function vt(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function yt(e){let t=-1/0;for(let n of e){if(n.seq<=t)return!1;t=n.seq}return!0}function q(e){for(let t=e.length-1;t>=0;--t)if(e[t].newerCursor===void 0)return e[t]}function bt(...e){if(!e.every(yt))return vt(...e);let t=e.map(()=>0),n=[];for(;;){let r=1/0;for(let n=0;n<e.length;n+=1){let i=e[n][t[n]];i!==void 0&&i.seq<r&&(r=i.seq)}if(r===1/0)return n;let i;for(let n=0;n<e.length;n+=1){let a=e[n][t[n]];a?.seq===r&&(i=a,t[n]=t[n]+1)}i!==void 0&&n.push(i)}}function xt(e,t,n=-1/0){let r=new Set(t.map(({seq:e})=>e)),i=new Map;for(let e of t){if(e.type!==`item.updated`&&e.type!==`item.completed`)continue;let t=R(e);t!==void 0&&i.set(t,Math.max(i.get(t)??-1/0,e.seq))}return e.filter(e=>{if(r.has(e.seq)||e.seq<=n&&e.type!==`item.delta`&&e.type!==`item.updated`)return!0;if(e.type!==`item.delta`&&e.type!==`item.updated`)return!1;let t=i.get(R(e)??``);return t!==void 0&&t>e.seq}).map(({seq:e})=>e)}function St(e,t){if(t.length===0)return e.slice();let n=e.at(-1)?.seq??-1/0,r=-1/0;for(let n of t){if(n.seq<=r)return vt(e,t);r=n.seq}return e.length===0||t[0].seq>n?[...e,...t]:bt(e,t)}function Ct(e){let t=j(),n=g(),r=[`run-history`,t,e],i=[`run-history-context`,t,e],o=[`run-history-tail`,t,e],s=k({queryKey:r,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>a(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:ft,retry:1}),c=T({queryKey:i,enabled:e!==void 0,queryFn:({signal:t})=>l(e,{signal:t}),retry:1}),u=s.isError&&s.data===void 0&&!s.isFetchPreviousPageError&&!s.isFetchNextPageError&&!s.isRefetchError,d=c.isError&&c.data===void 0&&!c.isRefetchError,f=s.data?.pages??[],p=(0,K.useRef)(void 0),m=`${t}\0${e??``}`,h=(0,K.useRef)({key:m,fallbackLatched:!1}),_=(0,K.useRef)(Promise.resolve()),v=(0,K.useRef)(0);h.current.key!==m&&(h.current={key:m,fallbackLatched:!1},_.current=Promise.resolve(),v.current+=1,p.current=void 0),(u||d)&&(h.current.fallbackLatched=!0);let y=h.current.fallbackLatched,b=(0,K.useCallback)(e=>{let t=_.current,n;return _.current=new Promise(e=>{n=e}),t.then(e).finally(n)},[]),x=q(f),S=f.length>0?n.getQueryData(o):void 0;x&&(!p.current||x.asOfSeq>=p.current.asOfSeq)?p.current=x:S&&(!p.current||S.asOfSeq>=p.current.asOfSeq)&&(p.current=S);let C=p.current??x??S??(f.length>0?f.at(-1):void 0),w=(0,K.useRef)(void 0),E=(0,K.useCallback)(async t=>{if(e===void 0||w.current===m)return!1;w.current=m;let i=v.current,s=new AbortController,c;try{let l=await Promise.race([a(e,void 0,{signal:s.signal}),new Promise((e,t)=>{c=setTimeout(()=>{s.abort(),t(Error(`history compaction timed out`))},gt)})]);if(h.current.key!==m||v.current!==i)return!1;let u=n.getQueryData(r),d=q(u?.pages??[]),f=n.getQueryData(o);if(Math.max(d?.asOfSeq??-1/0,f?.asOfSeq??-1/0,p.current?.asOfSeq??-1/0)>=l.asOfSeq)return!1;let g=u?(()=>{let e=[...u.pages],t=[...u.pageParams],n=d?e.indexOf(d):-1;for(n>=0?(e[n]=l,t[n]=void 0):(e.push(l),t.push(void 0));e.length>ft;)e.shift(),t.shift();return{pages:e,pageParams:t}})():{pages:[l],pageParams:[void 0]};return n.setQueryData(r,g),n.setQueryData(o,l),p.current=l,xt(t,g.pages.flatMap(e=>e.events),l.asOfSeq)}catch{return!1}finally{clearTimeout(c),s.abort(),w.current===m&&(w.current=void 0)}},[r,m,n,e,o]),D=re(C&&!y?e:void 0,C?{cursor:C.liveCursor,afterSeq:C.asOfSeq,compactWhenOver:ht,compactAt:mt,onCompact:E}:{}),O=re(y?e:void 0),A=dt(D,pt,e),M=dt(O,pt,e),N=(0,K.useRef)({runId:void 0,scope:t,events:[]});(N.current.runId!==e||N.current.scope!==t)&&(N.current={runId:e,scope:t,events:[]}),y||(N.current.events=A);let P=y?N.current.events:_t,F=(0,K.useMemo)(()=>{let e=f.map(e=>e.events);return C!==void 0&&!f.includes(C)&&e.push(C.events),vt(...e)},[C,f]);(0,K.useEffect)(()=>{let e=q(f);e&&n.setQueryData(o,e)},[f,n,e,t]);let I=(0,K.useMemo)(()=>y?bt(F,P,M):St(F,A),[y,M,P,A,F]),L=(0,K.useMemo)(()=>{if(y)return I;let e=c.data?.contextEvents??[],t=c.data?.asOfSeq??0;return bt(e,I.filter(({seq:e})=>e>t),A.filter(({seq:e})=>e<=t))},[c.data,y,A,I]),R=(0,K.useCallback)(async()=>{let e=m,t=v.current,i=q(n.getQueryData(r)?.pages??[]);i&&n.setQueryData(o,i);try{await b(()=>s.fetchPreviousPage())}finally{if(h.current.key!==e||v.current!==t)return;let i=p.current;if(!i)return;n.setQueryData(r,e=>{if(!e)return e;let t=q(e.pages),n=t?e.pages.indexOf(t):-1;if(n<0||e.pages[n].asOfSeq>=i.asOfSeq)return e;let r=[...e.pages];return r[n]=i,{...e,pages:r}})}},[b,s.fetchPreviousPage,r,n,o]),z=(0,K.useCallback)(async()=>{v.current+=1,_.current=Promise.resolve();let e=e=>p.current??q(e)??n.getQueryData(o),t=n.getQueryData(r);if(!e(t?.pages??[])){p.current=void 0,n.removeQueries({queryKey:o,exact:!0}),n.resetQueries({queryKey:r,exact:!0});return}if(t?.pages.length===1&&t.pages[0]===e(t.pages)&&!s.isFetchingPreviousPage)return;await n.cancelQueries({queryKey:r,exact:!0});let i=e(n.getQueryData(r)?.pages??[]);i&&(n.setQueryData(r,{pages:[i],pageParams:[void 0]}),n.setQueryData(o,i),p.current=i)},[s.isFetchingPreviousPage,r,n,o]);return{visibleEvents:I,currentEvents:L,isPending:!y&&s.isPending,contextPending:!y&&c.isPending,fallback:y,hasOlder:!y&&!!s.hasPreviousPage,isFetchingOlder:s.isFetchingPreviousPage,olderError:s.isFetchPreviousPageError?s.error instanceof Error?s.error.message:`Could not load earlier items`:void 0,loadOlder:R,jumpToLatest:z,retainedPages:f.length}}var J=n();function wt({run:e}){let t=g(),n=C({mutationFn:()=>p(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:b.runs.detail(e.id)}),t.invalidateQueries({queryKey:b.runs.list()}),y(`This task will not resume itself`)},onError:e=>y(e.message,{tone:`danger`})});if(e.status!==`failed`||!e.autoResumeAt)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,J.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,J.jsx)(H,{tone:`pending`,pulse:!0}),(0,J.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,J.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,J.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,J.jsx)(u,{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 Tt({run:e}){let t=e.status===`done`||e.status===`review`||e.status===`failed`||e.status===`cancelled`;return e.workflow!==`e2e-setup`||!t?null:(0,J.jsx)(Et,{run:e})}function Et({run:e}){let t=!!i().data?.configFile,n=e.status===`done`||e.status===`review`,r=e.steps.find(e=>e.status===`failed`&&e.id!==`pr`),a=e.pullRequestUrl&&/^https?:\/\//.test(e.pullRequestUrl)?e.pullRequestUrl:void 0,o=(0,J.jsx)(O,{className:`font-medium underline underline-offset-2`,to:`/settings/integrations`,children:`Settings → External integrations`});return(0,J.jsxs)(`div`,{"data-slot":`e2e-setup-verdict`,"data-verdict":n?`works`:`not-working`,role:`status`,className:P(`mt-4 flex gap-3 rounded-lg border p-4 text-sm`,n?`border-success/40 bg-success/5`:`border-danger/40 bg-danger/5`),children:[n?(0,J.jsx)(Se,{className:`mt-0.5 size-5 shrink-0 text-success`,"aria-hidden":!0}):(0,J.jsx)(pe,{className:`mt-0.5 size-5 shrink-0 text-danger`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`font-semibold`,children:n?`e2e works`:e.status===`cancelled`?`e2e is not set up — the setup was cancelled`:`e2e is not working yet`}),n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`The config loads and the smoke test passed in a real browser.`}),(0,J.jsx)(`p`,{className:`mt-1`,children:t?(0,J.jsxs)(J.Fragment,{children:[`It is live in this project: pick the `,(0,J.jsx)(`code`,{children:`implement-and-e2e`}),` workflow for your next task.`]}):a?(0,J.jsxs)(J.Fragment,{children:[`One step left: merge the `,(0,J.jsx)(`a`,{className:`font-medium underline underline-offset-2`,href:a,target:`_blank`,rel:`noreferrer`,children:`draft PR`}),`. Then pick the `,(0,J.jsx)(`code`,{children:`implement-and-e2e`}),` workflow for your next task.`]}):(0,J.jsxs)(J.Fragment,{children:[`One step left: merge branch `,(0,J.jsx)(`code`,{children:e.branch??`of this task`}),` (or open a draft PR from the header). Then pick the `,(0,J.jsx)(`code`,{children:`implement-and-e2e`}),` workflow for your next task.`]})})]}):e.status===`cancelled`?(0,J.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Start it again from `,o,`.`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:r?(0,J.jsxs)(J.Fragment,{children:[`“`,r.name,`” did not pass — its output is above.`]}):`The setup stopped before it could prove e2e works — the reason is above.`}),(0,J.jsxs)(`p`,{className:`mt-1`,children:[`Continue this task to fix it, or set it up again from `,o,`.`]})]})]})]})}var Dt=e=>e.kind===`tool`,Ot=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,kt=(e,t,n)=>`${e} ${e===1?t:n}`;function At(e,t){let n=[];return e>0&&n.push(kt(e,`file`,`files`)),t>0&&n.push(kt(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function jt(e){return`${e} earlier tool call${e===1?``:`s`}`}var Mt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`,`Skill:`];function Y(e){for(let t of Mt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t.endsWith(`:`)?t.slice(0,-1):t,detail:e.slice(t.length+1)};return{verb:e}}function Nt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Dt).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:At(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]};for(let e of i)Dt(e)&&Ot(e)&&!r.has(e.id)?o.push(e):(s(),Dt(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}));s();let c=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,l=e=>e.kind===`context-group`?e.tools.length:1,u=[],d=[],f=()=>{if(d.length>3){let e=d.slice(0,d.length-3);u.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+l(t),0),blocks:e}),u.push(...d.slice(d.length-3))}else u.push(...d);d=[]};for(let e of a)c(e)?d.push(e):(f(),u.push(e));return f(),u}var Pt=new Map,Ft=(0,K.createContext)(null);function It(){return(0,K.useContext)(Ft)}function Lt({runId:e,children:t}){let n=(0,K.useMemo)(()=>({get:t=>Pt.get(e)?.get(t),set:(t,n)=>{let r=Pt.get(e)??new Map;r.set(t,n),Pt.set(e,r)}}),[e]);return(0,J.jsx)(Ft.Provider,{value:n,children:t})}function Rt(e){let t=`flex w-full flex-col pb-2.5`;return e?`${t} [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`:t}function zt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function Bt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Vt(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 Ht(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ut(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Wt=new Map;function Gt(e,t){Wt.set(e,t)}function Kt(e){return Wt.get(e)}var qt=new Map;function Jt(e,t){qt.set(e,t)}function Yt(e,t){let n=qt.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}var Xt=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),Zt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Qt=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),$t=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),en=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function X(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function tn(e){let t=X(e);return t===void 0?void 0:Xt.format(t)}function nn(e){let t=X(e);return t===void 0?void 0:Zt.format(t)}var rn=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function an(e){let t=X(e);return t===void 0?void 0:rn(t)}function on(e,t=new Date){let n=X(e);if(n===void 0)return;let r=rn(n);return r===rn(t)?`Today`:r===rn(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Qt:$t).format(n)}function sn(e,t){let n=X(e),r=X(t);if(!(n===void 0||r===void 0))return ln(Math.round((r.getTime()-n.getTime())/1e3))}function cn(e,t){let n=X(e);if(n!==void 0)return ln(Math.floor((t-n.getTime())/1e3))}function ln(e){if(e<0)return;if(e<60)return`${e}s`;let t=Math.floor(e/60);return t<60?`${t}m ${String(e%60).padStart(2,`0`)}s`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,`0`)}m`}function un(e=1e3){let[t,n]=(0,K.useState)(()=>Date.now());return(0,K.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function dn({ts:e}){let t=tn(e);return t===void 0?null:(0,J.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:nn(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function fn({startedAt:e,completedAt:t}){let n=tn(t);if(n===void 0)return null;let r=sn(e,t);return(0,J.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,J.jsx)(`time`,{dateTime:t,title:nn(t),children:n}),r===void 0?null:(0,J.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function pn({ts:e}){let t=on(e),n=X(e);if(t===void 0||n===void 0)return null;let r=en.format(n);return(0,J.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,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,J.jsx)(`time`,{dateTime:an(e),title:r,children:t}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}function mn({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,onRemove:a,editLabel:o=`Edit message`,removeLabel:s=`Remove message`,draftRunId:c,draftSurface:l}){let u=t-n.length,[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(e),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(),y=we(c??``,l??``,{enabled:i!==void 0&&c!==void 0&&l!==void 0}),b=`${c??``} ${l??``}`,[x,S]=(0,K.useState)(b);x!==b&&(S(b),f(!1),m(e),v(void 0)),(0,K.useEffect)(()=>{d||!y.ready||!y.hasDraft||(m(y.text),v(void 0),f(!0))},[d,y.hasDraft,y.ready,y.text]);let C=e=>{m(e),y.setText(e)},w=()=>{m(e),v(void 0),f(!0)},T=async()=>{let t=p.trim();if(!t||t===e){y.clear(),f(!1);return}g(!0),v(void 0);try{await y.submit(()=>i?.(t)??Promise.resolve()),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},E=()=>{y.clear(),f(!1)},D=async()=>{g(!0),v(void 0);try{await a?.(),y.clear()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,J.jsxs)(`div`,{"data-slot":`user-bubble`,"data-editing":`true`,className:`max-w-[78%] self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[(0,J.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),E()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),T())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[13.5px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,J.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:E,disabled:h,className:`rounded-sm px-2 py-1 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,J.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:h,className:`rounded-sm bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,J.jsx)(je,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,J.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,J.jsxs)(`div`,{"data-slot":`user-bubble`,className:`group max-w-[78%] min-w-0 self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[i||a?(0,J.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,J.jsx)(`button`,{type:`button`,"aria-label":o,onClick:w,disabled:h,className:`rounded-sm p-1 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,J.jsx)(ut,{className:`size-3.5`})}):null,a?(0,J.jsx)(`button`,{type:`button`,"aria-label":s,onClick:()=>void D(),disabled:h,className:`rounded-sm p-1 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,J.jsx)(ge,{className:`size-3.5`})}):null]}):null,_?(0,J.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,(0,J.jsx)(hn,{text:e}),n.length>0?(0,J.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>I(e.split(`/`).pop()??``)?(0,J.jsx)(He,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,J.jsxs)(`a`,{href:e,download:!0,"data-slot":`user-file`,className:`inline-flex 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,J.jsx)(me,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,J.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null,r===void 0?null:(0,J.jsx)(`span`,{className:`mt-1 flex justify-end`,children:(0,J.jsx)(dn,{ts:r})})]})}function hn({text:e}){let t=(0,K.useMemo)(()=>Ke(e),[e]);return t?(0,J.jsxs)(J.Fragment,{children:[t.lead===``?null:(0,J.jsx)(U,{breaks:!0,children:t.lead}),(0,J.jsx)(Ye,{items:t.items})]}):(0,J.jsx)(U,{breaks:!0,children:e})}function gn({text:e}){return(0,J.jsx)(`div`,{"data-slot":`assistant-message`,className:`min-w-0 text-[15px] leading-[1.65]`,children:(0,J.jsx)(U,{children:e})})}function _n({note:e}){return(0,J.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:P(`px-0.5 text-xs`,e.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var vn={claude:`Claude Code`,codex:`Codex`,junie:`Junie`,opencode:`OpenCode`,cursor:`Cursor`,pi:`pi`,copilot:`GitHub Copilot CLI`};function yn({incident:e}){let t=vn[e.provider];return(0,J.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,J.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,J.jsx)(O,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function bn({text:e}){let t=(0,K.useId)();if(e.trim()===``)return null;let n=e.split(`
2
+ `,1)[0]??``,r=n.length<e.length;return(0,J.jsxs)(Be,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,J.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,J.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,J.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,J.jsx)(U,{inline:!0,children:n})}),r?(0,J.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,J.jsx)(ze,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,J.jsx)(Re,{children:(0,J.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,J.jsx)(U,{children:e})})})]})}function xn({since:e,lastActivityAt:t}={}){let n=un(),r=cn(e,n),i=cn(t,n),a=tn(t);return(0,J.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 py-1 text-[13px] text-soft-foreground`,children:[(0,J.jsx)(je,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,J.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`}),r===void 0?null:(0,J.jsx)(`span`,{"data-slot":`working-elapsed`,title:`Started ${nn(e)}`,className:`font-mono text-xs tabular-nums`,children:r}),i!==void 0&&a!==void 0?(0,J.jsxs)(`span`,{"data-slot":`working-last-activity`,title:nn(t),className:`text-xs`,children:[`· last activity `,a,` (`,i,` ago)`]}):null]})}var Sn={read:Oe,edit:ut,delete:ge,move:ct,search:fe,execute:le,think:ot,fetch:ce,task:he,skill:oe,plan:lt,other:Le},Cn=e=>e.split(`
3
+ `).length;function wn({text:e,streaming:t}){let[n,r]=(0,K.useState)(!1),i=(0,K.useRef)(null),a=(0,K.useRef)(!0);(0,K.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Cn(e),s=!t&&!n&&o>12;return(0,J.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=Ht(e.currentTarget)}:void 0,className:P(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,J.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,J.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,J.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function Tn({diffs:e}){return(0,J.jsx)(J.Fragment,{children:e.map((e,t)=>(0,J.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,J.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...En(e.oldText).map((e,t)=>(0,J.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...En(e.newText).map((e,t)=>(0,J.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
+ `).map((e,t)=>(0,J.jsx)(Dn,{text:e},t))})]},`${e.path}:${t}`))})}function En(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
+ `)}function Dn({text:e}){return(0,J.jsx)(`span`,{className:P(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function On(e){if(e.toolKind!==`execute`)return;let t=e.input,n=typeof t==`object`&&t&&`command`in t?t.command:void 0,r=typeof n==`string`?n:Array.isArray(n)&&n.every(e=>typeof e==`string`)?n.join(` `):Y(e.title).detail;return r!==void 0&&r.trim()!==``?r:void 0}function kn({command:e}){let[t,n]=(0,K.useState)(!1);return(0,J.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy command`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},className:`mt-[3px] mr-1.5 shrink-0 rounded p-1 text-soft-foreground hover:bg-muted hover:text-foreground`,children:t?(0,J.jsx)(ye,{"aria-hidden":!0,className:`size-3.5`}):(0,J.jsx)(De,{"aria-hidden":!0,className:`size-3.5`})})}function An(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function jn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=It(),[a,o]=(0,K.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},c=e.status===`running`||e.status===`pending`,l=On(e),{verb:u,detail:d}=Y(e.title),f=l!==void 0&&(l!==d||l.includes(`
6
+ `)||l.length>80),p=l!==void 0&&f,m=f||e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,h=m&&(a??An(e)),g=h&&p?l:void 0,_=Sn[e.toolKind]??Le;return(0,J.jsxs)(Be,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:h,onOpenChange:s,className:P(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start`,children:[(0,J.jsxs)(ze,{disabled:!m,className:P(`group flex min-h-[28px] w-full min-w-0 gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,g===void 0?`items-center`:`items-start [&>svg]:mt-[7px] [&>span]:mt-[2px]`),children:[(0,J.jsx)(xe,{"aria-hidden":!0,className:P(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!m&&`invisible`)}),(0,J.jsx)(_,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:P(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),g===void 0?d===void 0?null:(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:d}):(0,J.jsx)(`code`,{"data-slot":`tool-command`,className:`max-h-48 min-w-0 overflow-y-auto py-1 font-mono text-xs leading-[1.6] whitespace-pre-wrap break-all text-muted-foreground`,children:g}),(0,J.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,J.jsx)(je,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,J.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,J.jsx)(`span`,{"data-slot":`tool-exit`,className:P(`rounded-full px-2 py-px font-mono text-[10.5px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),g===void 0?null:(0,J.jsx)(kn,{command:g})]}),(0,J.jsx)(Re,{children:(0,J.jsxs)(`div`,{className:`border-t border-border bg-card-2 empty:hidden`,children:[e.error!==void 0&&e.error!==``?(0,J.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,J.jsx)(Tn,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,J.jsx)(wn,{text:e.output,streaming:c}):null,t.length>0?(0,J.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:r?.(t,n??e.id)}):null]})})]})}function Mn({group:e,scope:t}){return(0,J.jsxs)(Be,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,J.jsxs)(ze,{className:`group flex h-[34px] w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,J.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,J.jsx)(Re,{children:(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,J.jsx)(jn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Nn({count:e,children:t}){return(0,J.jsxs)(Be,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,J.jsxs)(ze,{className:`group flex items-center gap-1.5 rounded-md p-0.5 text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,J.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),jt(e)]}),(0,J.jsx)(Re,{children:(0,J.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Pn({image:e}){return(0,J.jsx)(He,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var Fn=120,In=e=>e!==`pending`&&e!==`running`,Ln=e=>e.kind===`tool`&&e.toolKind===`task`,Z=e=>Ln(e)&&e.parentItemId===void 0,Rn=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function zn(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>Z(e)&&t.has(e.id)))return n;return 0}function Bn(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 Vn(e){if(e.kind===`tool`)return Hn(e.title);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
7
+ `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Hn(n)}}}function Hn(e){return e.length>Fn?`${e.slice(0,Fn-1).trimEnd()}…`:e}function Un(e,t=!1){let n=Yn(e,e=>e.items.some(Z));if(n===-1)return[];let r=e=>!t&&!In(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(Z);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(Z)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?zn(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!Rn(n))continue;let e=n.parentItemId;if(e===void 0||!o.has(e))continue;let t=c.get(e);t?t.push(n):c.set(e,[n])}return a.map(e=>Gn(e,c.get(e.id)??[],t))}function Wn(e){let t=new Map;for(let n of e)for(let e of n.items){if(e.kind!==`tool`||e.toolKind!==`skill`||e.parentItemId!==void 0||e.status===`failed`||e.status===`declined`)continue;let n=Y(e.title).detail??e.title;t.has(n)||t.set(n,{id:e.id,name:n})}return[...t.values()]}function Gn(e,t,n){let r={id:e.id,title:Y(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Bn(e);i!==void 0&&(r.agentType=i),n&&!In(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Vn(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Kn(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function qn(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Jn(e){return e.find(e=>!In(e.status))??e[0]}function Yn(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Xn(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&Z(e));if(i!==void 0)return Gn(i,Zn(e,t),n)}}function Zn(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&Z(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)Rn(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}var Qn=new Map,$n=!1;function er({runId:e,agents:t,onSelect:n}){let[r,i]=(0,K.useState)(()=>Qn.get(e)??$n),a=t.every(e=>e.status!==`pending`&&e.status!==`running`),o=(0,K.useRef)(a);if((0,K.useEffect)(()=>{!o.current&&a&&i(t=>t&&(Qn.set(e,!1),!1)),o.current=a},[a,e]),t.length===0)return null;let{done:s,total:c}=Kn(t),l=Jn(t);return(0,J.jsxs)(`section`,{"data-slot":`agents-dock`,"data-state":r?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,J.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(t=>(Qn.set(e,!t),!t)),"aria-expanded":r,className:P(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,r?`pt-2 pb-1.5`:`py-2`),children:[(0,J.jsx)(he,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Agents`}),(0,J.jsxs)(`span`,{"data-slot":`agents-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,s,`/`,c]}),!r&&l!==void 0?(0,J.jsxs)(`span`,{"data-slot":`agents-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,qn(l)]}):null,(0,J.jsx)(be,{"aria-hidden":!0,className:P(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!r&&`rotate-180`)})]}),r?(0,J.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map(e=>(0,J.jsx)(tr,{agent:e,onSelect:n},e.id))}):null]})}function tr({agent:e,onSelect:t}){let n=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(nr,{status:e.status,stalled:e.stalled===!0}),(0,J.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,J.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,J.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:qn(e)}),(0,J.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,J.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,J.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function nr({status:e,stalled:t=!1}){return t?(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,J.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,J.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,J.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}var rr=new Map;function ir(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function ar(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function or(e){return e.find(e=>e.status===`in_progress`)??e.find(e=>e.status===`pending`)}function sr({runId:e,entries:t,settled:n=!1}){let[r,i]=(0,K.useState)(()=>rr.get(e)??ir());if(t.length===0)return null;let{done:a,total:o}=ar(t),s=n?void 0:or(t),c=n&&a<o;return(0,J.jsxs)(`section`,{"data-slot":`plan-dock`,"data-state":r?`open`:`collapsed`,"data-settled":n?`true`:void 0,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,J.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-0.5 md:h-[3px]`,style:{background:`var(--grad)`}}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(t=>(rr.set(e,!t),!t)),"aria-expanded":r,className:P(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,r?`pt-2 pb-1.5`:`py-2`),children:[(0,J.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Plan`}),(0,J.jsxs)(`span`,{"data-slot":`plan-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,a,`/`,o]}),c?(0,J.jsx)(`span`,{"data-slot":`plan-unfinished`,className:`shrink-0 text-soft-foreground`,children:`· left unfinished`}):null,!r&&s!==void 0?(0,J.jsxs)(`span`,{"data-slot":`plan-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,s.activeForm??s.content]}):null,(0,J.jsx)(be,{"aria-hidden":!0,className:P(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!r&&`rotate-180`)})]}),r?(0,J.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map((e,t)=>(0,J.jsx)(cr,{entry:e,settled:n},`${t}:${e.content}`))}):null]})}function cr({entry:e,settled:t}){let n=t&&e.status===`in_progress`?`pending`:e.status;return(0,J.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:P(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,n===`completed`&&`text-soft-foreground line-through`,n===`in_progress`&&`font-medium`,n===`pending`&&`text-muted-foreground`,n===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,J.jsx)(lr,{status:n}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),n===`in_progress`?(0,J.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function lr({status:e}){return e===`cancelled`?(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,J.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,J.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,J.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,J.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,J.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,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ur({skills:e}){return e.length===0?null:(0,J.jsxs)(`section`,{"data-slot":`skills-dock`,className:`flex min-w-0 items-center gap-2 overflow-hidden rounded-lg border border-border bg-card px-3.5 py-2 text-[13px] shadow-xs`,children:[(0,J.jsx)(oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`shrink-0 font-semibold`,children:e.length===1?`Skill`:`Skills`}),(0,J.jsxs)(`span`,{"data-slot":`skills-names`,className:`min-w-0 truncate text-muted-foreground`,children:[`· `,e.map(e=>e.name).join(` · `)]})]})}function dr(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!dr(e[n],t[n]))return!1;return!0}if(!fr(e)||!fr(t))return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.hasOwn(t,r)||!dr(e[r],t[r]))return!1;return!0}function fr(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function pr(){return typeof CSS>`u`||typeof CSS.supports!=`function`||CSS.supports(`overflow-anchor`,`auto`)}function mr(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,K.useRef)(null),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),d=(0,K.useRef)(!0),f=(0,K.useRef)(null),p=(0,K.useRef)(null),m=(0,K.useRef)(null),h=(0,K.useCallback)(e=>{let t=o.current;if(!t)return;let n=m.current;n?n.scrollTo(e):t.scrollTop=e},[]),g=(0,K.useCallback)(()=>{let e=o.current;e&&h(e.scrollHeight-e.clientHeight)},[h]),_=(0,K.useCallback)(()=>{if(o.current){if(p.current!==e){p.current=e;let t=Kt(e);t&&!t.atBottom?(d.current=!1,f.current=t.top):(d.current=!0,f.current=null)}f.current===null?d.current&&g():h(f.current)}},[e,h,g]),v=(0,K.useCallback)(e=>{c(e),e&&(o.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),_())},[n,_]),y=(0,K.useCallback)(()=>{d.current&&g()},[g]),b=(0,K.useRef)(!1),x=(0,K.useRef)(!1),S=(0,K.useRef)(void 0),C=(0,K.useRef)(!1),w=(0,K.useRef)(!1),T=(0,K.useRef)(!1),E=(0,K.useRef)(void 0),D=(0,K.useRef)(0),O=(0,K.useRef)(a);O.current=a;let k=(0,K.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}}),[]),A=(0,K.useCallback)(()=>{let e=o.current;if(!e||!r||b.current)return;b.current=!0;let t=e.scrollHeight,n=e.scrollTop,i=e.getBoundingClientRect().top,a=Bt(i,k(e));r().finally(()=>{requestAnimationFrame(()=>{let e=o.current;if(e&&!d.current){let r=n+Math.max(0,e.scrollHeight-t),i=e.getBoundingClientRect().top,o=a===void 0?-1:O.current.indexOf(a.key),s=m.current;s&&o>=0?s.scrollToIndex(o,{align:`start`,offset:-a.offset}):h(Vt(e.scrollTop,i,a,k(e),r))}b.current=!1})})},[k,r,h]);(0,K.useEffect)(()=>()=>clearTimeout(S.current),[]);let j=(0,K.useCallback)(()=>{o.current&&(f.current=null,d.current=!0,(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{let e=o.current;e?.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:`smooth`})})}))},[i]);return(0,K.useLayoutEffect)(()=>{!o.current||!s||_()},[s,_]),(0,K.useEffect)(()=>{let t=o.current,n=s;if(!t||!n)return;let r=!pr(),i=(e,t)=>{if(typeof document.elementsFromPoint==`function`){let n=document.elementsFromPoint(t.left+t.width/2,t.top+1).map(e=>e.closest(`[data-slot="thread-row"][data-row-key]`)).find(t=>t!==null&&e.contains(t));if(n){let e=n.getBoundingClientRect();return{key:n.dataset.rowKey,top:e.top,bottom:e.bottom}}return}return k(e).find(({bottom:e})=>e>t.top)},a=(e,t)=>{let n=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(t):t.replace(/["\\]/g,`\\$&`),r=e.querySelector(`[data-slot="thread-row"][data-row-key="${n}"]`);if(!r)return;let i=r.getBoundingClientRect();return{key:t,top:i.top,bottom:i.bottom}},c=()=>{!r||d.current||f.current!==null||D.current===0&&(D.current=requestAnimationFrame(()=>{D.current=0;let e=o.current;if(!e||d.current)return;let t=e.getBoundingClientRect(),n=i(e,t);E.current=n===void 0?void 0:{key:n.key,offset:n.top-t.top}}))},l=()=>{let e=E.current;if(!r||e===void 0||m.current)return;let n=t.getBoundingClientRect().top,i=a(t,e.key),o=i===void 0?t.scrollTop:t.scrollTop+(i.top-n-e.offset);Math.abs(o-t.scrollTop)>=1&&h(o)},p=0,_=null,v=!1,y=t.scrollTop,b=()=>{f.current=null,d.current=!1,p=0},O=()=>{p=Date.now()},j=e=>{if(e.deltaY<0){b();let e=!x.current;x.current=!0,clearTimeout(S.current),S.current=setTimeout(()=>{x.current=!1},180),e&&zt(t)&&A()}else O()},M=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(b(),!e.repeat&&zt(t)&&A()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&O()},N=()=>{v=!0,T.current=!1,y=t.scrollTop,Ht(t,80)||(b(),O())},P=()=>{v=!1},F=e=>{C.current=!1,w.current=!0,_=e.touches[0]?.clientY??null},I=()=>{w.current&&(w.current=!1,d.current&&f.current===null&&g())},L=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(_!==null&&n>_+1?(b(),!C.current&&zt(t)&&(C.current=!0,A())):_!==null&&n<_-1&&O(),_=n)},R=()=>{v&&!T.current&&t.scrollTop<y&&zt(t)&&(T.current=!0,A()),y=t.scrollTop;let n=Ht(t,80);n&&f.current===null&&(d.current||Date.now()-p<2e3)&&(d.current=!0),u(!n),f.current===null&&Gt(e,{top:t.scrollTop,atBottom:n}),c()};t.addEventListener(`scroll`,R,{passive:!0}),t.addEventListener(`wheel`,j,{passive:!0}),t.addEventListener(`touchstart`,F,{passive:!0}),t.addEventListener(`touchmove`,L,{passive:!0}),window.addEventListener(`touchend`,I,{passive:!0}),window.addEventListener(`touchcancel`,I,{passive:!0}),t.addEventListener(`pointerdown`,N,{passive:!0}),window.addEventListener(`pointerup`,P,{passive:!0}),t.addEventListener(`keydown`,M);let z;return typeof ResizeObserver<`u`&&(z=new ResizeObserver(()=>{let e=f.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;h(Math.min(e,n)),n>=e&&(f.current=null,c())}else d.current?w.current||g():l()}),z.observe(n)),c(),()=>{cancelAnimationFrame(D.current),D.current=0,E.current=void 0,t.removeEventListener(`scroll`,R),t.removeEventListener(`wheel`,j),t.removeEventListener(`touchstart`,F),t.removeEventListener(`touchmove`,L),window.removeEventListener(`touchend`,I),window.removeEventListener(`touchcancel`,I),t.removeEventListener(`pointerdown`,N),window.removeEventListener(`pointerup`,P),t.removeEventListener(`keydown`,M),z?.disconnect()}},[e,s,A,h,g]),{attachContent:v,scrollElRef:o,virtualizerRef:m,pillVisible:l,jumpToLatest:j,loadOlder:A,restickIfStuck:y}}function hr({runId:e,rows:t,mode:n,controls:r}){if(n===`virtual`)return(0,J.jsx)(gr,{runId:e,rows:t,controls:r});let i=Rt(pr());return(0,J.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,children:t.map(e=>(0,J.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:i,children:e.node},e.key))})}function gr({runId:e,rows:t,controls:n}){let r=(0,K.useRef)(null),[i]=(0,K.useState)(()=>Yt(e,t.length)),a=(0,K.useRef)(t.length);a.current=t.length;let o=(0,K.useRef)(null),s=(0,K.useCallback)(t=>{n.virtualizerRef.current=t,t?o.current=t:o.current&&=(Jt(e,{rows:a.current,cache:o.current.cache}),null)},[e,n.virtualizerRef]),[c,l]=(0,K.useState)(0);return(0,K.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||l(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,J.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,children:(0,J.jsx)(Ve,{ref:s,scrollRef:n.scrollElRef,startMargin:c,...i===void 0?{}:{cache:i},children:t.map(e=>(0,J.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))})})}function _r({onJump:e}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,onClick:e,className:`pointer-events-auto inline-flex min-h-8 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,J.jsx)(at,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}function vr(e,t){let n=[];e.task&&n.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])n.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let e of t.turns)n.push({id:e.id,userMessageKey:`${e.id}:user`,...e.userMessage===void 0?{}:{userMessage:{text:e.userMessage.text,imageCount:e.userMessage.imageCount,images:e.userMessage.images,...e.userMessage.ts===void 0?{}:{ts:e.userMessage.ts}}},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.completed?.ts===void 0?{}:{completedAt:e.completed.ts},entries:e.items});return n}function yr(e,t){return[{id:`agent:${e}`,entries:t}]}function br(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function xr(e,t){let n=[],r;for(let t of e){let e=br(t),i=an(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 Nt([...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 Sr({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,messageActions:o,scrollControls:s,renderMode:c,rowModels:l}){let u=(0,K.useMemo)(()=>l??xr(n,e),[l,n,e]),d=mr(`${e}:${t}`,{surface:r}),f=s??d,p=(0,K.useMemo)(()=>u.map(t=>({key:t.key,node:(0,J.jsx)(wr,{runId:e,row:t,actions:o?.[t.key],renderAsk:a})})),[o,a,u,e]),m=c??Ut(``,p.length),h=p.length===0?i??null:(0,J.jsx)(hr,{runId:`${e}:${t}`,rows:p,mode:m,controls:f});return(0,J.jsx)(Lt,{runId:e,children:r===`panel`?(0,J.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,J.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:h}),f.pillVisible?(0,J.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,J.jsx)(_r,{onJump:f.jumpToLatest})}):null]}):h})}function Cr({runId:e,row:t,actions:n,renderAsk:r}){return Tr(e,t,n,r)}var wr=(0,K.memo)(Cr,(e,t)=>e.runId===t.runId&&e.actions===t.actions&&e.renderAsk===t.renderAsk&&dr(e.row,t.row));function Tr(e,t,n,r){switch(t.content.kind){case`user-message`:return(0,J.jsx)(Er,{runId:e,message:t.content.message,actions:n});case`day-separator`:return(0,J.jsx)(pn,{ts:t.content.ts});case`turn-time`:return(0,J.jsx)(fn,{completedAt:t.content.completedAt,...t.content.startedAt===void 0?{}:{startedAt:t.content.startedAt}});case`block`:return(0,J.jsx)(Dr,{block:t.content.block,scope:t.scope,renderAsk:r});default:return Ar(t.content)}}function Er({runId:e,message:t,actions:n}){return(0,J.jsx)(mn,{text:t.text,imageCount:t.imageCount,images:t.images,...t.ts===void 0?{}:{ts:t.ts},onEdit:n?.onEdit,onRemove:n?.onRemove,editLabel:n?.editLabel,removeLabel:n?.removeLabel,draftRunId:n?.draftSurface===void 0?void 0:e,draftSurface:n?.draftSurface})}var Dr=(0,K.memo)(function e({block:t,scope:n,renderAsk:r}){switch(t.kind){case`entry`:return(0,J.jsx)(kr,{entry:t.entry,scope:n,renderAsk:r});case`tool-card`:return(0,J.jsx)(jn,{item:t.item,nested:t.children,cacheKey:`${n}:${t.id}`,renderNested:(e,t)=>(0,J.jsx)(Or,{entries:e,scope:t,renderAsk:r})});case`context-group`:return(0,J.jsx)(Mn,{group:t,scope:n});case`streak`:return(0,J.jsx)(Nn,{count:t.count,children:t.blocks.map(t=>(0,J.jsx)(e,{block:t,scope:n,renderAsk:r},t.id))});default:return Ar(t)}},jr);function Or({entries:e,scope:t,renderAsk:n}){return Nt([...e]).map(e=>(0,J.jsx)(Dr,{block:e,scope:t,renderAsk:n},e.id))}function kr({entry:e,scope:t,renderAsk:n}){switch(e.kind){case`message`:return e.role===`assistant`?(0,J.jsx)(gn,{text:e.text}):(0,J.jsx)(mn,{text:e.text});case`reasoning`:return(0,J.jsx)(bn,{text:e.text});case`tool`:return(0,J.jsx)(jn,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return(0,J.jsx)(_n,{note:e});case`image`:return(0,J.jsx)(Pn,{image:e});case`ask`:return n===void 0?(0,J.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`provider-auth-required`:return(0,J.jsx)(yn,{incident:e});default:return Ar(e)}}function Ar(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function jr(e,t){return e.scope===t.scope&&Nr(e.block,t.block)&&(!Mr(t.block)||e.renderAsk===t.renderAsk)}function Mr(e){return e.kind===`entry`?e.entry.kind===`ask`:e.kind===`tool-card`?e.children.some(e=>e.kind===`ask`):e.kind!==`context-group`&&e.blocks.some(Mr)}function Nr(e,t){if(e.kind!==t.kind||e.id!==t.id)return!1;switch(t.kind){case`entry`:return Fr(e.kind===`entry`?e.entry:void 0,t.entry);case`tool-card`:return e.kind===`tool-card`&&Ur(e.item,t.item)&&Pr(e.children,t.children);case`context-group`:return e.kind===`context-group`&&e.files===t.files&&e.searches===t.searches&&e.label===t.label&&e.tools.length===t.tools.length&&e.tools.every((e,n)=>Ur(e,t.tools[n]));case`streak`:return e.kind===`streak`&&e.count===t.count&&e.blocks.length===t.blocks.length&&e.blocks.every((e,n)=>Nr(e,t.blocks[n]));default:return!1}}function Pr(e,t){return e.length===t.length&&e.every((e,n)=>Fr(e,t[n]))}function Fr(e,t){if(e===void 0||e.kind!==t.kind||e.id!==t.id)return!1;switch(t.kind){case`message`:return e.kind===`message`&&Q(e,t,Ir);case`reasoning`:return e.kind===`reasoning`&&Q(e,t,Lr);case`tool`:return e.kind===`tool`&&Ur(e,t);case`note`:return e.kind===`note`&&Q(e,t,Rr);case`image`:return e.kind===`image`&&Q(e,t,zr);case`ask`:return e.kind===`ask`&&Q(e,t,Br);case`provider-auth-required`:return e.kind===`provider-auth-required`&&Q(e,t,Vr);default:return!1}}var Ir={kind:!0,id:!0,role:!0,text:!0,phase:!0,parentItemId:!0},Lr={kind:!0,id:!0,text:!0,parentItemId:!0},Rr={kind:!0,id:!0,text:!0,tone:!0},zr={kind:!0,id:!0,url:!0,name:!0},Br={kind:!0,id:!0,questions:!0,resolved:!0,answer:!0,fromWorkflow:!0},Vr={kind:!0,id:!0,provider:!0,authFailureId:!0},Hr={kind:!0,id:!0,name:!0,toolKind:!0,title:!0,status:!0,input:!0,output:!0,error:!0,diffs:!0,locations:!0,exitCode:!0,parentItemId:!0};function Q(e,t,n){return Object.keys(n).every(n=>e[n]===t[n])}function Ur(e,t){return Q(e,t,Hr)}function Wr({runId:e,renderAsk:t,agent:n,entries:r,onClose:i}){return(0,J.jsx)(ne,{open:n!==void 0,onOpenChange:e=>{e||i()},children:(0,J.jsx)(te,{"data-slot":`subagent-sheet`,side:`right`,className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:n===void 0?null:(0,J.jsx)(Gr,{runId:e,renderAsk:t,agent:n,entries:r})})})}function Gr({runId:e,renderAsk:t,agent:n,entries:r}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(L,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,J.jsxs)(ee,{className:`flex min-w-0 items-center gap-2 text-[15px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:n.title}),n.agentType===void 0?null:(0,J.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:n.agentType})]}),(0,J.jsxs)(z,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,J.jsx)(Kr,{status:n.status}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[n.toolCalls,` `,n.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,J.jsx)(Sr,{runId:e,viewId:`agent:${n.id}`,sections:yr(n.id,r),mode:`panel`,renderAsk:t,empty:(0,J.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 Kr({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,J.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:P(`rounded-full px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function qr({run:e,diffComments:t}){return(0,J.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-violet/30 bg-violet/10 px-3.5 py-2.5`,children:[(0,J.jsx)(Ee,{className:`size-4 shrink-0 text-violet`,"aria-hidden":`true`}),(0,J.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,J.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,J.jsx)(Ue,{runId:e.id}),(0,J.jsx)(Jr,{run:e,diffComments:t})]})}function Jr({run:e,diffComments:t}){let n=g(),r=(0,K.useRef)(null),i=we(e.id,`review-notes`),a=i.text,o=i.setText,[s,c]=(0,K.useState)(null),l=Ce(e.id),u=Je(e),f=()=>n.invalidateQueries({queryKey:b.runs.all}),p=C({mutationFn:async n=>{if(!u.canContinue)return null;let r=async t=>{let r=`Review feedback:\n${Ge(n,t)}`;if(r.length>1e5)throw Error(`Too long with the diff comments attached — shorten the notes or remove some comments.`);let i=await E(e.id,{text:r,runner:u.runnerOverride});return ue(`review`),i};return i.submit(()=>t?t.submit(r):r([]))},onSuccess:e=>{e!==null&&f()},onError:e=>y(e.message,{tone:`danger`})}),m=C({mutationFn:()=>D(e.id),onSuccess:e=>{y(`Draft PR created — ${e.url}`),f()},onError:e=>{e instanceof d&&e.manual!==void 0&&c(e.manual),y(e.message,{tone:`danger`})}}),h=t?.comments.length??0,_=()=>{let e=a.trim();if(e.length===0&&h===0){y(`Write what to change first.`),r.current?.focus();return}p.mutate(e)};return(0,J.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,J.jsx)(ve,{ref:r,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{Fe({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-[52px] text-[13px]`}),h>0?(0,J.jsxs)(`p`,{"data-slot":`review-diff-comments`,className:`text-xs text-muted-foreground`,children:[`+ `,h,` `,h===1?`comment`:`comments`,` on the diff — sent back with these notes.`]}):null,u.canContinue?null:(0,J.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:u.reason}),u.providerPending?null:(0,J.jsx)(O,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(F,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:u.reason??`Send the notes back into the agent's session`,"aria-describedby":u.canContinue?void 0:`review-provider-guidance`,disabled:p.isPending||!u.canContinue,onClick:_,children:[(0,J.jsx)(st,{"aria-hidden":`true`}),`Send back`]}),N(e.pullRequestUrl)?(0,J.jsx)(F,{asChild:!0,variant:`outline`,size:`sm`,children:(0,J.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,J.jsx)(_e,{"aria-hidden":`true`}),`PR ↗`]})}):(0,J.jsxs)(F,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:m.isPending,onClick:()=>m.mutate(),children:[(0,J.jsx)(ke,{"aria-hidden":`true`}),`Draft PR`]}),(0,J.jsxs)(F,{"data-slot":`review-accept`,variant:`contrast`,size:`sm`,className:`ml-auto`,title:V(`review`),disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,J.jsx)(ye,{"aria-hidden":`true`}),`Accept`]})]}),s===null?null:(0,J.jsx)(Yr,{command:s})]})}function Yr({command:e}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>y(`Command copied to clipboard.`)).catch(()=>y(`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,J.jsx)(De,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function Xr(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Zr=1500;function Qr({status:e}){let t=(0,K.useRef)(e),[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||Xr())return;r(!0);let i=setTimeout(()=>r(!1),Zr);return()=>clearTimeout(i)},[e]),n?(0,J.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,J.jsx)(Ae,{}),(0,J.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,J.jsx)(`span`,{className:`rounded-full border border-violet/30 bg-violet/15 px-4 py-1.5 text-[13px] font-medium text-violet shadow-modal`,children:`✓ Changes accepted`})})]}):null}var $r=new Map,ei=(e,t)=>JSON.stringify([e,t.id,t.questions.map(e=>[e.header,e.question,e.options.map(e=>e.label)])]);function ti(e,t){return $r.get(ei(e,t))??{}}function ni(e,t,n){$r.set(ei(e,t),n)}function ri(e,t){$r.delete(ei(e,t))}function ii(e,t){return`${e.header}: ${t.join(`, `)}`}function ai({ask:e,run:t}){return(0,K.useEffect)(()=>{e.resolved&&ri(t.id,e)},[e,t.id]),e.resolved?(0,J.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,J.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):(0,J.jsx)(oi,{ask:e,run:t})}function oi({ask:e,run:t}){let n=se(t),r=n.blockedBy!==void 0,i=e.questions,a=i.length===1&&i[0]?.multiSelect!==!0,[o,s]=(0,K.useState)(()=>ti(t.id,e)),c=(n,r)=>s(i=>{let a={...i,[n]:r};return ni(t.id,e,a),a}),l=e=>(o[e]?.length??0)>0,u=i.every((e,t)=>l(t)),d=i.some((e,t)=>l(t))?i.filter((e,t)=>!l(t)).map(e=>e.header):[],f=()=>void n.send(i.map((e,t)=>ii(e,o[t]??[])).join(`
8
+ `)),p=n.mode===`resume`;return(0,J.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-delivery":n.mode,className:`rounded-lg border border-primary/25 bg-primary/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,J.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,J.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:e.fromWorkflow?`The workflow is asking`:`The agent is asking`})}),(0,J.jsx)(`div`,{className:`flex flex-col gap-4`,children:i.map((e,t)=>(0,J.jsx)(si,{question:e,disabled:n.isPending||r,selected:o[t]??[],onSelect:i=>{r||(a?n.send(ii(e,i)):c(t,i))}},e.id??t))}),a?p?(0,J.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mt-3 text-[11.5px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,J.jsx)(F,{size:`sm`,disabled:n.isPending||r||!u,onClick:f,children:p?`Send answer & reopen`:`Send answer`}),(0,J.jsx)(`span`,{"data-slot":p?`ask-resume-hint`:`ask-hint`,className:`text-[11.5px] text-soft-foreground`,children:p?`the session has ended — sending reopens it`:`${i.length>1?`answer each question`:`pick one or more`} — or type a reply below`})]}),!a&&d.length>0?(0,J.jsxs)(`p`,{"data-slot":`ask-unanswered`,className:`mt-2 text-[11.5px] text-soft-foreground`,children:[`unanswered: `,d.join(`, `)]}):null,n.blockedBy===`provider`?(0,J.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:n.reason}),(0,J.jsx)(O,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,n.blockedBy===`no-session`?(0,J.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:n.reason}):null,n.error?(0,J.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:n.error}):null]})}function si({question:e,disabled:t,selected:n,onSelect:r}){let i=e.multiSelect===!0,a=e=>{if(!i){r([e]);return}r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,J.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-md bg-primary px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary-foreground`,children:e.header}),i?(0,J.jsx)(`span`,{className:`ml-auto text-[10.5px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,J.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map(e=>{let r=n.includes(e.label);return(0,J.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>a(e.label),className:P(`flex w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-primary/50 hover:bg-primary/[0.06] disabled:pointer-events-none disabled:opacity-50`,r?`border-primary/60 bg-primary/[0.06]`:`border-border bg-card`),children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13.5px] font-semibold text-foreground`,children:[i?(0,J.jsx)(`span`,{"aria-hidden":!0,className:P(`flex size-4 shrink-0 items-center justify-center rounded border text-[10px]`,r?`border-primary bg-primary text-primary-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,J.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,J.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})})]})}var ci=2e3;function li(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{lastEnd:t,lastStart:n}}function ui(e){let{lastEnd:t,lastStart:n}=li(e);return t>n?t:0}function di(e){let{lastEnd:t,lastStart:n}=li(e);return n>t?n:0}function fi(e,t){let n=g(),r=(0,K.useMemo)(()=>ui(t),[t]),i=(0,K.useMemo)(()=>di(t),[t]),a=e?.id,o=e?.status;(0,K.useEffect)(()=>{if(a===void 0||o===void 0||o===`queued`||!(o===`running`||o===`waiting`?r>0:i>0))return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:b.runs.detail(a)}),n.invalidateQueries({queryKey:b.runs.list()})},ci);return()=>clearTimeout(e)},[r,i,a,o,n])}function pi(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function mi(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function hi(e,t,n=!1){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return n?{state:`closed`,tone:`dim`,label:`Session closed — waiting for your answer, which reopens it`}:{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function gi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`string`?e:void 0}function _i(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function vi(e){return e===`claude`||e===`codex`||e===`junie`||e===`opencode`||e===`cursor`||e===`pi`||e===`copilot`?e:void 0}var yi=e=>gi(e)&&typeof e.header==`string`&&Array.isArray(e.options);function bi(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);return t&&(n=n.replace(/\s*CEZ:ASK[ \t]+\{[\s\S]*\}\s*$/,``)),n.includes(`CEZ:`)?n.split(`
9
+ `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
10
+ `):n}function xi(e){let t=e=>bi(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function Si(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var Ci=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,wi=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ti(e){if(!gi(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!gi(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:wi.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function Ei(e,t={}){let n=[],r=new Map,i,a=0,o,s,c=e=>{a+=1;let t={id:e===void 0?`turn-fallback-${a}`:`turn-seq-${e}`,entries:[],v2Items:!1};return n.push(t),t},l=()=>n.at(-1)??c(),u=(e,t)=>B(e.stepId,t),d=(e,t,n)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&r.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=r.get(n);if(a&&a.turn===e){a.entry.entry=i,r.set(n,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),r.set(n,{turn:e,entry:o})};for(let t of e)switch(s=_i(t.ts)??s,t.type){case`user-message`:{let e=$(t.text)??``;o&&!o.resolved&&(o.resolved=!0,e!==``&&(o.answer=e),o=void 0);let n=c(t.seq),r=_i(t.ts);n.userMessage={text:e,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...r===void 0?{}:{ts:r}},r!==void 0&&(n.startedAt=r);break}case`turn.started`:{let e=$(t.turnId),r=n.at(-1),i=r&&r.turnId===void 0&&!r.v2Items?r:c(t.seq);i.turnId=e;let a=_i(t.ts);i.startedAt===void 0&&a!==void 0&&(i.startedAt=a);break}case`turn.completed`:{let e=$(t.turnId),r;for(let t=n.length-1;t>=0&&!r;--t)n[t].turnId===e&&(r=n[t]);let i=r??n.at(-1);if(i){let e=_i(t.ts);i.completed={stopReason:$(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...e===void 0?{}:{ts:e}}}break}case`item.started`:case`item.updated`:case`item.completed`:{if(!gi(t.item))break;let e=t.item.kind,n=t.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof n!=`string`||n===``)break;let i=t.item,a=u(t,i.id);d(r.get(a)?.turn??l(),i,a);break}case`item.delta`:{let e=$(t.itemId)??``,n=r.get(u(t,e)),i=$(t.delta)??``;if(!n||i===``||!Ci(n.entry.entry))break;let a=n.entry.entry;t.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+i:t.field!==`output`&&a.kind!==`tool`&&(a.text+=i);break}case`text`:{let e=l(),n=$(t.text)??``;if(n===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:n}});break}case`tool-call`:{let e=l();if(e.v2Items)break;let n=$(t.tool)??`Tool`;if(Di.has(n))break;let i=it(n,t.input);if(i.toolKind===`plan`){let n=Ti(t.input);n!==void 0&&(e.planEntries=n)}let a={kind:`tool`,id:$(t.id)??`v1:${t.seq}`,name:n,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},o={origin:`v1`,entry:a};e.entries.push(o),r.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=r.get($(t.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let n=e.entry.entry;if(n.kind!==`tool`)break;n.status=`completed`,n.output=Si(t.result);break}case`note`:case`lifecycle`:{let e=$(t.message)??``;if(e===``)break;let n=t.tone===`danger`?`danger`:`dim`;l().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:n}});break}case`error`:{let e=$(t.message)??``;if(e===``)break;l().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=$(t.message)??``;if(e===``)break;l().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${t.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(t.status!==`failed`)break;let e=$(t.error)?` — ${$(t.error)}`:``;l().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:`step ${$(t.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=$(t.command)??`check`,n=typeof t.exitCode==`number`?t.exitCode:-1,r={kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:n===0?`completed`:`failed`,output:$(t.text)??``,exitCode:n};l().entries.push({origin:`meta`,entry:r});break}case`provider-auth-required`:{let e=vi(t.provider),n=$(t.authFailureId);if(e===void 0||n===void 0||n.length<1||n.length>128)break;l().entries.push({origin:`meta`,entry:{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:e,authFailureId:n}});break}case`image`:{let e=$(t.url);if(e===void 0)break;let n={kind:`image`,id:`v1:${t.seq}`,url:e},r=$(t.name);r!==void 0&&(n.name=r),l().entries.push({origin:`meta`,entry:n});break}case`plan.updated`:Array.isArray(t.entries)&&(l().planEntries=t.entries);break;case`session.ended`:i={reason:$(t.reason)??`end_turn`,...$(t.message)===void 0?{}:{message:$(t.message)}};break;case`ask.requested`:{let e=$(t.requestId);if(e===void 0||!Array.isArray(t.questions))break;let n=t.questions,r=n.every(yi)?n:n.filter(yi);if(r.length===0)break;let i={kind:`ask`,id:e,questions:r,resolved:!1,...t.source===`workflow`?{fromWorkflow:!0}:{}};l().entries.push({origin:`meta`,entry:i}),o=i;break}case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of n){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add(bi(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has(bi(e.entry.text,!0).trim()))),xi(e))}return{turns:n.map((e,r)=>{let i=e.entries.some(({entry:e})=>e.kind===`ask`),a=t.activeTurn===!0&&r===n.length-1;return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:bi(e.text,i||a)}:e)}}),...i===void 0?{}:{sessionEnded:i},...s===void 0?{}:{lastEventAt:s}}}var Di=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Oi(){let{id:e}=r(),t=v(e),n=Ct(e),i=t.data?.status,a=(0,K.useMemo)(()=>Ei(n.visibleEvents,{activeTurn:i===`running`}),[n.visibleEvents,i]),o=(0,K.useMemo)(()=>Ei(n.currentEvents,{activeTurn:i===`running`}),[n.currentEvents,i]),c=(0,K.useRef)(void 0);(0,K.useEffect)(()=>{c.current!==e&&(c.current=void 0)},[e]);let l=(0,K.useCallback)(e=>{c.current=e},[]),{mutate:u}=s();if((0,K.useEffect)(()=>{t.data&&c.current!==t.data.id&&ae(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived,e]),fi(t.data,n.visibleEvents),t.isPending)return(0,J.jsx)(Pe,{});if(t.isError){let e=t.error instanceof d&&t.error.status===404;return(0,J.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,J.jsx)(Me,{icon:e?(0,J.jsx)(Ie,{}):(0,J.jsx)(Ne,{}),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,J.jsx)(F,{asChild:!0,variant:`outline`,children:(0,J.jsx)(O,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,J.jsx)(Pe,{}):(0,J.jsx)(ki,{run:t.data,thread:a,currentThread:o,history:n,onMarkedUnread:l})}function ki({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){let a=hi(e.status,e.error,c(e)),s=(0,K.useCallback)(()=>i?.(e.id),[i,e.id]),l=pi(n),u=o(e),d=l!==void 0&&l.length>0?ar(l):void 0,p=e.status===`running`||e.status===`waiting`,g=e.status===`queued`,v=We(e),y=!p&&!g&&v.available,b=y&&v.canContinue,S=!p&&e.status!==`queued`,C=(0,K.useMemo)(()=>Un(n.turns,S),[n.turns,S]),T=(0,K.useMemo)(()=>Wn(n.turns),[n.turns]),[E,D]=(0,K.useState)(void 0),[O,k]=(0,K.useState)(e.id);O!==e.id&&(k(e.id),D(void 0));let j=(0,K.useMemo)(()=>E===void 0?void 0:Xn(n.turns,E,S),[n.turns,E,S]),M=(0,K.useMemo)(()=>E===void 0?[]:Zn(n.turns,E),[n.turns,E]),F=we(e.id,`composer`),I=Ze(e.id),{mutateAsync:L}=f(e.id),{mutateAsync:R}=x(e.id),{mutateAsync:z}=w(e.id),B=(0,K.useMemo)(()=>g?{onEditTask:async e=>{await L({task:e})},onEditMessage:(e,t)=>R({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>z(e).then(()=>void 0)}:void 0,[g,L,R,z]),ee=(0,K.useMemo)(()=>vr(e,t),[e,t]),te=(0,K.useMemo)(()=>xr(ee,e.id),[ee,e.id]),ne=(0,K.useCallback)(t=>(0,J.jsx)(ai,{ask:t,run:e}),[e]),re=(0,K.useMemo)(()=>{if(B===void 0)return;let t={task:{onEdit:B.onEditTask,editLabel:`Edit the prompt`,draftSurface:`task-prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>B.onEditMessage(n.id,e),onRemove:()=>B.onRemoveMessage(n.id),draftSurface:`message:${n.id}`};return t},[B,e.queuedMessages]),ie=A(e,m()),{search:ae}=h(),oe=Ut(ae,te.length),V=mr(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:te.map(({key:e})=>e)});return de(V.restickIfStuck),(0,J.jsxs)(`div`,{"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(Te,{run:e,planTally:d,onMarkedUnread:s,continuationEngine:b?v.pills:void 0}),(0,J.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-3 py-3 md:gap-3.5 md:px-6 md:py-5`,children:[r?(0,J.jsx)(Ni,{hasOlder:r.hasOlder,loading:r.isFetchingOlder,error:r.olderError,fallback:r.fallback,retainedPages:r.retainedPages,onLoad:V.loadOlder}):null,(0,J.jsx)(Sr,{runId:e.id,viewId:`main`,sections:ee,mode:`document`,renderAsk:ne,messageActions:re,scrollControls:V,renderMode:oe,rowModels:te}),t.turns.length===0?e.status===`queued`?(0,J.jsx)(Fi,{run:e}):(0,J.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,J.jsx)(xn,{since:Pi(e,n),lastActivityAt:n.lastEventAt}):null,(0,J.jsx)(Tt,{run:e}),a&&a.state===`closed`?(0,J.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":a.state,className:P(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,a.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[(0,J.jsx)(ji,{label:a.label,onContinue:y?()=>v.continueWith(``,[]):void 0,blockedReason:b?void 0:v.providerPending?`Checking the agent provider…`:v.reason??`Connect an agent provider to continue.`}),N(_(e))?(0,J.jsx)(`a`,{"data-slot":`pr-link`,href:_(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,N(ie)?(0,J.jsx)(`a`,{"data-slot":`issue-link`,href:ie,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,J.jsx)(qr,{run:e,diffComments:I}):null]}),(0,J.jsx)(Qr,{status:e.status}),(0,J.jsx)(Wr,{runId:e.id,renderAsk:ne,agent:j,entries:M,onClose:()=>D(void 0)}),(0,J.jsxs)(qe,{overlay:V.pillVisible?(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 -top-12 flex justify-center`,children:(0,J.jsx)(_r,{onJump:V.jumpToLatest})}):null,children:[(0,J.jsx)(er,{runId:e.id,agents:C,onSelect:D},`agents:${e.id}`),(0,J.jsx)(ur,{skills:T}),l!==void 0&&l.length>0?(0,J.jsx)(sr,{runId:e.id,entries:l,settled:S},e.id):null,(0,J.jsx)(wt,{run:e}),u?(0,J.jsxs)(`div`,{"data-slot":`budget-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(H,{tone:`pending`,pulse:!0}),`Budget reached — spent $`,u.spent.toFixed(2),` of $`,u.ceiling.toFixed(2),`; send a message to continue.`,e.status===`waiting`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,J.jsx)(Mi,{runId:e.id})]}):null]}):e.status===`waiting`?(0,J.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(H,{tone:`pending`,pulse:!0}),`The agent is paused, waiting for your reply`,(0,J.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,J.jsx)(Mi,{runId:e.id})]}):null,g?(0,J.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(H,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,(0,J.jsx)(Xe,{run:e,draft:F,diffComments:I,continueAction:v,getMentionCandidates:()=>mi(t)})]})]})}var Ai=/— continue to /i;function ji({label:e,onContinue:t,blockedReason:n}){let[r,i]=(0,K.useState)(!1),a=t?Ai.exec(e):null;if(!t||!a)return(0,J.jsx)(`span`,{children:e});let o=e.slice(0,a.index),s=e.slice(a.index+a[0].length);return(0,J.jsxs)(`span`,{children:[o,`—`,` `,(0,J.jsx)(`button`,{type:`button`,"data-slot":`footer-continue`,disabled:r||n!==void 0,title:n??`Reopen the session and pick up where it stopped`,onClick:()=>{i(!0),t().catch(e=>y(e instanceof Error?e.message:String(e),{tone:`danger`})).finally(()=>i(!1))},className:`rounded-sm font-semibold underline underline-offset-2 hover:brightness-125 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-not-allowed disabled:no-underline disabled:opacity-60`,children:`Continue`}),` `,`to `,s]})}function Mi({runId:e}){let t=Ce(e);return(0,J.jsx)(`button`,{type:`button`,"data-slot":`end-session`,title:`Close the session — the task finishes (or goes to review if it changed files)`,disabled:t.isPending,onClick:()=>t.mutate(),className:`rounded-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:opacity-60`,children:`End session`})}function Ni({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,J.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,J.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,J.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,J.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,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function Pi(e,t){let n=t.turns.at(-1);return n===void 0?e.startedAt:n.completed===void 0?n.startedAt??e.startedAt:n.completed.ts??e.startedAt}function Fi({run:e}){let t=ie(S().data??[],e.id);return(0,J.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,J.jsx)(H,{tone:`pending`,pulse:!0}),(0,J.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,J.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Oi as TaskThreadRoute};
@@ -1 +1 @@
1
- import{F as e}from"./button-CjSjKnkd.js";var t=e(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),n=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),r=e(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),i=e(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]);export{t as i,r as n,n as r,i as t};
1
+ import{F as e}from"./button-BNnH7COh.js";var t=e(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),n=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),r=e(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),i=e(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]);export{t as i,r as n,n as r,i as t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{F as n,r}from"./button-BNnH7COh.js";var i=n(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),a=n(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),o=n(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);e();var s=t();function c({className:e,...t}){return(0,s.jsx)(`textarea`,{"data-slot":`textarea`,className:r(`flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-card px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm`,e),...t})}export{i,o as n,a as r,c as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{F as t}from"./button-BNnH7COh.js";import{r as n,t as r}from"./centered-state-sEYB3bgq.js";var i=t(`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`}]]),a=e();function o(){return(0,a.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,a.jsx)(r,{icon:(0,a.jsx)(n,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}export{i as n,o as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{P as n,r}from"./button-CjSjKnkd.js";e();var i=t(),a=n(`inline-block size-[7px] shrink-0 rounded-full`,{variants:{tone:{success:`bg-success`,pending:`bg-pending`,danger:`bg-danger`,violet:`bg-violet`,neutral:`bg-soft-foreground`},pulse:{true:`animate-pulse`,false:``}},defaultVariants:{tone:`neutral`,pulse:!1}});function o({className:e,tone:t=`neutral`,pulse:n=!1,...o}){return(0,i.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,className:r(a({tone:t,pulse:n,className:e})),...o})}function s(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=Math.max(0,(t-n)/1e3);return r<60?`${Math.floor(r)}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function c(e){return!Number.isFinite(e)||e<=0?`0`:e>=1e6?`${(Math.floor(e/1e5)/10).toFixed(1)}M`:e>=1e3?`${(Math.floor(e/100)/10).toFixed(1)}k`:String(Math.floor(e))}function l(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}export{o as i,c as n,s as r,l as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{P as n,r}from"./button-BNnH7COh.js";e();var i=t(),a=n(`inline-block size-[7px] shrink-0 rounded-full`,{variants:{tone:{success:`bg-success`,pending:`bg-pending`,danger:`bg-danger`,violet:`bg-violet`,neutral:`bg-soft-foreground`},pulse:{true:`animate-pulse`,false:``}},defaultVariants:{tone:`neutral`,pulse:!1}});function o({className:e,tone:t=`neutral`,pulse:n=!1,...o}){return(0,i.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,className:r(a({tone:t,pulse:n,className:e})),...o})}function s(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=Math.max(0,(t-n)/1e3);return r<60?`${Math.floor(r)}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function c(e){return!Number.isFinite(e)||e<=0?`0`:e>=1e6?`${(Math.floor(e/1e5)/10).toFixed(1)}M`:e>=1e3?`${(Math.floor(e/100)/10).toFixed(1)}k`:String(Math.floor(e))}function l(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}export{o as i,c as n,s as r,l as t};