@hearsay-tools/squawk 0.19.0-pr4422.8666 → 0.19.0-pr4422.8708

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 (128) hide show
  1. package/dist/automations/tools.d.ts +8 -8
  2. package/dist/ci-wait/controller.d.ts +7 -7
  3. package/dist/contract/index.js +55 -14
  4. package/dist/contract/runs.d.ts +50 -0
  5. package/dist/contract/workspace-events.d.ts +18 -0
  6. package/dist/delegation/routes.d.ts +65 -65
  7. package/dist/delegation/transport.d.ts +14 -14
  8. package/dist/preview/chromium.d.ts +3 -2
  9. package/dist/preview/chromium.js +5 -1
  10. package/dist/preview/chromium.js.map +1 -1
  11. package/dist/runs/run-database.d.ts +5 -0
  12. package/dist/runs/run-database.js +5 -0
  13. package/dist/runs/run-database.js.map +1 -1
  14. package/dist/runs/run-queries.d.ts +9 -0
  15. package/dist/runs/run-queries.js +43 -6
  16. package/dist/runs/run-queries.js.map +1 -1
  17. package/dist/runs/store.js +1 -0
  18. package/dist/runs/store.js.map +1 -1
  19. package/dist/runs/transcript-facts-queue.d.ts +9 -1
  20. package/dist/runs/transcript-facts-queue.js +43 -10
  21. package/dist/runs/transcript-facts-queue.js.map +1 -1
  22. package/dist/runs/transcript-facts-sidecar.d.ts +22 -0
  23. package/dist/runs/transcript-facts-sidecar.js +58 -0
  24. package/dist/runs/transcript-facts-sidecar.js.map +1 -0
  25. package/dist/runs/transcript-facts-topic.d.ts +2 -0
  26. package/dist/runs/transcript-facts-topic.js +8 -10
  27. package/dist/runs/transcript-facts-topic.js.map +1 -1
  28. package/dist/runs/transcript-facts-worker.d.ts +7 -2
  29. package/dist/runs/transcript-facts-worker.js +8 -5
  30. package/dist/runs/transcript-facts-worker.js.map +1 -1
  31. package/dist/runs/transcript-facts.d.ts +4 -0
  32. package/dist/runs/transcript-facts.js +36 -16
  33. package/dist/runs/transcript-facts.js.map +1 -1
  34. package/dist/server/automations-routes.d.ts +150 -150
  35. package/dist/server/live-routes.d.ts +6 -6
  36. package/dist/server/models-routes.d.ts +12 -12
  37. package/dist/server/project-settings-routes.d.ts +107 -107
  38. package/dist/server/providers-routes.d.ts +57 -57
  39. package/dist/server/repo-routes.d.ts +34 -34
  40. package/dist/server/runner-install-routes.d.ts +10 -10
  41. package/dist/server/runners-routes.d.ts +10 -10
  42. package/dist/server/runs-routes.d.ts +24 -16
  43. package/dist/server/server.d.ts +1622 -1598
  44. package/dist/server/workspace-live-routes.d.ts +6 -6
  45. package/dist/server/workspace-routes.d.ts +92 -84
  46. package/package.json +4 -4
  47. package/scripts/measure-transcript-facts-health.mjs +10 -5
  48. package/scripts/measure-transcript-facts-lag.mjs +11 -2
  49. package/scripts/mock-ci-tool.mjs +4 -5
  50. package/scripts/transcript-facts-timing.mjs +10 -0
  51. package/web/dist/assets/{accounts-section-DrBRvg0M.js → accounts-section-De2qXAo-.js} +1 -1
  52. package/web/dist/assets/activity-motion-EJBR3wlq.js +1 -0
  53. package/web/dist/assets/{activity-route-CRu58Zj9.js → activity-route-6cQ_MX2v.js} +1 -1
  54. package/web/dist/assets/{agent-config-section-DXLXyPzF.js → agent-config-section-DFP2-YWs.js} +1 -1
  55. package/web/dist/assets/{agent-defaults-section-MHwKLUxx.js → agent-defaults-section-D88m66PJ.js} +1 -1
  56. package/web/dist/assets/{appearance-Dk8ikc1j.js → appearance-BwV8iZFM.js} +1 -1
  57. package/web/dist/assets/{archive-on-merge-field-CRGCTE05.js → archive-on-merge-field-BzFhSzxv.js} +1 -1
  58. package/web/dist/assets/attention--Y0CyzCN.js +1 -0
  59. package/web/dist/assets/{automations-route-2Z1J6aVz.js → automations-route-Cuz2CxlC.js} +2 -2
  60. package/web/dist/assets/commit-list-D8yY5bIe.js +1 -0
  61. package/web/dist/assets/diff-BBr7hIpt.js +3 -0
  62. package/web/dist/assets/{diff-controls-U3q_bktr.js → diff-controls-PEQLG-Zu.js} +1 -1
  63. package/web/dist/assets/diff-stat-U7DT4Ilj.js +1 -0
  64. package/web/dist/assets/{diff-view-BaEIMlyb.js → diff-view-Dma7qveY.js} +1 -1
  65. package/web/dist/assets/{file-preview-LgaV6Wwo.js → file-preview-DXB5mwQq.js} +1 -1
  66. package/web/dist/assets/{folder-browser-D_V807qp.js → folder-browser-CF2Sk1aR.js} +1 -1
  67. package/web/dist/assets/git-toolbar-dRjJ3sJQ.js +1 -0
  68. package/web/dist/assets/github-CLbTpdZ7.js +1 -0
  69. package/web/dist/assets/{global-activity-route-CrRAIAo1.js → global-activity-route-BXwZUqR8.js} +2 -2
  70. package/web/dist/assets/image-preview-2S3PEy8S.js +1 -0
  71. package/web/dist/assets/index-1TLdjVro.css +1 -0
  72. package/web/dist/assets/index-7Rg7tdSP.js +21 -0
  73. package/web/dist/assets/{label-C6BpWk0J.js → label-Bgcri58t.js} +1 -1
  74. package/web/dist/assets/{markdown-BVqO9ORd.js → markdown-gNAPnLDC.js} +1 -1
  75. package/web/dist/assets/{notifications-section-CliGeYkh.js → notifications-section-CnjarooH.js} +1 -1
  76. package/web/dist/assets/{open-in-menu-BkmmqWdB.js → open-in-menu-Qylys2X_.js} +1 -1
  77. package/web/dist/assets/{preview-pane-connected-Bg56dRpV.js → preview-pane-connected-CimzK7Qz.js} +2 -2
  78. package/web/dist/assets/{project-location-Z28U6-d1.js → project-location-n15GhUq1.js} +1 -1
  79. package/web/dist/assets/{project-router-B8blqSVo.js → project-router-CT6gVIcC.js} +1 -1
  80. package/web/dist/assets/{projects-section-DSNxCSOR.js → projects-section-DiaRaoyV.js} +1 -1
  81. package/web/dist/assets/{prompt-templates-section-BBGVLRbE.js → prompt-templates-section-5UJStA2u.js} +1 -1
  82. package/web/dist/assets/{queries-BwJVP1so.js → queries-BddxDJyD.js} +1 -1
  83. package/web/dist/assets/{reference-chip-uLQTF-sm.js → reference-chip-BGFxuvs6.js} +1 -1
  84. package/web/dist/assets/{remote-settings-notice-7BteeZ5o.js → remote-settings-notice-ihbrhzlZ.js} +1 -1
  85. package/web/dist/assets/repo-git-DaKHEjDf.js +1 -0
  86. package/web/dist/assets/{report-reader-Be9J9B79.js → report-reader-8B7MnBnV.js} +1 -1
  87. package/web/dist/assets/{report-selection-DBM7S3ha.js → report-selection-BwiY8hK3.js} +1 -1
  88. package/web/dist/assets/{reports-BOiZGsQR.js → reports-BeOzwtBO.js} +1 -1
  89. package/web/dist/assets/{resources-section-B3kPFCJY.js → resources-section-D2tex4pF.js} +1 -1
  90. package/web/dist/assets/review-panel-YwUoKsbu.js +8 -0
  91. package/web/dist/assets/{run-detail-refresh-YR2-iM4z.js → run-detail-refresh-C8P2J7Wq.js} +1 -1
  92. package/web/dist/assets/{run-header-BG-RicJl.js → run-header-CkhPOV1B.js} +2 -2
  93. package/web/dist/assets/{select-Be4wVHHG.js → select-BXpAjbYk.js} +1 -1
  94. package/web/dist/assets/{session-context-section-DdCeADhA.js → session-context-section-DkhGlKdR.js} +2 -2
  95. package/web/dist/assets/{settings-agent-picker-C4hz36AY.js → settings-agent-picker-3cUJmNQz.js} +1 -1
  96. package/web/dist/assets/{settings-shell-BluR2G4L.js → settings-shell-D--QpDPG.js} +1 -1
  97. package/web/dist/assets/{sidebar-section-Bo1FJw3L.js → sidebar-section-BydWRh8S.js} +1 -1
  98. package/web/dist/assets/{skills-DWVky-g5.js → skills-CbEyPyvn.js} +1 -1
  99. package/web/dist/assets/{tab-link-BkHBgpdC.js → tab-link-DE6t7XkG.js} +1 -1
  100. package/web/dist/assets/task-changes-BXDJmZkO.js +1 -0
  101. package/web/dist/assets/task-commits-B4uUhWjt.js +1 -0
  102. package/web/dist/assets/{task-files-BtAxAAcl.js → task-files-vOSCBpIt.js} +1 -1
  103. package/web/dist/assets/{task-github-item-DFD4xHYk.js → task-github-item-BIaOF-Ea.js} +1 -1
  104. package/web/dist/assets/{task-groups-BSovus2j.js → task-groups-CHHLB77I.js} +1 -1
  105. package/web/dist/assets/task-thread-MKnHdrU1.js +2 -0
  106. package/web/dist/assets/{tasks-table-C-wxALy6.js → tasks-table-5GNEZlxs.js} +1 -1
  107. package/web/dist/assets/{thread-state-DyYOz-Ad.js → thread-state-BtUboBbd.js} +1 -1
  108. package/web/dist/assets/{toaster-UvSCLhYx.js → toaster-C-xqAWVX.js} +2 -2
  109. package/web/dist/assets/use-hand-to-agent-state-BwQ45AKw.js +1 -0
  110. package/web/dist/assets/{workflows-C4UY4ka5.js → workflows-DUoxhR8h.js} +3 -3
  111. package/web/dist/assets/{workspace-tools-BMtjV-oC.js → workspace-tools-dwQmpL6C.js} +1 -1
  112. package/web/dist/assets/{worktrees-section-Bntdbzrl.js → worktrees-section-B9LR3yvO.js} +1 -1
  113. package/web/dist/index.html +16 -15
  114. package/web/dist/assets/activity-motion-DyczKxjj.js +0 -1
  115. package/web/dist/assets/attention-CXG_AzDe.js +0 -1
  116. package/web/dist/assets/commit-list-CjmYvVCK.js +0 -1
  117. package/web/dist/assets/diff-B1RHxCxU.js +0 -3
  118. package/web/dist/assets/git-toolbar-DyQaOcLy.js +0 -1
  119. package/web/dist/assets/github-DYLq16Wk.js +0 -1
  120. package/web/dist/assets/image-preview-OjGspLQY.js +0 -1
  121. package/web/dist/assets/index-AgYIT7cV.js +0 -21
  122. package/web/dist/assets/index-DTMSoiHJ.css +0 -1
  123. package/web/dist/assets/repo-git-DiNgzGWX.js +0 -1
  124. package/web/dist/assets/review-panel-CQp83gYh.js +0 -8
  125. package/web/dist/assets/task-changes-2yAaEJQ_.js +0 -1
  126. package/web/dist/assets/task-commits-02w8Ivwi.js +0 -1
  127. package/web/dist/assets/task-thread-Ck75x2Rd.js +0 -2
  128. package/web/dist/assets/use-hand-to-agent-state-BfQx2nM5.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as v}from"./queries-BwJVP1so.js";import{Fn as y,It as b,L as x,R as ee,ct as S,f as C,hi as w,l as te,n as T}from"./toaster-UvSCLhYx.js";import{Z as ne}from"./live-protocol-DMhTnCmf.js";import{g as re,h as ie}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as E}from"./tasks-table-C-wxALy6.js";import{A as D,C as ae,E as oe,F as se,J as ce,M as le,X as ue,Y as de,at as fe,j as pe,n as me,ot as O,s as he,u as ge,v as _e,x as ve}from"./design-icons-CzEoMH9c.js";import{t as ye}from"./createLucideIcon-BHp8sXmF.js";import{n as be,t as xe}from"./circle-x-7nTlobAF.js";import{_ as Se}from"./nav-row-styles-DKeXbc4N.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-DyQaOcLy.js";import{t as k}from"./info-DA1x_4bz.js";import{t as Ee}from"./loader-circle-CPBhhDbB.js";import{n as De,r as Oe}from"./diff-controls-U3q_bktr.js";import{c as ke,i as Ae,t as je}from"./reference-chip-uLQTF-sm.js";import{t as A}from"./button-B7MKxYjT.js";import{i as j,l as Me,p as Ne,r as Pe,t as Fe}from"./dropdown-menu-4e2iKSMT.js";import{t as M}from"./project-router-B8blqSVo.js";import{t as Ie}from"./status-dot-BRzVlF2X.js";import{a as N,o as Le}from"./format-BU7D3IfE.js";import{d as Re,n as ze,o as P,s as Be,t as Ve,u as He}from"./page-shell-7pLJMOgh.js";import{t as F}from"./centered-state-V15AR_qo.js";import{$n as Ue,At as We,Bt as I,Dt as Ge,Et as Ke,Ft as qe,Gt as L,Ht as R,It as Je,Kt as z,Ln as B,Lt as Ye,Mt as Xe,Nt as Ze,Ot as Qe,Pt as V,Rt as $e,T as H,Ut as U,Vt as W,Wn as et,Wt as G,Zn as tt,Zt as K,jt as nt,kt as rt,pn as it,qt as q,w as at,zt as ot}from"./index-AgYIT7cV.js";import{t as st}from"./markdown-BBDDg-4t.js";import{t as ct}from"./diff-B1RHxCxU.js";import{t as lt}from"./change-counts-CW7O8g5Y.js";import{n as ut,r as dt}from"./commit-list-CjmYvVCK.js";var J=e(t(),1);function ft(e,t){let n=w(t),r=n.getQueryCache();return J.useSyncExternalStore(J.useCallback(e=>r.subscribe(ne.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var pt=ye(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),mt=ye(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Y=n();function ht(){let e=r(),t=o(),n=w(),i=ft({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Ke(e,s,`screen`);return(0,Y.jsx)(He,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,Y.jsx)(Be,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,Y.jsx)(de,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,Y.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,Y.jsx)(`div`,{className:`mb-[16px]`,children:(0,Y.jsx)(rt,{scope:e,repo:s,info:s.info,variant:`screen`},e)}):t.isPending?(0,Y.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,Y.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,Y.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,Y.jsx)(Ge,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function gt({entry:e}){return e.keptReason?(0,Y.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function _t({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=v(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=w(),f=d({mutationFn:e=>te({name:e},n),onSuccess:async e=>{T(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>nt(t,n,e.branch))},onError:e=>T(e.message,{tone:`danger`})}),[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(``),y=h.trim().toLowerCase(),b=X(e,c.data?.branches),x=y?b.filter(e=>e.toLowerCase().includes(y)):b;return(0,Y.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Y.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Y.jsxs)(`label`,{className:`relative block`,children:[(0,Y.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,Y.jsx)(B,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,Y.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[x.map(e=>{let n=e===t.branch,r=l.get(e);return(0,Y.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,Y.jsx)(M,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,Y.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,Y.jsx)(St,{entry:r}):null]}),r?(0,Y.jsx)(gt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,Y.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,Y.jsxs)(A,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,Y.jsx)(D,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),x.length===0?(0,Y.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Y.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,Y.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Y.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,Y.jsx)(`span`,{className:`font-mono text-[11px] text-foreground`,children:t.branch}),`.`]}),(0,Y.jsx)(B,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-muted-foreground/70`,value:p,onChange:e=>m(e.target.value)}),(0,Y.jsxs)(A,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||f.isPending,children:[(0,Y.jsx)(ce,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Y.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,Y.jsx)(vt,{}):null]})}function vt(){let e=p({limit:20});return(0,Y.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,Y.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,Y.jsx)(yt,{pr:e},e.number))}):(0,Y.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function yt({pr:e}){let t=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(se,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Y.jsx)(bt,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Y.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,Y.jsx)(`span`,{className:n,children:t})})}function bt({checks:e}){let t=e===`passing`?be:e===`failing`?xe:tt;return(0,Y.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,Y.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var xt={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function St({entry:e}){return(0,Y.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-[11px] leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:xt[e.class]})}function X(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Ct(){let e=c(),t=K(),[n,r]=(0,J.useState)(`unified`),[i,a]=(0,J.useState)(!0),[o,s]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),f=e.isError&&e.error instanceof y&&e.error.status===409,p=e.data?.files??[],m=(0,J.useMemo)(()=>we(p),[p]),h=(0,J.useMemo)(()=>p.some(st),[p]),g=t?n:`unified`;return(0,Y.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,Y.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,Y.jsx)(F,{icon:f?(0,Y.jsx)(ae,{size:16}):(0,Y.jsx)(O,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,Y.jsx)(F,{icon:(0,Y.jsx)(ae,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,Y.jsx)(Te,{stat:e.data.stat}):null,(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h?(0,Y.jsx)(Oe,{preview:o,onPreviewChange:s}):null,(0,Y.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Y.jsx)(De,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:1rem] md:flex-row md:items-start`,children:[(0,Y.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[288px]`,children:[(0,Y.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Y.jsx)(Ce,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,Y.jsx)(ct,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function wt({repo:e,info:t}){let{sha:n}=ie(),r=e.log,i=(0,J.useMemo)(()=>ot(r),[r]);if(n)return(0,Y.jsx)(Dt,{sha:n});let a=qe(e,t),o=a&&a.behind>0?(0,Y.jsx)(Et,{info:t,tracking:a}):null;return r.length===0?(0,Y.jsxs)(Y.Fragment,{children:[o?(0,Y.jsx)(`div`,{children:o}):null,(0,Y.jsx)(F,{icon:(0,Y.jsx)(pe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,Y.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[o,i.map(e=>(0,Y.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,Y.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Y.jsxs)(M,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Y.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,Y.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ut,{sha:e.hash}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,Y.jsx)(`span`,{title:$e(e.when,e.at),children:Ye(e.when,e.at)})]})]})]}),(0,Y.jsx)(Tt,{source:e.source})]},e.hash))})]},e.label))]})}function Tt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-[11.5px] text-muted-foreground md:flex`;return e?(0,Y.jsxs)(M,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(le,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,Y.jsx)(he,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,Y.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function Et({info:e,tracking:t}){let n=Xe(r(),e),i=(0,J.useRef)(null);return(0,Y.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,Y.jsx)(pt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,Y.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,Y.jsx)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Y.jsx)(me,{"aria-hidden":`true`}),`Pull`]}),(0,Y.jsx)(We,{checkout:n,returnFocus:i})]})}function Dt({sha:e}){return(0,Y.jsx)(dt,{commit:s(e),sha:e,backTo:K()?`/git`:Ze,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-9`})}var Z=`Squash-merged branches may show as not landed without GitHub`;function Ot(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function kt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var At={done:`success`,failed:`danger`,cancelled:`neutral`};function jt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,J.useState)(null);if(e.isPending)return(0,Y.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,Y.jsx)(F,{icon:(0,Y.jsx)(O,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Ot(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=kt(e.data.branches),u=l>0?(0,Y.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,Y.jsx)(k,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,Y.jsx)(M,{to:V.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,Y.jsxs)(Ae,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,Y.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,Y.jsx)(Mt,{}),u,s.length===0?(0,Y.jsx)(Ve,{icon:(0,Y.jsx)(et,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Y.jsx)(M,{to:V.cleanup,children:`Check cleanup`})}),(0,Y.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Y.jsx)(M,{to:`/`,children:`View tasks`})})]})}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Y.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{children:e.note})]}):null]}),(0,Y.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,Y.jsx)(Nt,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,Y.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,Y.jsx)(k,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,Y.jsx)(ze,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,Y.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Y.jsx)(M,{to:V.cleanup,children:`Open cleanup`})})}):null]})]}),(0,Y.jsx)(Rt,{entry:a,onClose:()=>o(null)})]})}function Mt({className:e}){return(0,Y.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,Y.jsx)(k,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),Z,`.`]})}function Nt({entry:e,finishedAt:t,onDelete:n}){return(0,Y.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Y.jsx)(It,{entry:e,finishedAt:t}),(0,Y.jsx)(Pt,{entry:e}),(0,Y.jsx)(Ft,{entry:e,onDelete:n})]})}function Pt({entry:e}){return(0,Y.jsx)(Y.Fragment,{children:e.pr?(0,Y.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,Y.jsx)(je,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,Y.jsx)(Lt,{entry:e})]}):null})}function Ft({entry:e,onDelete:t}){let n=w(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>S(e.runId),onSuccess:e=>{T(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>T(e instanceof y&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>T(`Copied ${e.name}`),()=>T(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,Y.jsxs)(Y.Fragment,{children:[e.runId?(0,Y.jsx)(M,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,Y.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Y.jsx)(mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,Y.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,Y.jsxs)(Fe,{children:[(0,Y.jsx)(Ne,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,Y.jsx)(ve,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,Y.jsxs)(Pe,{align:`end`,className:`w-52`,children:[e.runId?(0,Y.jsx)(j,{asChild:!0,className:`md:hidden`,children:(0,Y.jsx)(M,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,Y.jsx)(j,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,Y.jsx)(j,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,Y.jsx)(Me,{className:`md:hidden`}),(0,Y.jsx)(j,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function It({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=N(i),o=n||!e.runStatus?a:`${e.runStatus}${a?` ${a}`:``}`,s=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,Y.jsx)(Se,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,Y.jsx)(Ie,{tone:e.runStatus&&At[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,Y.jsx)(M,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,Y.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,Y.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(lt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{className:`truncate`,title:s,children:o})]}):null]}),e.parentRunId?(0,Y.jsx)(M,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,Y.jsx)(gt,{entry:e})]})]})}function Q(){return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Lt({entry:e}){let t=m(ke(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Rt({entry:e,onClose:t}){let n=w(),[r,i]=(0,J.useState)(``),a=(0,J.useId)(),o=d({mutationFn:e=>C({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;T(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:u.repo}),s()},onError:e=>T(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,Y.jsx)(I,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,Y.jsxs)(U,{"data-slot":`delete-branch-dialog`,children:[(0,Y.jsxs)(z,{children:[(0,Y.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,Y.jsx)(G,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,Y.jsxs)(Y.Fragment,{children:[`This drops the work of `,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,Y.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,Y.jsx)(`span`,{className:`font-mono`,title:e?.lastCommit.sha,children:e?.lastCommit.sha.slice(0,8)}),`).`]})]})})]}),(0,Y.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,Y.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,Y.jsx)(B,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,Y.jsxs)(L,{children:[(0,Y.jsx)(R,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,Y.jsx)(W,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function zt({base:e}){let t=g(),n=w(),[r,i]=(0,J.useState)({merged:!1,empty:!1}),[a,o]=(0,J.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],f=d({mutationFn:e=>C({names:e}),onSuccess:e=>{let t=e.refused.length;T(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),T(e.message,{tone:`danger`})}});if(t.isPending)return(0,Y.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,Y.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,Y.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Y.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,Y.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,Y.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Y.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,Y.jsx)(Bt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:Z.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,Y.jsx)(Bt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,Y.jsx)(I,{open:a,onOpenChange:o,children:(0,Y.jsxs)(U,{children:[(0,Y.jsxs)(z,{children:[(0,Y.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,Y.jsxs)(G,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,Y.jsxs)(L,{children:[(0,Y.jsx)(R,{children:`Keep them`}),(0,Y.jsxs)(W,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Bt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,Y.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,Y.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,Y.jsx)(ge,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,Y.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,Y.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,Y.jsx)(M,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,Y.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:N(e.lastCommit.at)})]},e.name))}):null]})}function Vt(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>b(e,t.id),onError:e=>T(e.message,{tone:`danger`})}),r=w(),[i,a]=(0,J.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),s=d({mutationFn:e=>ee(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);T(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>T(e.message,{tone:`danger`})}),c=d({mutationFn:e=>x(e.runId),onSuccess:(e,t)=>{o(),T(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),T(e.message,{tone:`danger`})}});if(e.isPending)return(0,Y.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Y.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:p,totalBytes:m,keep:h}=e.data,g=s.isPending||c.isPending,_=p.filter(e=>e.pastKeep),v=_.length>0,y=_.some(e=>e.sizeBytes===null)?null:_.reduce((e,t)=>e+(t.sizeBytes??0),0),S=v?y?`Reclaim ${E(y)} now`:`Reclaim ${_.length} now`:`Reclaim now`,C=m?E(m):null;return(0,Y.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Y.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,C?` · ${C}`:``]}),(0,Y.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[h===0?`Retention is unlimited (`:`Retention keeps the newest ${h} finished checkout${h===1?``:`s`} (`,(0,Y.jsx)(M,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:it(`worktrees`,` › `)}),h===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,Y.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:g||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Y.jsx)(Ue,{"aria-hidden":`true`,className:`size-[12px]`}),S]})]}),p.length===0?(0,Y.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,Y.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:p.map(e=>(0,Y.jsx)(Wt,{worktree:e,keep:h,disabled:g,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,Y.jsx)(I,{open:i,onOpenChange:a,children:(0,Y.jsxs)(U,{children:[(0,Y.jsxs)(z,{children:[(0,Y.jsx)(q,{children:`Reclaim old worktrees?`}),(0,Y.jsxs)(G,{children:[_.length,` finished worktree`,_.length===1?``:`s`,` beyond the keep limit`,y?` (${E(y)})`:``,` `,_.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,Y.jsxs)(L,{children:[(0,Y.jsx)(R,{children:`Keep them`}),(0,Y.jsx)(W,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(_.length),a(!1)},children:S})]})]})})]})}var Ht=new Set([`queued`,`running`,`waiting`,`review`]);function Ut(e,t){return Ht.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function Wt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=Ut(e,t),c=N(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Le(c)}`:e.status,u=(0,Y.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,Y.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Y.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-[11px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,Y.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,Y.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:E(e.sizeBytes)||`0 kB`}),(0,Y.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,Y.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,Y.jsx)(oe,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,Y.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,Y.jsx)(Ue,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function $(e){return e===`main`||e===`changes`?`Split`:`Table`}function Gt({section:e,index:t=!1}){let n=o(),r=K(),[i]=re(),a=$(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,Y.jsx)(ht,{});if(n.isPending)return(0,Y.jsx)(at,{});if(n.isError)return(0,Y.jsx)(P,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Y.jsx)(H,{}),children:(0,Y.jsx)(F,{icon:(0,Y.jsx)(O,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,Y.jsx)(Kt,{repo:n.data,info:s,section:e}):(0,Y.jsx)(P,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Y.jsx)(H,{}),children:(0,Y.jsx)(F,{icon:(0,Y.jsx)(D,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function Kt({repo:e,info:t,section:n}){let r=$(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?X(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,Y.jsx)(P,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Re(a),rootProps:{"data-git-section":n},beforeHeader:(0,Y.jsx)(H,{}),header:{title:Qe(n,t.branch),headerSlot:`repo-header`,subtitle:(0,Y.jsx)(qt,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,Y.jsx)(wt,{repo:e,info:t}):n===`not-landed`?(0,Y.jsx)(jt,{}):n===`cleanup`?(0,Y.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,Y.jsx)(Vt,{}),(0,Y.jsx)(zt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,Y.jsx)(_t,{repo:e,info:t}):(0,Y.jsx)(Ct,{})})}function qt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,Y.jsxs)(Y.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Je(e.tracking)}`:``]});case`not-landed`:return(0,Y.jsxs)(Y.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,Y.jsx)(Jt,{repo:e,info:t});case`changes`:return(0,Y.jsxs)(Y.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,Y.jsxs)(Y.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Jt({repo:e,info:t}){let n=X(e,g().data?.branches).length;return(0,Y.jsxs)(Y.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Gt as RepoGitRoute};
@@ -1,8 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{$ as o,$t as s,Ct as c,P as l,Wt as u,Xt as d,Yt as f,_ as p,dn as m,lt as h,rn as g,un as _}from"./queries-BwJVP1so.js";import{Fn as v,ct as y,dr as b,hi as x,n as S,ot as C,pt as w,rr as T}from"./toaster-UvSCLhYx.js";import{f as E,n as D,p as O}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{B as ee,F as te,K as ne,X as re,at as ie,c as ae,dt as oe,s as se,u as k,v as ce}from"./design-icons-CzEoMH9c.js";import{t as A}from"./createLucideIcon-BHp8sXmF.js";import{t as le}from"./chevron-right-BENZ-1ZN.js";import{t as ue}from"./external-link-BE6y205O.js";import{t as j}from"./eye-B8okNWXU.js";import{n as de}from"./smartphone-Lr8Ug2z_.js";import{t as M}from"./loader-circle-CPBhhDbB.js";import{t as fe}from"./message-square-B-MD-8rD.js";import{n as pe,t as me}from"./tool-display-B9NN44oU.js";import{t as he}from"./square-terminal-B6RYYieR.js";import{t as N}from"./button-B7MKxYjT.js";import{n as P,r as F,t as I}from"./collapsible-BEV4FO-1.js";import{t as L}from"./project-router-B8blqSVo.js";import{O as ge}from"./task-groups-BSovus2j.js";import{t as _e}from"./report-selection-DBM7S3ha.js";import{n as ve}from"./centered-state-V15AR_qo.js";import{$t as ye,J as be,Kn as xe,P as Se,Vn as Ce,rn as we,tn as Te,un as Ee,yn as De}from"./index-AgYIT7cV.js";import{i as Oe,r as ke}from"./highlighter-DvLzHjjY.js";import{t as Ae}from"./zoomable-image-CIQl1Wpe.js";import{i as je,r as Me,t as R}from"./markdown-BVqO9ORd.js";import{r as Ne}from"./html-report-BX3msvci.js";import{t as z}from"./textarea-vJt9undk.js";import{t as Pe}from"./report-title-D4Mbu2Er.js";var Fe=A(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Ie=A(`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`}]]),Le=A(`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`}]]),Re=A(`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`}]]),ze=A(`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`}]]),B=e(t(),1),V=n();function Be(e,t){if(e.length===1)return[t.replace(RegExp(`^${Ve(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function Ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function He(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}function Ue({ask:e}){let t=e.answer===void 0?void 0:Be(e.questions,e.answer);return(0,V.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((n,r)=>{let i=t?.[r],a=He(n,i),o=i!==void 0&&a.length===0;return(0,V.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":n.question,children:[(0,V.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[n.header,` · Question `,r+1,` of `,e.questions.length]}),(0,V.jsx)(`p`,{className:`break-words font-semibold`,children:n.question}),n.options?(0,V.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[n.options.map(e=>(0,V.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,V.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,V.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,V.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,V.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,V.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,V.jsx)(H,{text:i}):null]})]}):i===void 0?null:(0,V.jsx)(H,{text:i})]},n.id??r)}),!t&&e.answer!==void 0?(0,V.jsx)(H,{text:e.answer}):null]})}function H({text:e}){return(0,V.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ge=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ke(e){return e.replaceAll(`'`,`'\\''`)}function qe(e){return e===``?`''`:Ge.test(e)?e:`\u0027${Ke(e)}\u0027`}function Je(e){if(!We(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(qe).join(` `)}}function Ye(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Xe(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ze(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function U(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qe(e){let t=Ye(Xe(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))U(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){U(e[2])&&i.push({label:Ze(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ze(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&U(t)&&i.push({label:t,href:t})}return i}var $e=(0,B.createContext)(void 0),et=(0,B.createContext)(void 0);function tt(e,t){let n=new Map;for(let r of Qe(e)){let e=je(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function W(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function nt({text:e,messageKey:t}){let n=(0,B.useContext)(Me),r=(0,B.useContext)(et),i=t??r;if(!n||i===void 0)return null;let a=tt(e,n);return a.length===0?null:(0,V.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,V.jsx)(rt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function rt({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,B.useContext)($e),s=(0,B.useContext)(_e);(0,B.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=l(r,n),u=E(),d=O();if(c.isError)return(0,V.jsx)(D,{id:W(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:u.pathname+u.search},children:i});let f=c.data?.artifact;if(f&&!Ne(f.name))return null;let p=new URLSearchParams(u.search);p.set(`report`,n),p.set(`card`,t);let m=new URLSearchParams(u.search).has(`report`)?u.state:null,h=new URLSearchParams(u.search);h.delete(`report`),h.delete(`card`);let g=`${u.pathname}${h.size?`?${h}`:``}`,_=window.navigation,v={reportCardEntry:!0,reportReturnTo:m?.reportReturnTo??g,reportReturnKey:m?.reportReturnKey??_?.currentEntry?.key,reportScrollTop:m?.reportScrollTop},y={pathname:u.pathname,search:`?${p}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,V.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,V.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:f?Pe(f):i}),(0,V.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,V.jsx)(D,{id:W(t,n),to:y,state:v,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=v.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;d(y,{state:{...v,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var it={message:!0,reasoning:!0,tool:!0,hook:!0};function at(e){return Object.hasOwn(it,e)&&it[e]}var G=e=>e.kind===`tool`,ot=e=>e.kind===`conversation`,st=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ct=(e,t,n)=>`${e} ${e===1?t:n}`;function lt(e,t){let n=[];return e>0&&n.push(ct(e,`file`,`files`)),t>0&&n.push(ct(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ut(e){return`${e} earlier tool call${e===1?``:`s`}`}var dt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ft(e){for(let t of dt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var pt=new WeakMap;function mt(e){let t=pt.get(e);if(t)return t;let n=ht(e);return pt.set(e,n),n}function ht(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(G).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=at(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:lt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of gt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(ot(e)){s(),c.push(e);continue}l(),G(e)&&st(e)&&!r.has(e.id)?o.push(e):(s(),G(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function gt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var K=new Map,_t=(0,B.createContext)(null);function q(){return(0,B.useContext)(_t)}function vt({runId:e,children:t}){let n=(0,B.useMemo)(()=>({get:t=>K.get(e)?.get(t),set:(t,n)=>{let r=K.get(e)??new Map;r.set(t,n),K.set(e,r)}}),[e]);return(0,V.jsx)(_t.Provider,{value:n,children:t})}function yt(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 xt(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 St(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ct(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var wt=new Map;function Tt(e,t){wt.set(e,t)}function Et(e){return wt.get(e)}var J=new Map;function Dt(e,t){J.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Ot(e){return J.get(e)}function kt(e,t,n){let r=J.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var At=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),jt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Mt=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Nt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Pt=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:At.format(t)}function Ft(e){let t=Y(e);return t===void 0?void 0:jt.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function It(e){let t=Y(e);return t===void 0?void 0:Z(t)}function Lt(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Mt:Nt).format(n)}function Rt(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function zt({ts:e}){let t=X(e);return t===void 0?null:(0,V.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Ft(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Bt({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=Rt(e,t);return(0,V.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,V.jsx)(`time`,{dateTime:t,title:Ft(t),children:n}),r===void 0?null:(0,V.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Vt({ts:e}){let t=Lt(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Pt.format(n);return(0,V.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,V.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,V.jsx)(`time`,{dateTime:It(e),title:r,children:t}),(0,V.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Ht={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Ut({note:e}){return e.icon===`handoff`?(0,V.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,V.jsx)(Ce,{className:`size-3`})}),(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,V.jsxs)(I,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,V.jsxs)(`div`,{className:a(`flex items-start gap-2`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,V.jsxs)(F,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,V.jsx)(k,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,V.jsx)(P,{children:(0,V.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-[11px] text-muted-foreground`,children:e.details.map((e,t)=>(0,V.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,V.jsxs)(`span`,{className:`font-sans font-medium text-foreground/80`,children:[Ht[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,V.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:a(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Wt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...o}){let s=Wt[e],c=r===void 0?void 0:X(r);return(0,V.jsxs)(`article`,{...o,"data-role":e,"aria-label":s.speaker,className:a(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,V.jsxs)(`p`,{className:a(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,V.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,V.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,V.jsx)(fe,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,V.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,V.jsx)(zt,{ts:r})})]}),(0,V.jsx)(`div`,{className:a(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var Gt=[],Kt=(0,B.memo)(function({text:e,imageCount:t=0,images:n=Gt,ts:i,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(e),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(),y=()=>{m(e),v(void 0),f(!0)},x=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},S=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,V.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,V.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,V.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,V.jsx)(M,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,V.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,V.jsxs)(Q,{role:`user`,ts:i,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,V.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,V.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,V.jsx)(ze,{className:`size-3.5`})}):null,o?(0,V.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void S(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,V.jsx)(ie,{className:`size-3.5`})}):null]}):null,_?(0,V.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,V.jsx)(R,{breaks:!0,children:e}),n.length>0?(0,V.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>b(e.split(`/`).pop()??``)?(0,V.jsx)(Ae,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,V.jsxs)(`a`,{href:r(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,V.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),qt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Jt=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Yt(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Jt).forEach(e=>e.remove());let r=Qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!U(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Xt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Yt(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Zt=(0,B.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,B.useRef)(null),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Xt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,V.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,V.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:qt,children:[(0,V.jsx)(ce,{className:`size-3.5`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,V.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:qt,children:[(0,V.jsx)(xe,{className:`size-3.5`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,V.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,V.jsx)(`div`,{ref:r,children:(0,V.jsx)(R,{breaks:!0,children:e})}),(0,V.jsx)(nt,{text:e,messageKey:n})]})});function Qt({incident:e}){let t=g().data;if(!t)return null;let n=d(t,e.provider);return(0,V.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,V.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,V.jsx)(L,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var $t=(0,B.memo)(function({text:e}){let t=(0,B.useId)();if(e.trim()===``)return null;let n=e.split(`
2
- `,1)[0]??``,r=n.length<e.length;return(0,V.jsxs)(I,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,V.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,V.jsx)(k,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,V.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,V.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,V.jsx)(R,{inline:!0,children:n})}),r?(0,V.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,V.jsx)(F,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,V.jsx)(P,{children:(0,V.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,V.jsx)(R,{children:e})})})]})});function en(){return(0,V.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,V.jsx)(M,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,V.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var tn={read:xe,edit:ze,delete:ie,move:Re,search:re,execute:he,think:Ie,fetch:de,task:se,plan:ee,other:oe},nn=e=>e.split(`
3
- `).length;function rn({text:e,streaming:t}){let[n,r]=(0,B.useState)(!1),i=(0,B.useRef)(null),o=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let e=i.current;t&&e&&o.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=nn(e),c=!t&&!n&&s>12;return(0,V.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`div`,{ref:i,onScroll:t?e=>{o.current=St(e.currentTarget)}:void 0,className:a(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,V.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,V.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,V.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function an({diffs:e}){return(0,V.jsx)(V.Fragment,{children:e.map((e,t)=>(0,V.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,V.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...on(e.oldText).map((e,t)=>(0,V.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...on(e.newText).map((e,t)=>(0,V.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
- `).map((e,t)=>(0,V.jsx)(sn,{text:e},t))})]},`${e.path}:${t}`))})}function on(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
- `)}function sn({text:e}){return(0,V.jsx)(`span`,{className:a(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function cn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function ln(e){let t=e.status===`running`||e.status===`pending`,n=ft(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Je(e.input):pe(e.name).toolKind===e.toolKind?me(e.name,e.input):void 0)??i,Icon:tn[e.toolKind]??oe}}function un(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function dn({item:e,busy:t}){return(0,V.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,V.jsx)(M,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,V.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,V.jsx)(`span`,{"data-slot":`tool-exit`,className:a(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function fn({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,V.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,V.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,V.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,V.jsx)(an,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,V.jsx)(rn,{text:e.output,streaming:n}):null,r.length>0?(0,V.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function pn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=q(),[o,s]=(0,B.useState)(()=>n===void 0?null:i?.get(n)??null),c=e=>{n!==void 0&&i?.set(n,e),s(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=ln(e),m=un(e,t.length),h=f!==void 0||m,g=h&&(o??(m&&cn(e)));return(0,V.jsxs)(I,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:c,className:a(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,V.jsxs)(F,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,V.jsx)(k,{"aria-hidden":!0,className:a(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,V.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:a(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,V.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,V.jsx)(dn,{item:e,busy:l})]}),(0,V.jsx)(P,{children:(0,V.jsx)(fn,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function mn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function hn({item:e,cacheKey:t}){let n=q(),[r,i]=(0,B.useState)(()=>t===void 0?!1:n?.get(t)??!1),o=e=>{t!==void 0&&n?.set(t,e),i(e)},s=e.status!==`completed`,c=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=mn(e);return(0,V.jsxs)(I,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:o,className:a(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,V.jsxs)(F,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,V.jsx)(k,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,V.jsx)(Fe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,V.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,V.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,V.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,V.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-[11px] font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,V.jsx)(P,{children:(0,V.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,V.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:a(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,V.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,V.jsxs)(I,{className:`border-t border-border`,children:[(0,V.jsxs)(F,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,V.jsx)(k,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,V.jsxs)(P,{children:[e.stdout?(0,V.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,V.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function gn({group:e,scope:t}){return(0,V.jsxs)(I,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,V.jsxs)(F,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,V.jsx)(k,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,V.jsx)(P,{children:(0,V.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,V.jsx)(pn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function _n({count:e,children:t}){return(0,V.jsxs)(I,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,V.jsxs)(F,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,V.jsx)(k,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),ut(e)]}),(0,V.jsx)(P,{children:(0,V.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function vn({image:e}){return(0,V.jsx)(Ae,{"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 yn={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function bn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function xn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i}){let a=e.context?(0,V.jsx)(Cn,{text:e.context}):null;if(e.resolved)return(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[a,(0,V.jsxs)(Q,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,V.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?yn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,V.jsx)(Ue,{ask:e})]})]});let o=e.placement===`pinned`&&r?r:void 0;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[a,e.routedToParent?(0,V.jsx)(wn,{ask:e,onShowOrigin:o}):(0,V.jsx)(Tn,{ask:e,run:t,projectId:n,onShowOrigin:o,onAnswered:i})]})}function Sn({onShowOrigin:e,className:t}){return(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,className:a(`mbs-2 min-h-11 min-w-11 px-2 text-xs font-medium text-muted-foreground underline underline-offset-4`,t),onClick:e,children:`Show where it was asked`})}function Cn({text:e}){return(0,V.jsx)(Q,{role:`agent`,children:(0,V.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,V.jsx)(R,{breaks:!0,children:e})})})}function wn({ask:e,onShowOrigin:t}){return(0,V.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,V.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,V.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,V.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,V.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,V.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,V.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,V.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,V.jsxs)(`li`,{className:`break-words`,children:[(0,V.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,V.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,V.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,V.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,V.jsx)(L,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),t?(0,V.jsx)(Sn,{onShowOrigin:t}):null]})}function Tn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i}){let o=ye(t,n),s=o.blockedBy!==void 0,c=e.questions,l=c.length===1&&c[0]?.options!==void 0&&c[0]?.multiSelect!==!0,[u,d]=(0,B.useState)({}),[f,p]=(0,B.useState)({}),m=(e,t)=>d(n=>({...n,[e]:t})),h=e=>p(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),g=e=>{m(e,[]),p(t=>({...t,[e]:t[e]??``}))},_=c.some((e,t)=>!e.options||f[t]!==void 0),v=c.every((e,t)=>(u[t]?.length??0)>0||!!f[t]?.trim()),y=async e=>{await o.send(e)===void 0&&i?.()},b=()=>void y(c.map((e,t)=>bn(e,u[t]??[],f[t])).join(`
6
- `)),x=o.mode===`resume`;return(0,V.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":o.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card px-3 pt-4 pb-2.5 max-sm:pt-3 max-sm:pb-1`,children:[(0,V.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,V.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,V.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,V.jsx)(An,{question:e,disabled:o.isPending||s,selected:u[t]??[],isOther:f[t]!==void 0,otherAnswer:f[t]??``,onSelect:n=>{s||(h(t),l?y(bn(e,n)):m(t,n))},onOtherToggle:()=>{s||(f[t]===void 0?g(t):h(t))},onOtherChange:e=>p(n=>({...n,[t]:e}))},e.id??t))}),(0,V.jsxs)(`div`,{"data-slot":`ask-footer`,className:`max-sm:mbs-2 max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:gap-x-2.5`,children:[(0,V.jsx)(Dn,{oneTap:l,hasOtherAnswer:_,resuming:x,disabled:o.isPending||s||!v,questionCount:c.length,onSend:b}),o.blockedBy===`provider`?(0,V.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground max-sm:order-4 max-sm:basis-full`,children:[(0,V.jsx)(`span`,{children:o.reason}),(0,V.jsx)(L,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,o.blockedBy===`no-session`?(0,V.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground max-sm:order-4 max-sm:basis-full`,children:o.reason}):null,o.error?(0,V.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger max-sm:order-4 max-sm:basis-full`,children:o.error}):null,r?(0,V.jsx)(Sn,{onShowOrigin:r,className:a(`max-sm:order-2 max-sm:mbs-0`,En(l,_)&&`max-sm:ms-auto`)}):null]})]})}var En=(e,t)=>!e||t;function Dn({oneTap:e,hasOtherAnswer:t,resuming:n,disabled:r,questionCount:i,onSend:a}){return En(e,t)?(0,V.jsxs)(`div`,{className:`mbs-2 flex flex-wrap items-center gap-x-2.5 max-sm:contents`,children:[(0,V.jsx)(N,{size:`sm`,className:`min-h-11 max-sm:order-1`,disabled:r,onClick:a,children:n?`Send answer & reopen`:`Send answer`}),n?(0,V.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:`the session has ended — sending reopens it`}):(0,V.jsxs)(`span`,{"data-slot":`ask-hint`,className:`inline-flex flex-wrap items-center gap-x-1 text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:[(0,V.jsx)(`span`,{children:t?`${i>1?`answer each question above`:`enter your answer above`} — or`:`${i>1?`answer each question`:`pick one or more`} — or`}),(0,V.jsx)(kn,{})]})]}):n?(0,V.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mbs-3 text-[11px] text-soft-foreground max-sm:order-3 max-sm:basis-full`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null}function On(e){return(e.closest(`[data-route="task-thread"]`)??document).querySelector(`[data-slot="thread-dock"] [data-slot="composer-editor"] textarea`)}function kn(){return(0,V.jsx)(`button`,{type:`button`,"data-slot":`ask-reply-jump`,className:`min-h-11 rounded-sm font-medium text-foreground underline underline-offset-4 hover:text-link-foreground focus-visible:outline-2 focus-visible:outline-ring`,onClick:e=>{let t=On(e.currentTarget);if(!t)return;let n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;t.scrollIntoView?.({behavior:n?`auto`:`smooth`,block:`center`}),t.focus({preventScroll:!0})},children:`type a reply below`})}function An({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:o,onOtherToggle:s,onOtherChange:c}){let l=(0,B.useId)(),u=e.options,d=u!==void 0&&e.multiSelect===!0,f=e=>{if(!d){o([e]);return}o(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,V.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,V.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,V.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),d?(0,V.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),u?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1 sm:grid-cols-2 sm:gap-2`,children:[u.map(e=>{let r=n.includes(e.label);return(0,V.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>f(e.label),className:a(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1 text-left transition-colors sm:py-1.5`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] [html:not(.light)_&]:hover:bg-card disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`:`border-border bg-card`),children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[d?(0,V.jsx)(`span`,{"aria-hidden":!0,className:a(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,V.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,V.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,V.jsx)(N,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,className:a(`h-auto min-h-11 w-full justify-start px-2.5 py-1 text-left sm:py-1.5`,u.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong/60 bg-accent-strong/[0.06] [html:not(.light)_&]:bg-card`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,V.jsx)(z,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]}):null]}):(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,V.jsx)(z,{id:l,rows:2,value:i,disabled:t,onChange:e=>c(e.target.value),className:`bg-card`})]})]})}var jn=/^diff --git /;function Mn(e){let t=e.replace(jn,``),n=t.lastIndexOf(` b/`);return $(n>=0?t.slice(n+3):t)}function $(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function Nn(e){let t=$(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function Pn(e){return{path:Mn(e),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]}}function Fn(e,t){if(t.startsWith(`rename from `))e.status=`renamed`,e.oldPath=$(t.slice(12));else if(t.startsWith(`rename to `))e.status=`renamed`,e.path=$(t.slice(10));else if(t.startsWith(`new file mode`))e.status=`added`;else if(t.startsWith(`deleted file mode`))e.status=`deleted`;else if(t.startsWith(`Binary files `)||t===`GIT binary patch`)e.binary=!0;else if(t.startsWith(`+++ `)){let n=Nn(t);n!==void 0&&(e.path=n)}else if(t.startsWith(`--- `)){let n=Nn(t);n!==void 0&&e.status===`deleted`&&(e.path=n)}}function In(e,t){e.lines.push(t),t.startsWith(`+`)?e.additions+=1:t.startsWith(`-`)&&(e.deletions+=1)}function Ln(e){let t=[],n=null,r=!1;for(let i of e.split(`
7
- `)){if(jn.test(i)){n=Pn(i),t.push(n),r=!1;continue}if(n){if(!r){i.startsWith(`@@`)?(r=!0,n.lines.push(i)):Fn(n,i);continue}In(n,i)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function Rn(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var zn=20,Bn=300;function Vn({runId:e,projectId:t}){let n=x(),r=o(e,t);(0,B.useEffect)(()=>{let r=t?[t,`runs`,`diff`,e]:u.runs.diff(e);n.invalidateQueries({queryKey:r})},[t,n,e]);let i=(0,B.useMemo)(()=>Ln(r.data??``),[r.data]),[a,s]=(0,B.useState)(!1);if(r.isPending)return(0,V.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(r.isError)return(0,V.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:r.error.message});if(i.length===0)return(0,V.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:r.data.trim()||`(no changes)`});let c=Rn(i),l=a?i:i.slice(0,zn);return(0,V.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,V.jsxs)(`span`,{children:[c.files,` `,c.files===1?`file`:`files`,` changed`]}),(0,V.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,c.additions]}),` `,(0,V.jsxs)(`span`,{className:`text-danger`,children:[`−`,c.deletions]})]})]}),l.map(e=>(0,V.jsx)(Un,{file:e},`${e.oldPath??``}→${e.path}`)),i.length>l.length?(0,V.jsxs)(N,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>s(!0),children:[`Show `,i.length-l.length,` more files`]}):null]})}var Hn={added:`added`,deleted:`deleted`,renamed:`renamed`};function Un({file:e}){let[t,n]=(0,B.useState)(!0),r=Hn[e.status],i=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,V.jsxs)(I,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,V.jsxs)(F,{className:`flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,V.jsx)(le,{className:a(`mbs-[1px] size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,V.jsx)(`span`,{"data-slot":`diff-file-path`,title:i,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:e.oldPath?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,V.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,V.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,V.jsx)(P,{children:(0,V.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,V.jsx)(Wn,{lines:e.lines})})})]})}function Wn({lines:e}){let[t,n]=(0,B.useState)(!1),r=t?e:e.slice(0,Bn),i=r.join(`
8
- `),[o,s]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!1;return ke(i,`diff`).then(t=>{e||s({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let c=o?.text===i?o.tokens:Oe(i,`diff`)?.tokens??null;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,V.jsxs)(`span`,{"data-line":e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:void 0,className:a(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[c?.[t]===void 0?e:c[t].map((e,t)=>(0,V.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>Bn?(0,V.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:t?`Show less`:`Show all ${e.length} lines`}):null]})}function Gn(e,t,n,r){return ge(e,t)?.runner??e.runner??(t||n?r:void 0)??`claude`}function Kn(e,t,n){let r=new Set;for(let i of e.workflowDef?.steps??[]){if(i.command!==void 0||i.kind===`plugin`)continue;let a=i.runner??t,o=i.agentProfile??(a===(e.runner??t)?e.agentProfile:void 0)??n.repoAccount?.[a];n.readyOn(a,o)||r.add(a)}return[...r]}function qn(e,t,n,r,i){if(!e)return t!==null||!n||r?i:void 0}function Jn(e){return e.needsConfig&&e.configPending?`Checking task settings…`:e.needsConfig&&e.configError?`Task settings could not be loaded.`:e.providersPending?`Checking agent providers…`:e.providersError?`Provider authentication could not be verified.`:e.canContinue?void 0:e.untouched?`Connect the required workflow providers (${e.missing.join(`, `)}) to continue.`:`Connect an agent provider to continue.`}function Yn(){let e=c(),t=g();return{providers:e,registered:t,providersPending:e.isPending||t.isPending,providersError:e.isError||t.isError,providersReady:e.isSuccess&&t.isSuccess}}function Xn(e,t=null){let{registered:n,providersPending:r,providersError:i,providersReady:a}=Yn(),o=p(),c=we(e),l=e.removedRunner!==void 0,u=c&&!e.runner||l,d=De(),m=e.delegation?.role===`worker`,h=o.data?.defaultRunner,g=Gn(e,c,l,f(h,s(n.data))??h),_=(t,n)=>Ee(e,t,d.repoAccount,{original:g,target:n},c),{runners:v,signedOut:y}=d.runnersOn(e=>_(e,e)),b=m?g:Se(t,v,g),x=v.includes(g),S=c?T(e.workflowDef,b,s(n.data)):[b],C=c&&m&&e.workflowDef?Kn(e,b,d):S.filter(e=>!d.readyOn(e,_(e,b))),w=a&&(!u||o.isSuccess)&&C.length===0,E=Jn({needsConfig:u,configPending:o.isPending,configError:o.isError,providersPending:r,providersError:i,canContinue:w,untouched:c,missing:C});return{runners:v,signedOut:y,currentRunner:g,runner:b,currentRunnerConnected:x,canContinue:w,providerPending:r||u&&o.isPending,providerError:i,reason:E,runnerOverride:qn(m,t,x,l,b)}}function Zn(e,t){let n=x();return m({mutationFn:()=>w(e,t?.projectId),onSuccess:()=>{n.invalidateQueries({queryKey:u.runs.all}),t?.onSuccess?.()},onError:e=>S(e.message,{tone:`danger`})})}function Qn({run:e,projectId:t,onResolved:n}){return(0,V.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-2.5`,children:[(0,V.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex flex-col gap-2 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,V.jsx)(j,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,V.jsxs)(`p`,{className:`min-w-0 break-words text-[13px] leading-relaxed`,children:[(0,V.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,V.jsx)(`span`,{className:`block text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,V.jsx)($n,{run:e,projectId:t,onResolved:n})]}),(0,V.jsx)(Vn,{runId:e.id,projectId:t})]})}function $n({run:e,projectId:t,onResolved:n}){let r=h(),a=x(),o=(0,B.useRef)(null),[s,c]=(0,B.useState)(``),[l,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),g=Zn(e.id,{projectId:t,onSuccess:n}),b=Xn(e),w=()=>a.invalidateQueries({queryKey:u.runs.all}),T=m({mutationFn:async n=>b.canContinue?C(_(e.id,{projectId:t}),{text:`Review feedback:\n${n}`,runner:b.runnerOverride}):null,onMutate:()=>_(e.id,{projectId:t}),onSuccess:(e,t,i)=>{e!==null&&(c(``),r.invalidateAfter(`continue`,i),n?.())},onError:e=>S(e.message,{tone:`danger`})}),E=m({mutationFn:()=>y(e.id,t),onSuccess:e=>{S(`Draft PR created — ${e.url}`),w(),n?.()},onError:e=>{e instanceof v&&e.manual!==void 0&&p(e.manual),S(e.message,{tone:`danger`})}});(0,B.useEffect)(()=>{l&&o.current?.focus()},[l]);let O=()=>{if(!l){d(!0);return}let e=s.trim();if(e.length===0){S(`Write what to change first.`),o.current?.focus();return}T.mutate(e)};return(0,V.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[b.canContinue?null:(0,V.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:b.reason}),b.providerPending?null:(0,V.jsx)(L,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button]:min-h-11 [&_a]:min-h-11`,children:[(0,V.jsx)(N,{asChild:!0,variant:`outline`,size:`sm`,children:t?(0,V.jsxs)(D,{to:`/p/${encodeURIComponent(t)}/tasks/${encodeURIComponent(e.id)}/changes`,children:[(0,V.jsx)(j,{"aria-hidden":`true`}),`Review changes`]}):(0,V.jsxs)(L,{to:`/tasks/${e.id}/changes`,children:[(0,V.jsx)(j,{"aria-hidden":`true`}),`Review changes`]})}),(0,V.jsxs)(N,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:b.reason??(l?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":b.canContinue?void 0:`review-provider-guidance`,"aria-expanded":l,"aria-controls":l?`review-notes`:void 0,disabled:T.isPending||!b.canContinue,onClick:O,children:[(0,V.jsx)(Le,{"aria-hidden":`true`}),l?`Send back with notes`:`Send back`]}),i(e.pullRequestUrl)?(0,V.jsx)(N,{asChild:!0,variant:`outline`,size:`sm`,children:(0,V.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,V.jsx)(ue,{"aria-hidden":`true`}),`PR ↗`]})}):(0,V.jsxs)(N,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:E.isPending,onClick:()=>E.mutate(),children:[(0,V.jsx)(te,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,V.jsxs)(N,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:Te(`review`),disabled:g.isPending,onClick:()=>g.mutate(),children:[(0,V.jsx)(ae,{"aria-hidden":`true`}),`Accept`]}):null]}),l?(0,V.jsx)(z,{ref:o,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:1,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{be({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())},className:`min-h-11 text-base md:text-[13px]`}):null,f===null?null:(0,V.jsx)(er,{command:f})]})}function er({command:e}){return(0,V.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>S(`Command copied to clipboard.`)).catch(()=>S(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,V.jsx)(ce,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,V.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function tr(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var nr=1500;function rr({status:e}){let t=(0,B.useRef)(e),[n,r]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||tr())return;r(!0);let i=setTimeout(()=>r(!1),nr);return()=>clearTimeout(i)},[e]),n?(0,V.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,V.jsx)(ve,{}),(0,V.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,V.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}export{Tt as A,W as B,bt as C,kt as D,Ot as E,mt as F,Ue as H,ft as I,at as L,Ct as M,vt as N,Et as O,q as P,et as R,It as S,yt as T,tt as V,Ut as _,xn as a,Bt as b,gn as c,Qt as d,$t as f,en as g,Kt as h,Xn as i,xt as j,Dt as k,hn as l,_n as m,Qn as n,Cn as o,pn as p,Zn as r,Zt as s,rr as t,vn as u,Vt as v,St as w,X as x,zt as y,$e as z};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{C as i,Wt as a,X as o,Y as s,dn as c,yt as l}from"./queries-BwJVP1so.js";import{Bt as u,Fn as d,Ft as f,Ht as p,Lt as m,Tt as h,at as g,ct as _,er as v,hi as y,n as b}from"./toaster-UvSCLhYx.js";import{h as x}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{C as S,j as C,l as w}from"./design-icons-CzEoMH9c.js";import{t as T}from"./run-header-BG-RicJl.js";import{i as E,n as D,r as O}from"./git-toolbar-DyQaOcLy.js";import{t as k}from"./button-B7MKxYjT.js";import{a as A,i as j,o as M,r as N,s as P,t as F}from"./dialog-B531GGAo.js";import{b as I,f as L}from"./task-groups-BSovus2j.js";import{c as R,d as z}from"./page-shell-7pLJMOgh.js";import{t as B}from"./centered-state-V15AR_qo.js";import{J as V,S as H,Zt as U,an as W,x as G}from"./index-AgYIT7cV.js";import{t as K}from"./markdown-BBDDg-4t.js";import{t as q}from"./textarea-vJt9undk.js";import{t as J}from"./diff-B1RHxCxU.js";var Y=e(t(),1),X=`no worktree — this task ran directly in the repo working tree`;function Z(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${X}`)}function Q(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.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${X}`)}function ee(e){let t=e=>({id:`create-pr`,label:`Draft PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Draft PR unavailable — ${X}`):e.forge===null?t(`Draft PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?v(e.run)?t(`Draft PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):I(e.run)?t(`Draft PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Draft PR`,enabled:!0}:t(`Draft PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function te(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:Z(e),n=e.prUrl?[Z(e),Q(e)]:[Q(e),ee(e)],r=[];if(e.localHandoff&&e.cliHandoff!==!1){let t=e.hasSession?I(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var $=n();function ne({run:e,open:t,onOpenChange:n}){let r=y(),[i,o]=(0,Y.useState)(``),s=L(e),l=(0,Y.useRef)(s);l.current=s,(0,Y.useEffect)(()=>{t&&o(l.current)},[t]);let u=c({mutationFn:t=>g(e.id,t),onSuccess:t=>{b(`Committed ${t.sha.slice(0,7)}`),n(!1),r.invalidateQueries({queryKey:a.runs.changes(e.id)}),r.invalidateQueries({queryKey:a.runs.all})},onError:e=>b(e.message,{tone:`danger`})}),d=()=>{let e=i.trim();e.length===0||u.isPending||u.mutate(e)};return(0,$.jsx)(F,{open:t,onOpenChange:n,children:(0,$.jsxs)(N,{"data-slot":`commit-dialog`,children:[(0,$.jsxs)(M,{children:[(0,$.jsx)(P,{children:`Commit changes`}),(0,$.jsxs)(j,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,$.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,$.jsx)(q,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{V({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,$.jsxs)(A,{children:[(0,$.jsx)(k,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,$.jsx)(k,{"data-slot":`commit-confirm`,disabled:i.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:`Commit`})]})]})})}function re(){let{id:e}=x(),t=s(e);return t.isPending?(0,$.jsx)(H,{tab:`changes`}):t.isError?(0,$.jsx)(G,{tab:`changes`,error:t.error}):(0,$.jsx)(ie,{run:t.data})}function ie({run:e}){let t=l(),n=i(),r=o(e.id,I(e)),s=U(),[p,h]=(0,Y.useState)(`unified`),[g,v]=(0,Y.useState)(!0),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[E,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),j=y(),M=()=>j.invalidateQueries({queryKey:a.runs.all}),N=e=>b(e.message,{tone:`danger`}),P=c({mutationFn:()=>u(e.id),onSuccess:e=>b(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:N}),F=c({mutationFn:()=>_(e.id),onSuccess:e=>{b(`Draft PR created — ${e.url}`),M()},onError:N}),L=c({mutationFn:()=>m(e.id),onError:e=>{if(e instanceof d&&e.command){navigator.clipboard.writeText(e.command).then(()=>b(`No terminal found — command copied to clipboard.`)).catch(()=>b(`Run manually: ${e.command}`));return}N(e)}}),B=c({mutationFn:t=>f(e.id,t),onError:N}),V=r.isError&&r.error instanceof d&&r.error.status===409,H=te({run:e,cliHandoff:e.cliHandoff,hasWorktree:!!e.worktreePath&&!V,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:W(e)!==void 0,prUrl:e.pullRequestUrl}),G=e=>{switch(e){case`commit`:k(!0);break;case`push`:P.mutate();break;case`create-pr`:F.mutate();break;case`open-terminal`:L.mutate();break;case`view-pr`:break}},q=r.data?.files??[],J=(0,Y.useMemo)(()=>O(q),[q]),X=(0,Y.useMemo)(()=>q.some(K),[q]),Z=s?p:`unified`;return(0,$.jsxs)(R,{route:`task-changes`,density:z(q.length),flushPadding:!0,children:[(0,$.jsx)(T,{run:e,tab:`changes`}),(0,$.jsx)(D,{bar:H,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:Z,wrap:g,preview:x,onModeChange:h,onWrapChange:v,onPreviewChange:X?S:void 0,onAction:G}),r.data?.repointedHead?(0,$.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,$.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,$.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,$.jsx)(ae,{changes:r,changesRefused:V,fileCount:q.length,children:(0,$.jsx)(oe,{runId:e.id,files:q,tree:J,selected:C,selectFile:e=>{w(e),A.current?.scrollToPath(e)},diffRef:A,effectiveMode:Z,effectiveWrap:g,preview:x,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:B.mutate})}),(0,$.jsx)(ne,{run:e,open:E,onOpenChange:k})]})}function ae({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,$.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,$.jsx)(B,{icon:t?(0,$.jsx)(S,{size:16}):(0,$.jsx)(C,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,$.jsx)(B,{icon:(0,$.jsx)(S,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function oe({runId:e,files:t,tree:n,selected:i,selectFile:a,diffRef:o,effectiveMode:s,effectiveWrap:c,preview:l,localHandoff:u,onOpenInApp:d}){let[f,m]=(0,Y.useState)(!1);return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-4 px-4 pb-9 pt-0 [--diff-sticky-top:0px] md:flex-row md:items-start md:gap-5 md:px-9 md:[--diff-sticky-top:1rem]`,children:[(0,$.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain md:p-3.5 lg:w-[288px]`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-slot":`changes-tree-toggle`,"aria-expanded":f,onClick:()=>m(e=>!e),className:`flex min-h-11 w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-xs font-semibold text-foreground md:hidden`,children:[(0,$.jsxs)(`span`,{children:[`Changed files`,` `,(0,$.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]}),(0,$.jsx)(w,{size:16,"aria-hidden":`true`,className:r(`size-4 shrink-0 text-muted-foreground motion-safe:transition-transform`,f&&`rotate-180`)})]}),(0,$.jsx)(`h2`,{className:`mb-3 hidden border-b border-border pb-3 text-xs font-semibold md:block`,children:`Changed files`}),(0,$.jsx)(`div`,{className:r(f?`border-t border-border px-3.5 py-3 md:border-t-0 md:p-0`:`hidden md:block`),children:(0,$.jsx)(E,{root:n,selected:i,onSelect:e=>{a(e),m(!1)}})})]}),(0,$.jsx)(J,{files:t,viewRef:o,mode:s,wrap:c,preview:l,loadFileText:t=>se(e,t),imageSrc:t=>p(e,t),onOpenInApp:u?e=>d(e):void 0,totals:!1,className:`min-w-0 flex-1`})]})}async function se(e,t){try{let n=await h(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{re as TaskChangesRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Q as r,Wt as i,Y as a,Z as o,fn as s}from"./queries-BwJVP1so.js";import{Fn as c,St as l}from"./toaster-UvSCLhYx.js";import{h as u}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{S as d,j as f,ot as p}from"./design-icons-CzEoMH9c.js";import{t as m}from"./run-header-BG-RicJl.js";import{n as h}from"./diff-controls-U3q_bktr.js";import{t as g}from"./project-router-B8blqSVo.js";import{b as _}from"./task-groups-BSovus2j.js";import{c as v,d as y}from"./page-shell-7pLJMOgh.js";import{t as b}from"./centered-state-V15AR_qo.js";import{Lt as x,S,Zt as C,fn as w,x as T}from"./index-AgYIT7cV.js";import{t as E}from"./diff-B1RHxCxU.js";import{t as D}from"./change-counts-CW7O8g5Y.js";import{r as O,t as k}from"./commit-list-CjmYvVCK.js";var A=e(t(),1),j=n();function M(){let{id:e}=u(),t=a(e);return t.isPending?(0,j.jsx)(S,{tab:`changes`}):t.isError?(0,j.jsx)(T,{tab:`changes`,error:t.error}):(0,j.jsx)(N,{run:t.data})}function N({run:e}){let{sha:t}=u(),n=r(e.id,_(e)),i=n.data?.commits[0]?.sha;return(0,j.jsxs)(v,{route:`task-commits`,density:y(n.data?.commits.length??0),flushPadding:!0,children:[(0,j.jsx)(m,{run:e,tab:`commits`}),t?(0,j.jsx)(F,{runId:e.id,sha:t}):n.isPending?(0,j.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading commits…`}):n.isError?(0,j.jsx)(b,{icon:(0,j.jsx)(f,{size:16}),tone:n.error instanceof c&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof c&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,j.jsx)(b,{icon:(0,j.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,j.jsx)(P,{run:e,commits:n.data.commits,selectedSha:i})]})}function P({run:e,commits:t,selectedSha:n}){let r=o(e.id,n),i=L(e.id,t),a=(0,A.useRef)(null),s=C(),[c,l]=(0,A.useState)(`unified`),[u,d]=(0,A.useState)(!0),m=s?c:`unified`;return(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5 px-4 py-5 md:px-9 lg:flex-row lg:items-start`,children:[(0,j.jsxs)(`div`,{className:`w-full shrink-0 lg:w-[380px] xl:w-[420px]`,children:[(0,j.jsx)(k,{slot:`task-commits`,selectedSha:n,heading:(0,j.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[t.length,` `,t.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:t.map(t=>({...t,href:`/tasks/${e.id}/commits/${t.sha}`,stat:i.get(t.sha)}))}),n&&r.data&&r.data.files.length>0?(0,j.jsx)(R,{runId:e.id,sha:n,files:r.data.files,onPick:e=>a.current?.scrollToPath(e)}):null]}),n?(0,j.jsx)(`section`,{"data-slot":`task-commit-preview`,"data-sha":n,className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card`,children:r.isPending?(0,j.jsx)(`p`,{className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):r.isError?(0,j.jsx)(b,{icon:(0,j.jsx)(p,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load commit diff`,subtitle:r.error.message}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`h3`,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:r.data.subject}),(0,j.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,j.jsx)(`span`,{children:r.data.author}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{title:r.data.when,children:x(r.data.when)}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{className:`font-mono select-all`,title:r.data.sha??n,children:(r.data.sha??n).slice(0,8)}),r.data.stat?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(w,{stat:r.data.stat})]}):null]})]}),(0,j.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:(0,j.jsx)(h,{mode:c,wrap:u,onModeChange:l,onWrapChange:d})})]}),!r.data.files||r.data.files.length===0?(0,j.jsx)(b,{icon:(0,j.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,j.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem]`,children:(0,j.jsx)(E,{viewRef:a,files:r.data.files,mode:m,wrap:u,totals:!1,className:`min-w-0`})})]})}):null]})}function F({runId:e,sha:t}){return(0,j.jsx)(O,{commit:o(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`})}var I=12;function L(e,t){let n=t.length<=I,r=s({queries:t.map(t=>({queryKey:i.runs.commit(e,t.sha),queryFn:({signal:n})=>l(e,t.sha,{signal:n}),enabled:n,retry:!1}))}),a=new Map;return r.forEach((e,n)=>{let r=t[n]?.sha;r&&e.data?.stat&&a.set(r,e.data.stat)}),a}function R({runId:e,sha:t,files:n,onPick:r}){return(0,j.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-4 rounded-xl border border-border bg-card p-4`,children:[(0,j.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,j.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[n.length,` `,n.length===1?`file`:`files`,` in`,` `,(0,j.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,title:t,children:t.slice(0,8)})]}),(0,j.jsx)(g,{to:`/tasks/${e}/changes`,className:`text-xs text-muted-foreground hover:text-foreground`,children:`All task changes ›`})]}),(0,j.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,"data-slot":`task-commit-file`,title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,onClick:()=>r(e.path),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,j.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:e.path}),(0,j.jsx)(D,{adds:e.adds,dels:e.dels,className:`font-mono text-xs`})]})},e.path))})]})}export{M as TaskCommitsRoute};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{n as i,t as a}from"./utils-DSMR_WLb.js";import{G as o,J as s,R as c,Ut as l,V as u,Wt as d,Xt as f,Y as p,_ as m,dn as h,dt as g,ln as _,lt as v,nt as y,ot as b,rn as x,rt as S,sn as C,un as w,xt as T,yt as E,z as D}from"./queries-BwJVP1so.js";import{$r as O,An as k,At as ee,Fn as A,Nn as j,Pn as M,Qn as N,Xn as P,Yn as F,Zn as te,ei as I,er as L,hi as R,ii as ne,it as z,lt as B,n as V,ot as H,rt as U,vr as re,yr as W}from"./toaster-UvSCLhYx.js";import{f as ie,h as G,n as ae}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as oe,m as se,r as ce,s as le,v as ue}from"./tasks-table-C-wxALy6.js";import{A as de,B as fe,a as pe,f as me,g as K,h as he,it as ge,k as _e,l as ve,m as q,n as ye,ot as be,p as xe,s as Se,u as Ce,ut as we,y as Te,z as Ee}from"./design-icons-CzEoMH9c.js";import{t as De}from"./createLucideIcon-BHp8sXmF.js";import{A as Oe,B as ke,C as Ae,D as je,E as Me,F as Ne,H as Pe,I as Fe,L as Ie,M as Le,N as Re,O as ze,P as Be,R as Ve,S as He,T as Ue,V as We,_ as Ge,a as Ke,b as qe,c as Je,d as Ye,f as Xe,g as Ze,h as Qe,i as $e,j as et,k as tt,l as nt,m as rt,n as it,o as at,p as ot,r as st,s as ct,t as lt,u as ut,v as dt,w as ft,x as pt,y as mt,z as ht}from"./review-panel-CQp83gYh.js";import{a as gt,c as _t,i as vt,n as yt,o as bt,r as xt,s as St,t as Ct}from"./run-header-BG-RicJl.js";import{t as wt}from"./loader-circle-CPBhhDbB.js";import{a as Tt}from"./tool-display-B9NN44oU.js";import{i as Et,l as Dt,o as Ot,t as kt}from"./reference-chip-uLQTF-sm.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,t as Ft}from"./thread-state-DyYOz-Ad.js";import{t as J}from"./button-B7MKxYjT.js";import{n as It,r as Lt,t as Rt}from"./collapsible-BEV4FO-1.js";import{a as zt}from"./popover-BPgUYFyu.js";import{s as Bt,t as Vt}from"./project-router-B8blqSVo.js";import"./attention-CXG_AzDe.js";import{D as Ht,E as Ut,O as Wt,S as Gt,b as Kt,f as Y,u as qt,w as Jt,x as Yt}from"./task-groups-BSovus2j.js";import{t as Xt}from"./status-dot-BRzVlF2X.js";import{c as Zt,i as Qt,l as $t,o as en,r as tn,s as nn,t as rn}from"./report-selection-DBM7S3ha.js";import{c as an}from"./page-shell-7pLJMOgh.js";import{t as on}from"./centered-state-V15AR_qo.js";import{$t as sn,A as cn,H as ln,M as un,N as dn,U as fn,W as pn,Zt as mn,cn as hn,dn as gn,gn as _n,hn as vn,i as yn,j as bn,k as xn,l as Sn,ln as Cn,m as wn,n as Tn,nn as En,on as Dn,q as On,rn as kn,s as An,sn as jn,vn as Mn,xn as Nn,y as Pn}from"./index-AgYIT7cV.js";import{t as Fn}from"./markdown-BVqO9ORd.js";import{i as In}from"./automation-format-DB34jUyF.js";var Ln=De(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Rn=De(`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`}]]),X=e(t(),1),Z=r(),zn=12;function Bn({run:e}){let t=R(),n=h({mutationFn:()=>U(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:d.runs.detail(e.id)}),t.invalidateQueries({queryKey:d.runs.list()}),V(`This task will not resume itself`)},onError:e=>V(e.message,{tone:`danger`})});if(!L(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,Z.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Xt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Z.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,zn,`)`]}):(0,Z.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Z.jsx)(ae,{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 Vn(e,t,n,r,i,a,o,s,c){let l=Wt(e,kn(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=bn(t,o,a,[p,f?.[t]]),h=dn(p,t,o,f,a),g=cn(h,a),_=r?``:c??d??``,v=un(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function Hn(e,t,n,r){let i=Ut(e.steps),a=Wt(e,kn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function Un(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function Wn(e,t,n,r){return!!t&&(r!==Ht(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function Gn({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`auto`,effortLabel:n.find(e=>e.value===r)?.label??`auto`}}function Kn(e){let t=v(),n=Cn(e).continueRun,r=m(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),u=`${e.id}:${Wt(e,kn(e))?.id??``}`,[d,p]=(0,X.useState)(u);d!==u&&(p(u),a(null),s(null),l(null));let g=$e(e,i),{runners:_,canContinue:y,currentRunner:b,runner:S}=g,{sessionStep:T,workerStep:D,account:O}=Hn(e,S,S!==b,Mn().repoAccount),k=E(),ee=k.data?.capabilities?.localHandoff!==!1,j=x(),M=C(S,n&&!k.isPending&&!j.isPending,ee?O:null),N=r.data?.modelsLocked===!0,P=S!==b,F=Vn(e,S,P,N,r.data,M.data,j.data,o,c),{models:te,model:I,effortOptions:L,effort:R}=F,{modelLabel:ne,effortLabel:z}=Gn(F),B=h({mutationFn:({text:t,images:n})=>y?H(w(e.id),Un(t,n,g.runnerOverride,N,P,o,c,F)):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onMutate:()=>w(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof A&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),V=e.delegation?.role===`worker`;return{skillRunner:S,skillAccount:O,available:n,canContinue:y,startsNewConversation:Wn(e,T,D,S),reason:g.reason,providerPending:g.providerPending,pills:(0,Z.jsx)(qn,{compact:e.status===`review`,summary:`${f(j.data,S)} · ${ne} · ${z}`,children:(0,Z.jsxs)(fn,{children:[!V&&(_.length>1||g.signedOut.length>0)?(0,Z.jsx)(pn,{icon:(0,Z.jsx)(ge,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,signedOut:g.signedOut,value:S,onPick:e=>{e!==S&&(a(e),s(null))}}):(0,Z.jsx)(ln,{icon:(0,Z.jsx)(ge,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:V?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:S,value:S,onPick:()=>{},options:[{value:S,label:S}]}),(0,Z.jsx)(ln,{icon:(0,Z.jsx)(Te,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:ne,value:I,readOnly:N,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=cn(e,M.data);R!==``&&un(R,t)===``&&l(``)},options:te.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:xn(S,j.data,M)}),(0,Z.jsx)(ln,{icon:(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:z,value:R,readOnly:N,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:L.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},u),continueWith:(e,t)=>B.mutateAsync({text:e,images:t})}}function qn({compact:e,summary:t,children:n}){let[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(null),o=e&&!r;return(0,X.useEffect)(()=>{r&&a.current?.querySelector(`button:not([disabled])`)?.focus()},[r]),(0,Z.jsx)(`div`,{ref:a,"data-slot":`follow-up-engine`,"data-folded":o||void 0,className:o?`min-w-0`:`session-engine-controls`,children:o?(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`follow-up-engine-summary`,"aria-expanded":!1,"aria-label":`Agent settings: ${t}`,title:`Change the runner, model or effort`,onClick:()=>i(!0),className:`inline-flex min-h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground transition-colors outline-hidden hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Z.jsx)(ge,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var Jn=120,Yn=e=>e!==`pending`&&e!==`running`,Xn=e=>e.kind===`tool`&&e.toolKind===`task`,Zn=e=>Xn(e)&&e.parentItemId===void 0,Qn=e=>Ie(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function $n(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 er(e){if(e.kind===`tool`)return tr(e.title);if(e.kind===`hook`)return tr(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
2
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return tr(n)}}}function tr(e){return e.length>Jn?`${e.slice(0,Jn-1).trimEnd()}…`:e}function nr(e,t=!1,n=e){let r=or(e,e=>e.items.some(Zn));if(r===-1)return[];let i=e=>!t&&!Yn(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(Zn);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(Zn)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>rr(r,ur(n,e,r.id),t))}function rr(e,t,n){let r={id:e.id,title:Fe(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=$n(e);i!==void 0&&(r.agentType=i),n&&!Yn(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=er(t[e]);if(n!==void 0){r.activity=n;break}}return r}function ir(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function ar(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function or(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function sr(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&Zn(e));if(a!==void 0)return rr(a,ur(r,e,t),n)}}function cr(e,t){return or(e,e=>e.items.some(e=>e.id===t&&Zn(e)))}function lr(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)Qn(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function ur(e,t,n){let r=cr(t,n);if(r===-1)return[];let i=lr(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of lr(e,n,Math.max(cr(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:dr(t,e))}return[...s.values()].sort(fr).map(({entry:e})=>e)}function dr(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function fr(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function pr(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?Ne(e.children).flatMap(n=>pr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>pr(e,t)):[]}function mr(e){return e.flatMap((e,t)=>e.content.kind===`block`?pr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function hr(e,t,n,r){let i=(0,X.useContext)(rn),{projectId:a}=G(),o=(0,X.useMemo)(()=>mr(t),[t]);(0,X.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=We(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=ke(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function gr(e){let t=R();return h({mutationFn:t=>B(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:d.runs.all})}})}var _r=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),vr=()=>navigator.onLine;function yr({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,Z.jsx)(xr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,Z.jsx)(br,{permission:e,runId:t},e.requestId)}function br({permission:e,runId:t}){let n=gr(t),r=(0,X.useSyncExternalStore)(_r,vr,()=>!1),i=(0,X.useRef)(!1),[a,o]=(0,X.useState)(`pending`),[s,c]=(0,X.useState)(),[l,u]=(0,X.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof A&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,Z.jsx)(xr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function xr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,X.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,Z.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,Z.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,Z.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,Z.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,Z.jsx)(J,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,Z.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}var Sr=(0,X.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Cr(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function wr(e,t,n=[]){let r={};for(let e of n)r[e.id]=Y(e);for(let e of t??[])r[e.id]=Y(e);return r[e.id]=Y(e),r}function Tr(e,t){return t?.[e]??`Task`}function Er(e,t,n){return t?n?.[e]??`peer task`:Tr(e,n)}function Dr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Or(e){return e?.relationship===`peer`}function kr(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Ar(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function jr(e){if(e.outcome)return Ar(e.outcome.status);if(e.delivery===`not-delivered`)return Mr(`not-delivered`)}function Mr(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Nr(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Or(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${vn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Pr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Tr(e,n),linkable:!0}):(0,Z.jsx)(Fr,{id:e,children:r})}function Fr({id:e,children:t}){let n=p(e);return n.data?t({title:Y(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof A&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Ir={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},Lr=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function Rr({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,Z.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,Z.jsx)(zr,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function zr({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Dr(e.messages[0]??{senderRunId:e.senderRunId},t),o=Or(e.messages[0]),s=Ir[o?`peer`:i],c=Jr(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),l=i===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>Er(e,o,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,Z.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":o?`peer`:`family`,"data-kind":e.kind,className:a(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes),children:[(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`p`,{className:a(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,Z.jsx)(`span`,{children:l}),c.map((e,t)=>(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,Z.jsx)(Pr,{id:e,peer:o,taskTitles:n,children:t=>(0,Z.jsx)(Wr,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),o?(0,Z.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,Z.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:kr(e.kind)}),e.messages.length===1&&d?(0,Z.jsx)(Vr,{message:d}):null]}),(0,Z.jsx)(Br,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,Z.jsx)(Ur,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Nr(e,r?.[e.recipientRunId])))].map(e=>e?(0,Z.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,Z.jsx)(Hr,{messages:e.messages,peer:o,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,Z.jsx)(Gr,{message:d,runId:t,taskTitles:n}):null,(0,Z.jsx)(Kr,{batch:e,heading:u})]})}function Br({at:e,className:t,children:n}){return e===void 0||pt(e)===void 0?null:(0,Z.jsxs)(`span`,{className:t,children:[n,(0,Z.jsx)(mt,{ts:e})]})}function Vr({message:e}){let t=jr(e),n=Mr(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,Z.jsxs)(Z.Fragment,{children:[t?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function Hr({messages:e,peer:t,runId:n,taskTitles:r}){return(0,Z.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=jr(e),a=e.createdAt??e.recordedAt;return(0,Z.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Pr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,Z.jsx)(Wr,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Mr(e.delivery)===i?null:(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Mr(e.delivery)}),(0,Z.jsx)(Gr,{message:e,runId:n,taskTitles:r}),(0,Z.jsx)(Br,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function Ur({batch:e}){let t=Be(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,X.useState)(()=>t?.get(n)??!1),a=(0,Z.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,Z.jsx)(Fn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,Z.jsxs)(Rt,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,Z.jsxs)(Lt,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(Ce,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,Z.jsx)(It,{children:a})]})}function Wr({view:e,to:t,label:n}){return e.linkable?(0,Z.jsx)(Vt,{className:Lr,to:t,"aria-label":n,children:e.title}):(0,Z.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function Gr({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:o}=(0,X.useContext)(Sr),s=e.requestId?r.get(e.requestId):void 0,c=e.requestId?s?[s]:[]:i.get(e.messageId)??[],l=e.requestId?`request`:`reply`;return c.length===0?e.requestId||e.outcome?.replyId?(0,Z.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,l,` is outside loaded history.`]}):null:c.map(e=>{let r=Dr(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:a(Lr,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>o(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,Z.jsx)(Pr,{id:i,peer:Or(e.message),taskTitles:n,children:e=>(0,Z.jsxs)(Z.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function Kr({batch:e,heading:t}){return(0,Z.jsxs)(Rt,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,Z.jsxs)(Lt,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,Z.jsx)(Ce,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,Z.jsx)(It,{children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>qr(e)).map((e,t)=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,Z.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function qr(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Or(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Mr(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function Jr(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var Yr=e(n(),1),Xr=`pending-ask`;function Zr(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function Qr(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?Zr(t):null}function $r(e,t){let n=`${Xr}:${e}`;return e=>{if(!t())return!1;let r=[...e.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);return r?Qr(r):null}}var ei=`[data-slot="ask-card"][data-pinned="true"]`;function ti(e,t){let[n,r]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!e||typeof IntersectionObserver>`u`||typeof MutationObserver>`u`)return;let n=t.current??document.body,i=null,a=null,o=()=>{let e=n.querySelector(ei);if(e===i)return;if(a?.disconnect(),i=e,!i){r(!1);return}let t=document.querySelector(`[data-slot="thread-dock"]`),o=t&&getComputedStyle(t).position===`sticky`?Math.round(t.getBoundingClientRect().height):0;a=new IntersectionObserver(e=>r(e.some(e=>e.isIntersecting)),{rootMargin:`0px 0px -${o}px 0px`}),a.observe(i)};o();let s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!0}),()=>{s.disconnect(),a?.disconnect()}},[e,t]),e&&n}function ni(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function ri({onGoToQuestion:e}){return(0,Z.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,Z.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}function ii(){let e=(0,X.useRef)(null);return(0,X.useLayoutEffect)(()=>{let t=e.current,n=t?.closest(`[data-slot="main"]`),r=t?.querySelector(`[data-slot="run-header"]`),i=t?.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),t=r.getBoundingClientRect();r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-t.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${ai(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function ai(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var oi={viewKey:void 0,generation:0},si=600,ci=24;function li(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,X.useRef)(a);o.current=a;let s=(0,X.useRef)(e);s.current=e;let c=(0,X.useRef)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),m=(0,X.useRef)(!0),h=(0,X.useRef)(!0),g=(0,X.useRef)(0),_=(0,X.useRef)(0),v=(0,X.useRef)(new Set),y=(0,X.useCallback)(e=>{for(let t of[...v.current])t(e)},[]),b=(0,X.useCallback)(e=>(v.current.add(e),()=>{v.current.delete(e)}),[]),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(e=>{let t=c.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,X.useCallback)(()=>{let e=c.current;if(!e)return;let t=h.current?o.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=h.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?ai(r):0;n?T(e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top-i-12):t>=0&&w.current?w.current.scrollToIndex(t,{align:`start`,offset:-i-12}):T(e.scrollHeight-e.clientHeight)},[T]),D=(0,X.useCallback)(()=>{if(c.current){if(C.current!==e){C.current=e,h.current=!0;let t=ze(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=Me(e)?.rowKeys?{viewKey:e,top:t.top}:null):(m.current=!0,x.current=null,S.current=null)}x.current===null?m.current&&E():T(x.current)}},[e,T,E]),O=(0,X.useCallback)(e=>S.current?.viewKey===e,[]),k=(0,X.useCallback)(e=>{let t=S.current;return!t||!O(e)||e!==s.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),ee=(0,X.useCallback)(e=>{d(e),e&&(c.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),D())},[n,D]),A=(0,X.useCallback)(()=>{m.current&&E()},[E]),j=(0,X.useRef)(!1),M=(0,X.useRef)(0),N=(0,X.useRef)(!1),P=(0,X.useRef)(void 0),F=(0,X.useRef)(!1),te=(0,X.useRef)(!1),I=(0,X.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),L=(0,X.useRef)(null),R=(0,X.useRef)(0);(0,X.useEffect)(()=>{if(!l())return;let e=e=>{x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let ne=(0,X.useCallback)(()=>{let e=L.current,t=c.current;if(!e||!t)return;L.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:o.current.indexOf(e.anchor.key),a=w.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):T(et(t.scrollTop,r,e.anchor,I(t),n))},[I,T]),z=(0,X.useCallback)(()=>{let e=c.current;if(!e||!r||j.current)return;x.current=null,S.current=null,m.current=!1,j.current=!0;let t=M.current+1;M.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,l=Ae(a,I(e)),u=l===void 0?-1:o.current.indexOf(l.key),d=s.current,f=R.current;r().then(()=>{s.current===d&&R.current===f&&(L.current={beforeHeight:n,beforeTop:i,anchor:l,anchorIndex:u})},()=>{}).finally(()=>{M.current===t&&(j.current=!1)})},[I,r]);(0,X.useEffect)(()=>()=>clearTimeout(P.current),[]);let B=(0,X.useRef)(null),V=(0,X.useRef)(0),H=(0,X.useCallback)(()=>n===`document`?++oi.generation:++V.current,[n]),U=(0,X.useCallback)((e,t)=>n===`document`?oi.viewKey===e&&oi.generation===t:s.current===e&&V.current===t,[n]);(0,X.useEffect)(()=>()=>B.current?.disconnect(),[e,u]);let re=(0,X.useCallback)((t,n,r,i)=>{let a=c.current;if(!a||!u)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0,p(!0),H(),B.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e&&(e.tabIndex=-1),t.focus({preventScroll:!0}),document.activeElement===t?(B.current?.disconnect(),!0):!1},l=a.querySelector(`[data-slot="run-header"]`),d=l&&getComputedStyle(l).position===`sticky`?ai(l):0,f=w.current;if(i!==void 0)T(i);else if(f)f.scrollToIndex(n,{align:`start`,...d>0?{offset:-d}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-d)}s()||(B.current=new MutationObserver(()=>{s()}),B.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Oe(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,H]),W=(0,X.useCallback)(t=>{let n=H(),r=s.current;B.current?.disconnect();let a=c.current;if(!a)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),Oe(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},l=()=>U(r,n),u=()=>{let e=t?.(a);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!l()||u())return;B.current?.disconnect();let e=new MutationObserver(()=>{l()?u()&&e.disconnect():e.disconnect()});B.current=e,e.observe(a,{childList:!0,subtree:!0})})})})},[i,e,E,H,U,y]),ie=a.at(-1),G=a.length;return(0,X.useLayoutEffect)(()=>{R.current+=1,L.current=null,j.current=!1,n===`document`?oi.viewKey!==e&&(oi.viewKey=e,oi.generation+=1):V.current+=1},[e,n]),(0,X.useLayoutEffect)(()=>{let e=L.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?ne():L.current=null:m.current&&E()},[ie,G,ne,E]),(0,X.useLayoutEffect)(()=>{!c.current||!u||D()},[u,D]),(0,X.useEffect)(()=>{let t=c.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,l,d=()=>{h.current&&!ft(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),l=e},v=()=>{H(),B.current?.disconnect(),x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,R.current+=1,L.current=null,g.current=Date.now()},C=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){v();let e=!N.current;N.current=!0,clearTimeout(P.current),P.current=setTimeout(()=>{N.current=!1},180),e&&Ue(t)&&z()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&Ue(t)&&z()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),b())},D=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,te.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(h.current=!1,x.current=null,S.current=null,ft(t,80)||(v(),b()))},k=()=>{i=!1},ee=e=>{F.current=!1,r=e.touches[0]?.clientY??null},A=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),v(),!F.current&&Ue(t)&&(F.current=!0,z())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},j=e=>{if(e===0||!i&&Date.now()-_.current>=si)return;let n=e<0?`up`:`down`;!i&&n!==l||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=ci&&(0,Yr.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},M=()=>{let n=m.current;j(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!te.current&&t.scrollTop<a&&Ue(t)&&(te.current=!0,z()),a=t.scrollTop;let r=ft(t,80);r&&x.current===null&&(m.current||Date.now()-g.current<2e3)&&(m.current=!0),!n&&m.current&&y({direction:`tail`}),p(!r),x.current===null&&!O(e)&&Oe(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,M,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,ee,{passive:!0}),t.addEventListener(`touchmove`,A,{passive:!0}),t.addEventListener(`pointerdown`,D,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,w);let I;if(typeof ResizeObserver<`u`){I=new ResizeObserver(()=>{let e=x.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;T(Math.min(e,n)),n>=e&&(x.current=null)}else m.current&&E()}),I.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&I.observe(r),i&&I.observe(i)}return()=>{t.removeEventListener(`scroll`,M),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,ee),t.removeEventListener(`touchmove`,A),t.removeEventListener(`pointerdown`,D),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,w),I?.disconnect()}},[e,u,z,T,E,O,H,y]),{attachContent:ee,scrollElRef:c,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:W,jumpToRow:re,loadOlder:z,restickIfStuck:A,subscribeReaderScroll:b}}function ui({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Z.jsx)(di,{runId:e,rows:t,controls:r}):(0,Z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function di({runId:e,rows:t,controls:n}){return(0,Z.jsx)(fi,{runId:e,rows:t,controls:n},e)}function fi({runId:e,rows:t,controls:n}){let r=(0,X.useRef)(null),i=(0,X.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,X.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,X.useState)(()=>Me(e)),[l,u]=(0,X.useState)(()=>({cache:je(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,X.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,X.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,X.useRef)(t.length);f.current=t.length;let p=(0,X.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,X.useRef)(null),h=(0,X.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||tt(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,X.useState)(0);return(0,X.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,Z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,Z.jsx)(An,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function pi({onJump:e,pendingQuestions:t=0}){return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-sm hover:text-foreground`,children:[(0,Z.jsx)(ye,{"aria-hidden":!0,className:`size-3.5`}),ni(t)]})}function mi(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function hi(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,mi(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function gi(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var _i=new WeakMap;function vi(e,t){let n=_i.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(_i.set(e,t),t)}function yi(e,t,n=t,r){let i=r==null?void 0:n.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===r&&!e.resolved),a=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),o=new Set,s=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),c=[];e.task&&c.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])c.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let l=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===l?xi(n.items):n.items;c.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:vi(n.items,hi(e,t.filter(t=>!e.task||!At(t,`opening`)).map(e=>e.kind===`ask`&&s.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?gi(e,r,i):e.kind===`permission`?(o.add(e.requestId),a.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let u=[...a.values()].filter(e=>e.status===`pending`&&!o.has(e.requestId));return u.length>0&&c.push({id:`pending-permissions`,entries:u,inDaySequence:!1}),i!==void 0&&c.push({id:Xr,entries:[{...i,placement:`pinned`}],inDaySequence:!1}),c}var bi=`changes ready for review`;function xi(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(bi)))}function Si(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function Ci(e,t){return[{id:`agent:${e}`,entries:t}]}function wi(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Ti(e,t){let n=[],r;for(let t of e){let e=wi(t),i=He(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 Ne(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 Ei({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,X.useMemo)(()=>Ti(n,e),[n,e]),p=li(`${e}:${t}`,{surface:r}),m=c??p;hr(e,f,m,r);let h=(0,X.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,X.useMemo)(()=>f.map(t=>({key:t.key,node:Di(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??Le(``,g.length),v=g.length===0?i??null:(0,Z.jsx)(ui,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,Z.jsx)(yt,{runId:e,children:(0,Z.jsx)(Re,{runId:e,children:(0,Z.jsx)(Sr.Provider,{value:h,children:r===`panel`?(0,Z.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,Z.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,Z.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,Z.jsx)(pi,{onJump:m.jumpToLatest})}):null]}):v})})})}function Di(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,Z.jsx)(Oi,{message:e.content.message,actions:t});case`day-separator`:return(0,Z.jsx)(dt,{ts:e.content.ts});case`turn-time`:return(0,Z.jsx)(qe,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,Z.jsx)(ki,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Ni(e.content)}}function Oi({message:e,actions:t}){return(0,Z.jsx)(Qe,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,Z.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,Z.jsx)(Pe,{ask:e.ask})}):void 0})}function ki({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,Z.jsx)(Ve.Provider,{value:`${t}:${e.entry.id}`,children:(0,Z.jsx)(ji,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,Z.jsx)(ot,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Z.jsx)(Ai,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,Z.jsx)(Je,{group:e,scope:t});case`streak`:return(0,Z.jsx)(rt,{count:e.count,children:e.blocks.map(e=>(0,Z.jsx)(ki,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,Z.jsx)(Rr,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Ni(e)}}function Ai({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return Ne(e).map(e=>(0,Z.jsx)(ki,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function ji({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,Z.jsx)(ct,{text:e.text,ts:e.ts}):(0,Z.jsx)(Qe,{text:e.text,ts:e.ts});case`reasoning`:return(0,Z.jsx)(Xe,{text:e.text});case`tool`:return(0,Z.jsx)(ot,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${Mr(e.delivery)}`:``]}),(0,Z.jsx)(Ge,{note:e})]}):(0,Z.jsx)(Ge,{note:e});case`conversation`:return(0,Z.jsx)(Rr,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,Z.jsx)(ut,{image:e});case`ask`:return n===void 0?(0,Z.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,Z.jsx)(yr,{permission:e,runId:i});case`provider-auth-required`:return(0,Z.jsx)(Ye,{incident:e});case`preview-server`:return(0,Z.jsx)(Mi,{entry:e});case`hook`:return(0,Z.jsx)(nt,{item:e,cacheKey:`${t}:${e.id}`});default:return Ni(e)}}function Mi({entry:e}){let t=wn(),n=E().data?.capabilities?.preview===!0;return(0,Z.jsx)(Nt,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function Ni(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Pi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,taskTitles:o,recipientBackends:s}){let c=(0,X.useContext)(rn),l=(0,X.useRef)(void 0),u=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{l.current?.()},[c,e]),(0,Z.jsx)(Qt,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,Z.jsx)(en,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{u.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,Z.jsx)(ht.Provider,{value:e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===r?.id);l.current?.(),l.current=c?.registerOpener(e,()=>{t?.focus({preventScroll:!0})}),u.current=!0,a()},children:(0,Z.jsx)(Fi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:o,recipientBackends:s})})})})}function Fi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Z.jsxs)($t,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,Z.jsxs)(nn,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(Ii,{status:r.status}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Z.jsx)(Ei,{runId:e,viewId:`agent:${r.id}`,sections:Ci(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,Z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function Ii({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,Z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:a(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function Li(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function Ri(e){return typeof e==`object`&&!!e&&!(0,X.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:i,aside:o,open:s,onToggle:c,className:l,children:u}){let d=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,Z.jsx)(`span`,{className:a(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(Ri(r)?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,Z.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,Z.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,Z.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:a(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,o,(0,Z.jsx)(ve,{"aria-hidden":!0,className:a(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!o&&`ms-auto`,s&&`rotate-180`)})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,o]}),f&&s?(0,Z.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function zi(e){return re(e.delegation)}function Bi(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function Vi(e){let t=e.delegation,n=zi(e),r=y(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=Bi(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function Hi(e){let t=y(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>Yt(e.status))}function Ui({run:e,open:t,onToggle:n}){let r=y(e.id),i=S(),o=mn(),s=e.delegation,c=new Map(r.data?.workers.map(e=>[e.workerId,e])),l=Bi(s,r.data),u=F(e)??P(e),d=u?Wi(e,u):void 0,f=e=>i.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),p=e=>{let t=f(e);return t?Y(t):`worker ${e.slice(0,8)}`};return(0,Z.jsx)(Q,{slot:`workers`,icon:(0,Z.jsx)(de,{className:`size-4`}),title:`Workers`,meta:Gi({ids:l,workers:c,desktop:o,query:r}),aside:r.data?.capacity?(0,Z.jsx)(Qi,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,Z.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,u?(0,Z.jsx)(Yi,{wait:u,dependencyLabel:d}):null,l.length>0?(0,Z.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:l.map(t=>{let n=c.get(t),i=f(t),o=n?qi(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,Z.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,Z.jsxs)(Vt,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(Ki,{status:n?.status}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate`,children:i?Y(i):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,Z.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,p(n.supervisorRunId)]}):null]}),(0,Z.jsx)(`span`,{className:a(`max-w-[45%] shrink-0 truncate text-xs`,Ji(n?.status)),children:o}),(0,Z.jsx)(pe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,Z.jsx)(ea,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,Z.jsx)(ia,{state:n.destroy}):null]},t)})}):zi(e)&&r.isSuccess?(0,Z.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,Z.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,Z.jsx)(J,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function Wi(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return M(e)??j(n.role,t,`requestIds`in t&&N(n,t.requestIds))}function Gi({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function Ki({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,Z.jsx)(me,{"aria-hidden":!0,className:a(t,`text-success`)}):e===`failed`?(0,Z.jsx)(K,{"aria-hidden":!0,className:a(t,`text-danger`)}):e===`cancelled`?(0,Z.jsx)(he,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,Z.jsx)(wt,{role:`status`,"aria-label":`Worker running`,className:a(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,Z.jsx)(q,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)})}function qi(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Ji(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Yi({wait:e,dependencyLabel:t}){return(0,Z.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,Z.jsxs)(Z.Fragment,{children:[` `,`Deadline: `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function Xi(e){return e.delegation?.role===`worker`&&P(e)?.phase===`wake-pending`}function Zi({run:e}){let t=P(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,Z.jsx)(Yi,{wait:t,dependencyLabel:j(`worker`,t)}):null}function Qi({capacity:e}){return(0,Z.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var $i=new Set([`review`,`done`,`failed`,`cancelled`]);function ea({parentRunId:e,worker:t}){let n=c(e),[r,i]=(0,X.useState)(!1);if(!$i.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof A?n.error.work:void 0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`break-words text-xs`,children:W(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,Z.jsx)(J,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,Z.jsx)(J,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,Z.jsx)(J,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,Z.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${na(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,Z.jsx)(J,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var ta=(e,t,n)=>`${e} ${e===1?t:n}`;function na(e){return[...e.uncommittedFiles?[ta(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${ta(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function ra(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function ia({state:e}){if(!ra(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,Z.jsx)(aa,{at:t.nextAt});return(0,Z.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,Z.jsxs)(Z.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,Z.jsxs)(Z.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function aa({at:e}){let t=tn(3e4);return(0,Z.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:In(t,Date.parse(e))})}function oa(e){let t=R(),[n,r]=(0,X.useState)(),i=Kt(e);(0,X.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=h({mutationFn:async()=>{r(e.id);try{if(!(await z(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:d.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function sa({agents:e,onSelect:t}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,Z.jsx)(ca,{agent:e,onSelect:t},e.id))})}function ca({agent:e,onSelect:t}){let n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(la,{status:e.status,stalled:e.stalled===!0}),(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:ar(e)}),(0,Z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,Z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,Z.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,Z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function la({status:e,stalled:t=!1}){return t?(0,Z.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function ua(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function da({entries:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,Z.jsx)(fa,{entry:e},`${t}:${e.content}`))})}function fa({entry:e}){return(0,Z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:a(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,Z.jsx)(pa,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,Z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function pa({status:e}){return e===`cancelled`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Z.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ma(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 ha(e,t){let n=ma(e);return n===`active`&&t===`waiting`?`paused`:n}function ga(e){return e===`active`?`running`:e}function _a(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 va({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=_a(e)*100;return(0,Z.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,Z.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":ha(n.status,t),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,Z.jsx)(ya,{visual:ha(n.status,t)}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:n.name}),n.iterations>1?(0,Z.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,Z.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function ya({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Z.jsx)(me,{"aria-hidden":!0,className:a(t,`text-success`)});case`active`:return(0,Z.jsx)(wt,{role:`status`,"aria-label":`Step running`,className:a(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(xe,{role:`img`,"aria-label":`Step paused`,className:a(t,ba)});case`failed`:return(0,Z.jsx)(K,{"aria-hidden":!0,className:a(t,`text-danger`)});case`pending`:return(0,Z.jsx)(q,{"aria-hidden":!0,className:a(t,`text-soft-foreground`)})}}var ba=`stroke-pending [html.light_&]:stroke-pending-strong`,xa={done:`done`,failed:`failed`,cancelled:`cancelled`};function Sa(e){let t=xa[e.status];return t?e.steps.map(e=>ma(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):Ca(e)}function Ca(e){let t=wa(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function wa(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ma(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function Ta({items:e,lead:t=0}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(-1/0);return(0,X.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,Z.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,Z.jsxs)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:[!a||t>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ea({run:e,references:t}){return(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,Z.jsx)(kt,{reference:t,taskTitle:Y(e),inert:!0},le(t)))})}function Da(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?_n(e.accounts,e.accountBackend)?`default`:void 0:e.known?_n(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Oa(e){let t=x(),n=m(),r=g(),{accounts:i}=Mn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,u=c?.backend??a,d=r.data?.profiles.find(e=>e.id===l&&e.provider===u),p=Da({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:d,accounts:i,accountBackend:u}),h=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?f(t.data,a):O(e.removedRunner),...p?{account:p}:{},model:o,effort:s,...h?{identity:h}:{}}}var ka=[`running`,`queued`,`waiting`];function Aa(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function $(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function ja(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function Ma(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Na(e){let t=Aa(e.waits),n=ka.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&Ma(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Aa(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Pa(e){return Na(e)!==void 0}function Fa(e){return(Na(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Ia({run:e}){let t=Na(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,Z.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,Z.jsx)(Ra,{run:e,wait:t},t.id):t.kind===`worker`?(0,Z.jsx)(za,{wait:t},t.id):t.kind===`process`?(0,Z.jsx)(Ga,{run:e,wait:t},t.id):t.kind===`peer`?(0,Z.jsx)(Ba,{wait:t},t.id):t.kind===`subagent`?(0,Z.jsx)(Va,{wait:t},t.id):t.kind===`plugin`?(0,Z.jsx)(Ha,{run:e,wait:t},t.id):(0,Z.jsx)(Ua,{run:e,wait:t},t.id)),i?(0,Z.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,Z.jsx)(Ra,{run:e,wait:r,settled:!0}):null,a?(0,Z.jsx)(Ga,{run:e,wait:a,settled:!0}):null]})}function La(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha.slice(0,7)} → ${r?.observedHeadSha?.slice(0,7)??`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?ja(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function Ra({run:e,wait:t,settled:n=!1}){let r=t.result,a=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=La(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=$(c),u=`${t.repository}#${t.prNumber}`;return(0,Z.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,Z.jsx)(`dd`,{children:s}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,Z.jsx)(`dd`,{className:`min-w-0`,children:i(t.prUrl)?(0,Z.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,Z.jsx)(`span`,{children:u})}),l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,Z.jsxs)(`dd`,{children:[a,` deadline unavailable`]})]})]})})}function za({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting on `,r,` `,i]}),a?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,Z.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function Ba({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting on `,t,` `,t===1?`task`:`tasks`]}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function Va({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,Z.jsxs)(`p`,{children:[`Check by`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function Ha({run:e,wait:t}){let n=t.phase===`open`?$(t.deadline):void 0;return(0,Z.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsx)(`p`,{children:t.phase===`resolved`?ja(t.summary,e):t.summary}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function Ua({run:e,wait:t}){let n=$(t.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,Z.jsx)(`p`,{children:ja(`Automatic check due`,e)}):n?(0,Z.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,Z.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,Z.jsx)(`p`,{children:t.note}):null]})}function Wa(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function Ga({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?Wa(t):t.phase===`resolved`?ja(Wa(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?$(t.deadline):void 0;return(0,Z.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsx)(`p`,{children:r}),i?(0,Z.jsxs)(`p`,{children:[`Until`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var Ka=new Map,qa=new Map;function Ja(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=St(e.run);return(0,Z.jsx)(Et,{projectId:t,repoBase:n,requests:i,children:(0,Z.jsx)(Ya,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!se(e.run)||!!oe(e.run,n)})})}function Ya({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,prNumbers:s,hasReferences:c,references:l}){let u=mn(),d=Oa(e),[f,p]=(0,X.useState)(()=>i?!1:Ka.get(e.id)??!1),m=fo(o,f),h=m.open,[g,_]=(0,X.useState)({}),v=Xa(e,t??n,n,r,s),y=bt(e),b=t=>g[t]??qa.get(`${e.id}:${t}`)??t===`workers`,x=t=>{let n=!b(t);qa.set(`${e.id}:${t}`,n),_(e=>({...e,[t]:n}))},S=e=>({open:b(e),onToggle:()=>x(e)});return(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:m.ref,"data-state":h?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Z.jsx)(to,{run:e,identity:d,activity:v,references:l,open:h,onToggle:()=>{Ka.set(e.id,!h),p(!h),m.chose(!h)}}),h?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,Z.jsx)(io,{run:e,activity:v,...S(`status`)}),(0,Z.jsx)(ao,{run:e,desktop:u,automations:v.automations,...S(`workflow`)}),(0,Z.jsx)(oo,{activity:v,desktop:u,onOpenWorker:a,...S(`subagents`)}),(0,Z.jsx)(so,{run:e,...S(`workers`)}),(0,Z.jsx)(co,{activity:v,desktop:u,...S(`plan`)}),(0,Z.jsx)(lo,{run:e,identity:d,activity:v,...S(`usage`)}),(0,Z.jsx)(uo,{run:e,references:l,conflicts:v.conflicts,hasReferences:c,onResume:()=>y.mutate(),...S(`workspace`)})]}):null]})}function Xa(e,t,n,r,i){let a=E(),o=Tn(a.data),s=S(),c=_t(e,{queuePosition:e.status===`queued`?qt(s.data??[]).get(e.id):void 0}),l=Ot(i),u=!Gt(e)&&e.status!==`queued`,d=(0,X.useMemo)(()=>r?nr(n.turns,u,t.turns):[],[r,n.turns,u,t.turns]),f=Ft(n)??[],p=Vi(e),m=ir(d),h=ua(f);return{line:c,...Za(e,c,p,r?m:void 0,h),...Qa(e,o),conflicts:l,waitReferences:Fa(e),agents:d,agentCounts:m,planEntries:f,planCounts:h,automations:Nn(a.data)}}function Za(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`||e.status===`cancelled`,glyph:o?(0,Z.jsx)(me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,Z.jsx)(Xt,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function Qa(e,t){return{cost:t.cost&&e.costUsd!==void 0?ce(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,Z.jsx)(yn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function $a(e){return e.allComplete?`text-success`:e.failed&&`text-danger`}function eo(e){let t=Sa(e),n=wa(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function to({run:e,identity:t,activity:n,references:r,open:i,onToggle:o}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[le(e),e])).values()];return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":no(e,t,n,c,i),onClick:o,className:a(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,Z.jsx)(Ee,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,Z.jsx)(ro,{run:e,identity:t,activity:n,summaryReferences:c}),i&&s?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:s}):null,(0,Z.jsx)(ve,{"aria-hidden":!0,className:a(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!s&&`ms-auto`,i&&`rotate-180`)})]})}function no(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=eo(e)?.step,u=l?`; step ${l.name}, ${ga(ha(l.status,e.status))}`:``,d=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${u}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${d}`}function ro({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:o,conflicts:s}=n,c=eo(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...o?[{id:`cost`,priority:1,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,children:o})}]:[],...r.length||s.length?[{id:`chips`,priority:0,content:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ea,{run:e,references:r}),s.length>0?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(be,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:a(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,$a(n)),children:[n.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),c?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-step`,className:a(`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,e.status===`waiting`&&`max-md:hidden`),children:[(0,Z.jsx)(go,{step:c,runStatus:e.status,decorative:!0}),(0,Z.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:c.name,className:`min-w-0 truncate`,children:c.name})]}):null,(0,Z.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,Z.jsx)(Ta,{items:l,lead:8})})]})}function io({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:o}=t,s=Xi(e);return(0,Z.jsxs)(Q,{slot:`status-row`,icon:t.glyph,title:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:a(`truncate`,$a(t)),children:t.statusText}),i.nextCheck?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,Z.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&o.length>0?(0,Z.jsx)(Ta,{items:[{id:`chips`,priority:0,content:(0,Z.jsx)(Ea,{run:e,references:o})}]}):void 0,open:n,onToggle:Pa(e)||s?r:void 0,children:[(0,Z.jsx)(Ia,{run:e}),s?(0,Z.jsx)(Zi,{run:e}):null]})}function ao({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=ue(e),o=eo(e);return!a&&!o?null:(0,Z.jsxs)(Q,{slot:`workflow`,icon:o?(0,Z.jsx)(go,{step:o.step,runStatus:e.status}):(0,Z.jsx)(we,{className:`size-4`}),title:(0,Z.jsxs)(Z.Fragment,{children:[`Workflow`,a?(0,Z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:Li(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,Z.jsx)(va,{steps:o.steps,runStatus:e.status}):null,(0,Z.jsx)(ho,{run:e,available:n})]})}function oo({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,Z.jsx)(Q,{slot:`subagents`,icon:(0,Z.jsx)(Se,{className:`size-4`}),title:`Subagents`,meta:Li(o.done,o.total,t),open:r,onToggle:i,children:(0,Z.jsx)(sa,{agents:a,onSelect:n})})}function so({run:e,open:t,onToggle:n}){return zi(e)?(0,Z.jsx)(Ui,{run:e,open:t,onToggle:n}):null}function co({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,Z.jsx)(Q,{slot:`plan`,icon:(0,Z.jsx)(fe,{className:`size-4`}),title:`Plan`,meta:Li(a.done,a.total,t),open:n,onToggle:r,children:(0,Z.jsx)(da,{entries:i})})}function lo({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,Z.jsx)(Q,{slot:`usage`,icon:(0,Z.jsx)(Ln,{className:`size-4`}),title:`Usage & agent`,summary:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(Ta,{items:c})}),open:r,onToggle:i,children:(0,Z.jsx)(mo,{run:e,tokens:o,cost:a})})}function uo({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||hn(e)||ra(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,Z.jsx)(Q,{slot:`workspace`,icon:(0,Z.jsx)(de,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(Ta,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,Z.jsx)(Ea,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,Z.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(be,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,Z.jsx)(ia,{state:s}):null,(0,Z.jsx)(vt,{run:e}),e.branch?(0,Z.jsx)(po,{label:`Branch`,children:(0,Z.jsx)(xt,{branch:e.branch})}):null,e.worktreePath?(0,Z.jsx)(po,{label:`Worktree`,children:(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,Z.jsx)(gt,{run:e,canResume:Cn(e).terminal,onResume:i})]})})}function fo(e,t){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(t);a.current=t;let o=(0,X.useRef)({active:!1,override:!1});return(0,X.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function po({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function mo({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Oa(e);return(0,Z.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,Z.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,Z.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function ho({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,Z.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,Z.jsx)(Vt,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:a(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,Z.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function go({step:e,runStatus:t,decorative:n=!1}){let r=ha(e.status,t),i=`size-4 shrink-0`;switch(r){case`active`:return(0,Z.jsx)(wt,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(xe,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,ba)});case`failed`:return(0,Z.jsx)(K,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-danger`)});case`pending`:return(0,Z.jsx)(q,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-soft-foreground`)});case`done`:return(0,Z.jsx)(me,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:a(i,`text-success`)})}}var _o=2e3;function vo(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function yo(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function bo(e,t){let n=R(),r=(0,X.useMemo)(()=>vo(t),[t]),i=(0,X.useMemo)(()=>yo(t),[t]),a=e?.id,o=e?.status;(0,X.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:d.runs.detail(a)}),n.invalidateQueries({queryKey:d.runs.list()})},_o);return()=>clearTimeout(e)},[r,i,a,o,n])}function xo(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function So({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,X.useState)(void 0),s=(0,X.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,X.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Si(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,xo);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}function Co(){let{id:e}=G(),t=p(e),n=Sn(e),r=t.data?.status,i=(0,X.useMemo)(()=>Mt(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,X.useMemo)(()=>Mt(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,X.useRef)(void 0),s=(0,X.useCallback)(e=>{o.current=e},[]),{mutate:c}=u();if((0,X.useEffect)(()=>{t.data&&o.current!==t.data.id&&Jt(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),bo(t.data,n.visibleEvents),t.isPending)return(0,Z.jsx)(Pn,{});if(t.isError){let e=t.error instanceof A&&t.error.status===404;return(0,Z.jsx)(an,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,Z.jsx)(on,{icon:e?(0,Z.jsx)(Dt,{}):(0,Z.jsx)(Rn,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,Z.jsx)(J,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(Vt,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Z.jsx)(Pn,{}):(0,Z.jsx)(To,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var wo=e=>({titles:Object.fromEntries(e.map(e=>[e.id,Y(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function To({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Bt();let a=ne({queryKey:d.runs.list(),queryFn:({signal:e})=>ee(_(),{signal:e}),select:wo}),{pendingAsk:c,transcriptAsk:l,pendingAskId:u,historyLoading:f}=Eo(r,n),p=k(e),m=jt(e.status,e.error,t),h=En(e),g=!h&&e.status!==`queued`,v=e.status===`queued`,x=Kn(e),S=oa(e),C=st(e.id),w=l||te(e),{hasContinuation:E,continuable:O}=Do(h,v,x),[A,j]=(0,X.useState)(void 0),[M,N]=(0,X.useState)(e.id);M!==e.id&&(N(e.id),j(void 0));let P=(0,X.useMemo)(()=>A===void 0?void 0:sr(n.turns,A,g,t.turns),[n.turns,A,g,t.turns]),F=(0,X.useMemo)(()=>A===void 0?[]:ur(t.turns,n.turns,A),[t.turns,n.turns,A]),I=b(e.id),L=sn(e),{providerBlocked:R,providerReason:z}=Oo(h,gn(e),E,x),{mutateAsync:B}=o(e.id),{mutateAsync:V}=D(e.id),{mutateAsync:H}=s(e.id),U=(0,X.useMemo)(()=>v?{onEditTask:async e=>{await B({task:e})},onEditMessage:(e,t)=>V({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>H(e).then(()=>void 0)}:void 0,[v,B,V,H]),re=f?void 0:u??null,W=(0,X.useMemo)(()=>yi(e,t,n,re),[e,t,n,re]),G=(0,X.useMemo)(()=>Ti(W,e.id),[W,e.id]),ae=e.delegation?.role===`root`||e.delegation?.role===`worker`,se=y(e.id,{enabled:ae}),ce=(0,X.useMemo)(()=>({...wr(e,void 0,se.data?.titles),...a.data?.titles,[e.id]:Y(e)}),[e,a.data,se.data]),le=(0,X.useMemo)(()=>({...a.data?.backends,...Cr(e,void 0)}),[e,a.data]),ue=(0,X.useCallback)(t=>(0,Z.jsx)(yr,{permission:t,runId:e.id,sessionOpen:h}),[e.id,h]),de=(0,X.useMemo)(()=>{if(U===void 0)return;let t={task:{onEdit:U.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>U.onEditMessage(n.id,e),onRemove:()=>U.onRemoveMessage(n.id)};return t},[U,e.queuedMessages]),fe=oe(e,T()),{search:pe}=ie(),me=Le(pe,G.length),K=li(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:G.map(({key:e})=>e)}),{pinnedAsk:he,pendingQuestions:ge}=ko(W),_e=So({pendingAskId:u,askSeq:r?c?.seq:void 0,rows:G,history:r,jumpToRow:K.jumpToRow}),ve=(0,X.useRef)(u);f||(ve.current=u);let q=(0,X.useRef)({rows:G,jumpToRow:K.jumpToRow,reveal:_e.reveal});q.current={rows:G,jumpToRow:K.jumpToRow,reveal:_e.reveal};let ye=(0,X.useCallback)(t=>t.placement===`origin`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.resolved&&t.context?(0,Z.jsx)(at,{text:t.context}):null,t.resolved?null:(0,Z.jsx)(ri,{onGoToQuestion:()=>{let{rows:e,jumpToRow:n}=q.current,r=Si(e,t.id,`pinned`);r&&n(r.key,r.index,e=>Qr(e))}})]}):(0,Z.jsx)(Ke,{ask:t,run:e,onShowOrigin:()=>q.current.reveal()}),[e]);zt(K.restickIfStuck);let be=ii();return(0,Z.jsxs)(an,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,flushPadding:!0,rootRef:be,rootProps:{"data-run-id":e.id},children:[(0,Z.jsx)(Ct,{run:e,onMarkedUnread:()=>i?.(e.id)}),(0,Z.jsx)(Ao,{run:e,thread:t,history:r,footer:m,issueUrl:fe,sections:W,renderAsk:ye,renderPermission:ue,messageActions:de,scroll:K,mode:me,taskTitles:ce,recipientBackends:le}),(0,Z.jsx)(lt,{status:e.status}),(0,Z.jsx)(Pi,{runId:e.id,renderAsk:ye,renderPermission:ue,agent:P,entries:F,taskTitles:ce,recipientBackends:le,onClose:()=>j(void 0)}),(0,Z.jsx)(jo,{run:e,thread:t,currentThread:n,currentComplete:r?.currentComplete??!0,scroll:K,pendingQuestions:ge,onJump:()=>{let e=ge>0?he?.id:void 0;K.jumpToLatest(e===void 0?void 0:$r(e,()=>ve.current===e))},onOpenWorker:j,sessionOpen:h,attention:p,queued:v,continuable:O,continueAction:x,stopAction:S,finishAction:C,needsAnswer:w,sendMessage:I,reply:L,providerBlocked:R,providerReason:z}),(0,Z.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function Eo(e,t){let n=e?Tt(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function Do(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function Oo(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function ko(e){let t=e.at(-1),n=t?.id===`pending-ask`?t.entries[0]:void 0;return{pinnedAsk:n,pendingQuestions:n?.kind===`ask`?n.questions.length:0}}function Ao({run:e,thread:t,history:n,footer:r,issueUrl:o,sections:s,renderAsk:c,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,Z.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,Z.jsx)(Io,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,Z.jsx)(Ei,{runId:e.id,viewId:`main`,sections:s,mode:`document`,renderAsk:c,renderPermission:l,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,Z.jsx)(Lo,{run:e}):(0,Z.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,Z.jsx)(Ze,{}):null,r&&r.state===`closed`?(0,Z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:a(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[r.label,i(se(e))?(0,Z.jsx)(`a`,{"data-slot":`pr-link`,href:se(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,i(o)?(0,Z.jsx)(`a`,{"data-slot":`issue-link`,href:o,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,Z.jsx)(it,{run:e}):null]})}function jo({run:e,thread:t,currentThread:n,currentComplete:r,scroll:i,pendingQuestions:a,onJump:o,onOpenWorker:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:_,providerBlocked:v,providerReason:y}){let b=ti(h&&a>0,i.scrollElRef);return(0,Z.jsxs)(`div`,{"data-slot":`thread-dock`,"data-pending-ask":h||void 0,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[i.pillVisible&&!b?(0,Z.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,Z.jsx)(pi,{pendingQuestions:a,onJump:o})}):null,(0,Z.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,Z.jsx)(Ja,{pendingAsk:h,run:e,thread:t,currentThread:n,currentComplete:r,onOpenWorker:s,readerScroll:i.subscribeReaderScroll},`${e.id}:${h}`),(0,Z.jsx)(Bn,{run:e}),e.status===`waiting`&&c?(0,Z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Xt,{tone:l.tone,shape:l.shape,pulse:l.pulse}),l.bucket===`permission`?`Choose an approval option above to continue`:l.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${l.label.charAt(0).toUpperCase()}${l.label.slice(1)} — you can send a message to resume`]}):null,u?(0,Z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Xt,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,d&&e.removedRunner!==void 0?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:I(e.removedRunner)}):d&&f.startsNewConversation?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,Z.jsx)(No,{run:e,thread:t,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,sessionOpen:c})]})]})}function Mo(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function No({run:e,thread:t,stopAction:n,finishAction:r,attention:i,needsAnswer:a,continuable:o,continueAction:s,queued:c,sendMessage:l,reply:u,providerBlocked:d,providerReason:f,sessionOpen:p}){let m=Hi(e);return(0,Z.jsx)(On,{...Mo(e,o,s),onStop:Cn(e,m).cancel?n.stop:void 0,onFinish:Dn(e)?()=>r.mutateAsync().catch(()=>void 0):void 0,finishing:r.isPending,stopOnEmpty:Po(e,i,a),stopping:n.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:o?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:o?s.pills:void 0,onSubmit:o?(e,t)=>s.continueWith(e,t):c?(e,t)=>l.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await u.send(e,t);if(n!==void 0)throw Error(n)},disabled:d||!p&&!c&&!o,disabledReason:d?f:`Session closed — no session to resume.`,footerEnd:d&&!s.providerPending?(0,Z.jsx)(Vt,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:o&&!a,emptySubmitVariant:e.status===`review`?`outline`:`primary`,emptySubmitLabel:o&&!a?`Continue`:void 0,placeholder:Fo(e,c,o),autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>Pt(t)})}function Po(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function Fo(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function Io({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Z.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,Z.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Z.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function Lo({run:e}){let t=jn(S().data??[],e.id);return(0,Z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Z.jsx)(Xt,{tone:`neutral`,shape:`ring`}),(0,Z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Co as TaskThreadRoute};