@hearsay-tools/squawk 0.19.0-dev.9155 → 0.19.0-dev.9160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-wait/controller.d.ts +7 -7
- package/dist/features/reports/routes.d.ts +2 -2
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/project-settings-routes.d.ts +107 -107
- package/dist/server/projects-routes.d.ts +41 -41
- package/dist/server/provider-sign-in-routes.d.ts +2 -2
- package/dist/server/repo-routes.d.ts +13 -13
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/runs-routes.d.ts +325 -325
- package/dist/server/server.d.ts +1195 -1195
- package/dist/server/workspace-identity-routes.d.ts +5 -5
- package/package.json +4 -4
- package/web/dist/assets/accounts-section-m_1ntZJh.js +1 -0
- package/web/dist/assets/activity-motion-DDqgr8eF.js +1 -0
- package/web/dist/assets/activity-route-BlEZZxyI.js +1 -0
- package/web/dist/assets/agent-accounts-D_ZKAmaW.js +1 -0
- package/web/dist/assets/{agent-config-section-D8pxNy2V.js → agent-config-section-wICtFVks.js} +2 -2
- package/web/dist/assets/agent-defaults-section-BC9Ypg0g.js +1 -0
- package/web/dist/assets/{appearance-D_t3wCjY.js → appearance-fkDdWPlG.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-C63xRNFZ.js → archive-on-merge-field-B6kX09p-.js} +1 -1
- package/web/dist/assets/{ask-card-kqWOqKIc.js → ask-card-Cue5EajQ.js} +5 -5
- package/web/dist/assets/attention-BI6592lk.js +1 -0
- package/web/dist/assets/{automation-format-DB34jUyF.js → automation-format-jKMOXcHS.js} +1 -1
- package/web/dist/assets/automations-route-BfOpJjLK.js +2 -0
- package/web/dist/assets/{badge-DVxxThpb.js → badge-DAnkqD7i.js} +1 -1
- package/web/dist/assets/{button-B22ANdCY.js → button-BV_AiLj2.js} +1 -1
- package/web/dist/assets/{centered-state-BgSV4e79.js → centered-state-N8vWM_Hw.js} +1 -1
- package/web/dist/assets/{cez-idle-CdswdDRd.js → cez-idle-C0drOeLs.js} +1 -1
- package/web/dist/assets/{change-counts-wqSYI3W8.js → change-counts-BLLRvt46.js} +1 -1
- package/web/dist/assets/chunk-KS7C4IRE-BdLLx37K.js +3 -0
- package/web/dist/assets/{code-editor-GfQChdgl.js → code-editor-DZMD1guX.js} +1 -1
- package/web/dist/assets/{code-workbench-CUkiQ1pF.js → code-workbench-B0GIezrD.js} +1 -1
- package/web/dist/assets/{collapsible-Bx2vViFx.js → collapsible-D5i3hm2L.js} +1 -1
- package/web/dist/assets/{command-B2Y0By1v.js → command-4D8sPZJy.js} +1 -1
- package/web/dist/assets/{commit-list-Bjc-pQxv.js → commit-list-StLehTiQ.js} +1 -1
- package/web/dist/assets/{dialog-rpNyAWGb.js → dialog-DKr-j9S6.js} +1 -1
- package/web/dist/assets/diff-DEw-tkVq.js +3 -0
- package/web/dist/assets/{diff-controls-CaCUSyxs.js → diff-controls-CSO8HgZ0.js} +1 -1
- package/web/dist/assets/{diff-stat-Dy4uLuyP.js → diff-stat-DCO_BkZB.js} +1 -1
- package/web/dist/assets/{diff-view-4wxDvYXE.js → diff-view-BcU4Rnuo.js} +3 -3
- package/web/dist/assets/discard-changes-dialog-BEsdWdyJ.js +1 -0
- package/web/dist/assets/{dist-BSUJIXeE.js → dist-B2_vvox1.js} +1 -1
- package/web/dist/assets/dist-CCX8mhHc.js +1 -0
- package/web/dist/assets/{dist-BuF3mvCA.js → dist-ClMNSUvT.js} +1 -1
- package/web/dist/assets/{dist--f2yFdPY.js → dist-CyFJ-9Ex.js} +1 -1
- package/web/dist/assets/{dist-DudPJH39.js → dist-Du6flkGD.js} +1 -1
- package/web/dist/assets/{dropdown-menu-DjtKUK8F.js → dropdown-menu-NJZfnQCU.js} +1 -1
- package/web/dist/assets/{es2015-CUEfzDjB.js → es2015-BHonSvOU.js} +1 -1
- package/web/dist/assets/file-preview-_4nAs_Ai.js +2 -0
- package/web/dist/assets/{folder-browser-Civftk0W.js → folder-browser-CFd1U5hn.js} +1 -1
- package/web/dist/assets/{git-toolbar-CepvG0Ng.js → git-toolbar-DXnIUFi1.js} +1 -1
- package/web/dist/assets/github-g-Ykk4uE.js +1 -0
- package/web/dist/assets/{global-activity-route-DhmrWj31.js → global-activity-route-OsAvUny-.js} +2 -2
- package/web/dist/assets/highlighter-Crq-WTmN.js +3 -0
- package/web/dist/assets/host-context-DDbYAKpm.js +1 -0
- package/web/dist/assets/host-storage-B72yoDU1.js +1 -0
- package/web/dist/assets/hosts-CpDMDiQW.js +1 -0
- package/web/dist/assets/{html-report-frame-Ck76gKfA.js → html-report-frame-Bk6UkqKa.js} +1 -1
- package/web/dist/assets/{image-preview-CeEKI2T5.js → image-preview-CdL9a1Zj.js} +1 -1
- package/web/dist/assets/index-D_WkVdwL.css +1 -0
- package/web/dist/assets/index-Dp7K74Jw.js +21 -0
- package/web/dist/assets/label-CgU9vxuM.js +1 -0
- package/web/dist/assets/{live-protocol-DMhTnCmf.js → live-protocol-CNUmr-VT.js} +1 -1
- package/web/dist/assets/markdown-BB-PN03o.js +2 -0
- package/web/dist/assets/{middle-truncated-name-D41ibfXD.js → middle-truncated-name-jUQS2QzL.js} +1 -1
- package/web/dist/assets/{nav-row-styles-CgP5uNp4.js → nav-row-styles-CIedRn3A.js} +1 -1
- package/web/dist/assets/{open-in-menu-CbQWVBD0.js → open-in-menu-BI7mnPPf.js} +1 -1
- package/web/dist/assets/{option-select-BwSkbCrQ.js → option-select-Bmm4ktgQ.js} +1 -1
- package/web/dist/assets/{page-shell-BgabWJ3w.js → page-shell-BdjH5hyc.js} +1 -1
- package/web/dist/assets/{popover-CvL6hQ5c.js → popover-BQolmvDR.js} +1 -1
- package/web/dist/assets/{preferences-section-Cvh644K0.js → preferences-section-dKDCZSWD.js} +1 -1
- package/web/dist/assets/preview-EtD19mg1.js +1 -0
- package/web/dist/assets/preview-pane-connected-DBbCXW1b.js +3 -0
- package/web/dist/assets/{project-location-DR8go8oL.js → project-location-DJjcFmsE.js} +1 -1
- package/web/dist/assets/project-router-Dc6KBQsv.js +1 -0
- package/web/dist/assets/projects-section-CVFyzORg.js +1 -0
- package/web/dist/assets/{prompt-templates-section-DcxD28iA.js → prompt-templates-section-Jj1YbCwG.js} +2 -2
- package/web/dist/assets/queries-IlC9MZgh.js +1 -0
- package/web/dist/assets/{read-state-c_RNJaXO.js → read-state-BeVNfGkB.js} +1 -1
- package/web/dist/assets/{reference-chip-z7dZJVH-.js → reference-chip-BjerVjzM.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-Dtaa3ovl.js → remote-settings-notice-Czl9yS5W.js} +1 -1
- package/web/dist/assets/repo-git-C9N9wa5l.js +1 -0
- package/web/dist/assets/{report-reader-mbkd2DKt.js → report-reader-Ci4sWoe1.js} +1 -1
- package/web/dist/assets/report-selection-CZ8eb9QP.js +1 -0
- package/web/dist/assets/reports-CQPRtR5G.js +1 -0
- package/web/dist/assets/{resources-section-g5XRlefz.js → resources-section-lLpdP6MD.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-BdBvLP6E.js → review-notes-drafts-BjXqp0gY.js} +1 -1
- package/web/dist/assets/{review-panel-Ba8yb8Fu.js → review-panel-B4dp-Rol.js} +1 -1
- package/web/dist/assets/{review-strip-CdlMeV2i.js → review-strip-BE71YjB6.js} +1 -1
- package/web/dist/assets/{run-detail-refresh-C5qmRdgD.js → run-detail-refresh-CE0vyYYA.js} +1 -1
- package/web/dist/assets/{run-diff-BDMdnSv7.js → run-diff-ClfLRsHF.js} +3 -3
- package/web/dist/assets/run-header-DvbVw3uo.js +2 -0
- package/web/dist/assets/{select-DdH25sWT.js → select-CYo1lo6a.js} +1 -1
- package/web/dist/assets/{session-context-section-BqEdLdTv.js → session-context-section-B_NEOGby.js} +2 -2
- package/web/dist/assets/{settings-agent-picker-b4M6fQ8m.js → settings-agent-picker-DeAST7qR.js} +1 -1
- package/web/dist/assets/{settings-field-Bhh8I9fJ.js → settings-field-AyinSFR_.js} +1 -1
- package/web/dist/assets/{settings-list-detail-D3ibaYUj.js → settings-list-detail-BlEEuyae.js} +1 -1
- package/web/dist/assets/settings-save-bar-Dd3bTznK.js +1 -0
- package/web/dist/assets/{settings-shell-BUwdvhI9.js → settings-shell-Bt7NYun7.js} +1 -1
- package/web/dist/assets/sidebar-section-DdrFJBTL.js +1 -0
- package/web/dist/assets/{skills-BLkPhZO8.js → skills-DNCuhhKf.js} +1 -1
- package/web/dist/assets/status-dot-Bmn4xhch.js +1 -0
- package/web/dist/assets/{switch-CAKeV99j.js → switch-B9OfOEzC.js} +1 -1
- package/web/dist/assets/{tab-link-BKlpD9sn.js → tab-link-6TltE1jl.js} +1 -1
- package/web/dist/assets/{task-changes-Drvnew5P.js → task-changes-CdAzeh9M.js} +2 -2
- package/web/dist/assets/{task-commits-1MJHuX1i.js → task-commits-CzZJZj2x.js} +1 -1
- package/web/dist/assets/{task-file-scope-CB3L3KQl.js → task-file-scope-BuFeMG6a.js} +1 -1
- package/web/dist/assets/task-files-BFdMVAb3.js +1 -0
- package/web/dist/assets/{task-github-item-CMNk7FxR.js → task-github-item-Dv0Uflz7.js} +1 -1
- package/web/dist/assets/{task-groups-CGCnVqHE.js → task-groups-DCg4iOB9.js} +1 -1
- package/web/dist/assets/task-thread-C98mqSie.js +2 -0
- package/web/dist/assets/{textarea-vEsJAUAV.js → textarea-BGp28xFr.js} +1 -1
- package/web/dist/assets/thread-state-DqBwIoCM.js +4 -0
- package/web/dist/assets/toaster-DNnL8v10.js +4 -0
- package/web/dist/assets/{tool-display-B9NN44oU.js → tool-display-CTbToGmi.js} +1 -1
- package/web/dist/assets/use-finish-run-CFEVvqeg.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-BYN578_s.js +1 -0
- package/web/dist/assets/use-path-bases-B238cLk1.js +1 -0
- package/web/dist/assets/{use-search-params-writer-ClMScnNe.js → use-search-params-writer-DD5PEEZw.js} +1 -1
- package/web/dist/assets/use-workspace-config-save-DScW6_8J.js +1 -0
- package/web/dist/assets/{workflows-BUcx-n8J.js → workflows-IT5WTfLr.js} +3 -3
- package/web/dist/assets/{workspace-tools-dbiR1fzO.js → workspace-tools-D_opTe6D.js} +1 -1
- package/web/dist/assets/{worktrees-section-Dyb_QkSd.js → worktrees-section-B8ycJMoK.js} +4 -4
- package/web/dist/assets/zoomable-image-CULOtYYp.js +1 -0
- package/web/dist/index.html +41 -37
- package/web/dist/live-worker.js +2 -2
- package/web/dist/assets/accounts-section-BsgnDmow.js +0 -1
- package/web/dist/assets/activity-motion-Ckq9kC3I.js +0 -1
- package/web/dist/assets/activity-route-5S9WhN9U.js +0 -1
- package/web/dist/assets/agent-accounts-D_7QcFSx.js +0 -1
- package/web/dist/assets/agent-defaults-section-et5LHv9W.js +0 -1
- package/web/dist/assets/attention-DnxGjw_R.js +0 -1
- package/web/dist/assets/automations-route-B5YBpGMc.js +0 -2
- package/web/dist/assets/chunk-KS7C4IRE-Cg8l-LDN.js +0 -3
- package/web/dist/assets/diff-lwWO-At7.js +0 -3
- package/web/dist/assets/discard-changes-dialog-B3gvm7lX.js +0 -1
- package/web/dist/assets/dist-C_rn70hE.js +0 -1
- package/web/dist/assets/file-preview-98pJhZJj.js +0 -2
- package/web/dist/assets/github-4Jhl7lLG.js +0 -1
- package/web/dist/assets/highlighter-Cfo7mLVB.js +0 -3
- package/web/dist/assets/index-BK1FcZrA.css +0 -1
- package/web/dist/assets/index-DJB0lid-.js +0 -21
- package/web/dist/assets/label-feCJ3WOT.js +0 -1
- package/web/dist/assets/markdown-BAPhDASs.js +0 -2
- package/web/dist/assets/preview-pane-connected-B08ZdGux.js +0 -3
- package/web/dist/assets/project-router-j0uBi7Ep.js +0 -1
- package/web/dist/assets/projects-section-XDboHBFP.js +0 -1
- package/web/dist/assets/queries-CchoEEzj.js +0 -1
- package/web/dist/assets/repo-git-Dp9R2TuI.js +0 -1
- package/web/dist/assets/report-selection-BdGxjISG.js +0 -1
- package/web/dist/assets/reports-ya2OW-iR.js +0 -1
- package/web/dist/assets/run-header-BTRXYB4W.js +0 -2
- package/web/dist/assets/settings-save-bar-DFY_Km4X.js +0 -1
- package/web/dist/assets/sidebar-section-CcucfASN.js +0 -1
- package/web/dist/assets/status-dot-Drd4-nfa.js +0 -1
- package/web/dist/assets/task-files-B9okW1TC.js +0 -1
- package/web/dist/assets/task-thread-_2ch8BRt.js +0 -2
- package/web/dist/assets/thread-state-qNczqxZQ.js +0 -4
- package/web/dist/assets/toaster-zMN8cNZQ.js +0 -4
- package/web/dist/assets/use-finish-run-Dvm4JnAH.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-CBJvP-US.js +0 -1
- package/web/dist/assets/use-path-bases-C9yvZF5B.js +0 -1
- package/web/dist/assets/use-workspace-config-save-9jm9qV6u.js +0 -1
- package/web/dist/assets/zoomable-image-BUTgYpld.js +0 -1
|
@@ -1,2 +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{o as r,s as i}from"./dist-C_rn70hE.js";import{G as a,H as o,J as s,St as c,U as l,Ut as u,V as d,W as f,bt as p,cn as m,ct as h,d as g,et as _,ln as v,nn as y,nt as ee,un as b,vt as te,xt as x}from"./queries-CchoEEzj.js";import{Bt as ne,Nn as re,Rn as S,Sr as ie,dr as ae,ft as C,lr as oe,n as w,rt as T,vi as se,zt as E}from"./toaster-zMN8cNZQ.js";import{C as ce,S as le,T as ue,b as de,g as fe,i as pe,m as me,n as he,p as ge,t as D,x as _e}from"./reference-chip-z7dZJVH-.js";import{I as ve,S as ye,Y as be,Z as xe,a as Se,ct as Ce,m as we,mt as Te,o as Ee,st as De,t as Oe,u as ke,y as O}from"./design-icons-QbNMZniQ.js";import{t as k}from"./createLucideIcon-BHp8sXmF.js";import{t as Ae}from"./app-window-CSHwDX9N.js";import{n as je,r as Me,t as Ne}from"./open-in-menu-CbQWVBD0.js";import{t as Pe}from"./info-DA1x_4bz.js";import{t as Fe}from"./message-square-B-MD-8rD.js";import{t as Ie}from"./square-terminal-B6RYYieR.js";import{t as A}from"./button-B22ANdCY.js";import{a as j,i as M,l as N,n as P,p as F,r as I,t as L}from"./dropdown-menu-DjtKUK8F.js";import{n as Le,r as Re,t as ze}from"./popover-CvL6hQ5c.js";import{a as Be,i as Ve,o as He,r as Ue,s as We,t as Ge}from"./dialog-rpNyAWGb.js";import{c as Ke,s as qe,t as R}from"./project-router-j0uBi7Ep.js";import"./attention-DnxGjw_R.js";import{T as Je,f as z,u as Ye}from"./task-groups-CGCnVqHE.js";import{t as B}from"./status-dot-Drd4-nfa.js";import{t as Xe}from"./format-BU7D3IfE.js";import{a as Ze}from"./agent-accounts-D_7QcFSx.js";import{An as V,Cn as H,Dr as Qe,J as $e,Rn as et,Sn as U,Xn as tt,Y as W,_ as nt,a as rt,an as it,cn as at,fn as ot,g as st,hr as ct,in as lt,ir as ut,ln as dt,mn as ft,mr as G,nn as pt,nr as mt,o as ht,on as gt,q as _t,r as K,rn as vt,rr as q,sn as yt,vn as bt,yr as xt}from"./index-DJB0lid-.js";import{t as St}from"./textarea-vEsJAUAV.js";import{t as Ct}from"./markdown-BAPhDASs.js";import{t as wt}from"./task-file-scope-CB3L3KQl.js";import{t as J}from"./tab-link-BKlpD9sn.js";var Tt=k(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Et=k(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Dt=k(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Ot=k(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Y=e(t(),1),X=n();function kt(e){let t=h();return b({mutationFn:t=>T(v(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>m()),onError:e=>w(e.message,{tone:`danger`})})}var At={archive:{full:`Archive task`,compact:`Archive`},unarchive:{full:`Unarchive`,compact:`Unarchive`}};function jt(e){return At[e.archived?`unarchive`:`archive`].full}function Mt(e){return At[e.archived?`unarchive`:`archive`].compact}function Nt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(pt,{open:t,onOpenChange:n,children:(0,X.jsxs)(it,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(at,{children:[(0,X.jsx)(dt,{children:`Archive task?`}),(0,X.jsxs)(gt,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:z(e),children:z(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(yt,{children:[(0,X.jsx)(lt,{children:`Cancel`}),(0,X.jsx)(vt,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Pt({run:e,className:t,compact:n=!1}){let[i,a]=(0,Y.useState)(!1),o=kt(e.id),s=jt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(A,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":s,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:o.isPending,className:r(`gap-[7px] px-3`,t),onClick:()=>e.archived?o.mutate(!1):a(!0),children:[e.archived?(0,X.jsx)(Qe,{"aria-hidden":`true`}):(0,X.jsx)(Oe,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:n?Mt(e):s})]}),(0,X.jsx)(Nt,{run:e,open:i,onOpenChange:a,onConfirm:()=>{o.mutate(!0),a(!1)}})]})}function Ft({phone:e}){return e?(0,X.jsx)(Ee,{"aria-hidden":`true`}):null}function It({run:e,action:t,prUrl:n,patch:r,phone:a}){let o=t.phase===`blocked`;return{key:`completion`,heading:o?`Completion blocked`:`Completion pending`,reason:t.message||(o?`Completion needs attention.`:`Checking completion actions.`),pending:!o,actions:(0,X.jsxs)(X.Fragment,{children:[n&&i(n)?(0,X.jsx)(A,{variant:`outline`,asChild:!0,children:(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:[`Open PR`,(0,X.jsx)(Ft,{phone:a})]})}):null,e.autoMergePr?(0,X.jsx)(A,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>w(e.message,{tone:`danger`})}),children:r.isPending?`Saving…`:`Disable auto-merge`}):null]})}}function Lt({run:e,blocker:t,flags:n,phone:r}){return{key:`archive`,heading:`Archive blocked`,reason:t.message,actions:(0,X.jsxs)(X.Fragment,{children:[t.runId?(0,X.jsx)(A,{variant:`outline`,asChild:!0,children:(0,X.jsx)(R,{to:`/tasks/${t.runId}`,"aria-label":r?`Open task that blocks the archive`:void 0,children:r?`Open task`:`Open blocking task`})}):null,t.pullRequestUrl&&i(t.pullRequestUrl)?(0,X.jsx)(A,{variant:`outline`,asChild:!0,children:(0,X.jsxs)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":r?`Open PR that blocks the archive`:void 0,children:[r?`Open PR`:`Open blocking PR`,(0,X.jsx)(Ft,{phone:r})]})}):null,n.archive?(0,X.jsx)(Pt,{run:e,compact:r}):null]})}}function Rt({heading:e,reason:t,className:n,hideHeading:i}){return(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:r(`text-sm [overflow-wrap:anywhere]`,n),children:[i?(0,X.jsxs)(`span`,{className:`sr-only`,children:[e,` · `]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e}),` · `]}),t]})}function zt({blocks:e}){return(0,X.jsx)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-card-edge bg-card p-3 shadow-card [margin-block:0.75rem]`,children:e.map(e=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Rt,{heading:e.heading,reason:e.reason}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions})]},e.key))})}function Bt({blocks:e}){let[t,n]=(0,Y.useState)(!1),i=(0,Y.useId)(),[a]=e;if(!a)return null;let o=e.length-1;return(0,X.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`-mx-4 min-w-0 border-b border-card-edge bg-card`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-slot":`completion-status-toggle`,"aria-expanded":t,"aria-controls":i,onClick:()=>n(e=>!e),className:`flex min-h-11 w-full items-center gap-2 px-4 text-start text-sm outline-hidden focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/50`,children:[a.pending?(0,X.jsx)(xe,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}):(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`size-4 shrink-0 text-semantic-amber`}),(0,X.jsx)(`span`,{className:`shrink-0 font-medium`,children:a.heading}),t?(0,X.jsx)(`span`,{className:`flex-1`}):(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[`· `,a.reason]}),o>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-muted-foreground`,children:[`+`,o]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[`and `,o,` more`]})]}):null,(0,X.jsx)(ke,{"aria-hidden":`true`,className:r(`size-4 shrink-0 text-muted-foreground`,t&&`rotate-180`)})]}),(0,X.jsx)(`div`,{id:i,className:r(t&&`grid gap-2 px-4 pb-3`),children:e.map((e,n)=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Rt,{heading:e.heading,reason:e.reason,className:r(!t&&`sr-only`),hideHeading:n===0}),t?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions}):null]},e.key))})]})}function Vt({run:e}){let t=f(e.id),n=q(),r=H(e),i=e.status===`done`?e.completionAction:void 0,a=r.archive?e.archiveBlocker:void 0,o=i&&i.phase!==`complete`?i:void 0;if(!o&&!a)return null;let s=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url,c=!n,l=[o?It({run:e,action:o,prUrl:s,patch:t,phone:c}):void 0,a?Lt({run:e,blocker:a,flags:r,phone:c}):void 0].filter(e=>e!==void 0);return n?(0,X.jsx)(zt,{blocks:l}):(0,X.jsx)(Bt,{blocks:l})}var Ht=[`running`,`queued`,`waiting`];function Ut(e,{queuePosition:t,now:n=new Date}){let r=re(e),i=et(e,r).label,a=t===void 0?i:`${i} #${t}`,o=Ht.includes(e.status)?Gt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Wt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Gt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Xe(n,t)}}async function Z(e,t){try{await navigator.clipboard.writeText(e),w(t)}catch{w(`Run manually: ${e}`)}}function Kt(e){let t=p(),n=g(),r=(0,Y.useMemo)(()=>ue(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>ge(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function qt(e){return b({mutationFn:()=>ne(e.id),onError:e=>{if(e instanceof S&&e.command){Z(e.command,`No terminal found — command copied to clipboard.`);return}w(e.message,{tone:`danger`})}})}function Q(e,t){let n=l(),r=c(),i=y(),a=b({mutationFn:t=>E(e.id,t),onError:e=>w(e.message,{tone:`danger`})}),o=Ze(),s=Je(e),u=o.runnersOn(e=>t&&s.sessionId!==void 0&&e===s.backend?s.profileId??`default`:o.repoAccount?.[e]).runners,d=e=>!r.isSuccess||!i.isSuccess||u.includes(e??`claude`);return{canResumeHere:t&&d(bt(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=je(e.id);return t===void 0||i.isSuccess&&d(t)}).map(t=>({target:t,...ft(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function Jt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=y().data,s=U(e);return!r&&i.length===0&&!s?null:(0,X.jsxs)(X.Fragment,{children:[r||i.length>0?(0,X.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,X.jsxs)(A,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,X.jsx)(Ie,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=Me(e,o);return(0,X.jsxs)(A,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,X.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,X.jsxs)(A,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>w(`Worktree path copied`)).catch(()=>w(`Path: ${t}`))},children:[(0,X.jsx)(O,{}),`Copy worktree path`]}):null]}):null,s?(0,X.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,X.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,X.jsxs)(A,{variant:`outline`,onClick:()=>void Z(s,`Command copied to clipboard.`),children:[(0,X.jsx)(O,{}),`Copy resume command`]})]}):null]})}function Yt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=U(e),s=e.worktreePath;return!r&&i.length===0&&!o&&!s?null:(0,X.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,X.jsx)(Ne,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,leading:r?(0,X.jsxs)(M,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(Ie,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,X.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void Z(s,`Worktree path copied`),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,X.jsxs)(A,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,onClick:()=>void Z(o,`Command copied to clipboard.`),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function Xt({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Q(e,t);return!a&&o.length===0?null:r?(0,X.jsx)(M,{onSelect:r,children:`Open in…`}):(0,X.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,X.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,X.jsx)(Te,{})})]}),e.worktreePath?(0,X.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Jt,{run:e,canResume:t,onResume:n})})]})}function Zt({branch:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{w(`Could not copy branch. Select and copy: ${e}`)}};return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-xs font-medium break-all`,children:e}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,X.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function Qt({run:e}){let t=p(),n=g(),r=r=>n===void 0?void 0:_e(n,e.id,r,t),a=(0,Y.useMemo)(()=>ue(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,X.jsx)(D,{reference:t,to:r(t),taskTitle:z(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(ot,{run:e,prNumber:t.number})},fe(t)));let l=ce(e);l&&i(l)&&!c.some(e=>e.url===l)&&o.push((0,X.jsx)(D,{reference:{kind:`PR`,url:l},taskTitle:z(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,X.jsx)(D,{reference:t,to:r(t),taskTitle:z(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},fe(t)));let d=de(e,t);if(d&&i(d)&&!u.some(e=>e.url===d)){let t=me(d);s.push((0,X.jsx)(D,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?r({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:z(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,X.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function $t(){let e=qe(),t=x();return _t(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var $=e=>e.map(e=>`${e.name}: ${$e(e.url)}`).join(`
|
|
2
|
-
`);function en(e){let t=tt(),n=$t(),r=n.length>0,i=o(e.id),[a,s]=(0,Y.useState)(null),c=e.notify===!0,l=()=>i.mutate({notify:!1},{onSuccess:()=>w(`Stopped notifying the webhook`),onError:e=>w(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),u=r?(0,X.jsx)(an,{mode:a,targets:n,pending:i.isPending,onOpenChange:e=>!e&&s(null),onSubmit:e=>i.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{s(null),w(a===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>w(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null;return{visible:t!==`absent`&&(r||c),notifying:c,reachable:r,targets:n,pending:i.isPending,open:s,stop:l,dialog:u}}function tn({run:e}){let t=en(e);if(!t.visible)return null;let{notifying:n,reachable:r,targets:i}=t;return(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsxs)(L,{children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(A,{variant:`outline`,"data-slot":`notifying-chip`,className:`gap-1.5`,"aria-label":r?`Notifying ${W(i)} — webhook actions`:`Notifying — webhook actions`,title:r?$(i):void 0,children:[(0,X.jsx)(B,{tone:`success`}),(0,X.jsx)(`span`,{children:`Notifying`}),(0,X.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,X.jsxs)(I,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[r?(0,X.jsx)(j,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-xs font-normal text-muted-foreground`,children:i.map(e=>(0,X.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:$e(e.url),children:e.name},e.id))}):null,r?(0,X.jsxs)(M,{className:`min-h-11`,onSelect:()=>t.open(`note`),children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,X.jsxs)(M,{variant:`destructive`,className:`min-h-11`,disabled:t.pending,onSelect:t.stop,children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,X.jsxs)(A,{variant:`outline`,"data-action":`handoff`,className:`max-md:px-0`,"aria-label":`Hand off to webhook`,onClick:()=>t.open(`handoff`),children:[(0,X.jsx)(G,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),t.dialog]})}function nn({handoff:e}){if(!e.visible)return null;let{notifying:t,reachable:n,targets:r}=e;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(j,{"data-slot":`handoff-menu-label`,className:`truncate px-2 py-3 text-[12px] font-normal text-muted-foreground uppercase`,title:n?$(r):void 0,children:n?`Webhook · ${W(r)}`:`Webhook`}),t?(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsx)(M,{"data-action":`handoff-note`,className:`min-h-11`,onSelect:()=>e.open(`note`),children:`Send a note…`}):null,(0,X.jsx)(M,{"data-action":`handoff-stop`,variant:`destructive`,className:`min-h-11`,disabled:e.pending,onSelect:e.stop,children:`Stop notifying`})]}):(0,X.jsx)(M,{"data-action":`handoff`,className:`min-h-11`,onSelect:()=>e.open(`handoff`),children:`Hand off to webhook…`})]})}function rn({run:e}){let t=tt(),n=$t();return e.notify!==!0||t===`absent`?null:(0,X.jsx)(K,{"data-slot":`notifying-status`,role:`img`,"aria-label":n.length>0?`Notifying ${W(n)}`:`Notifying`,title:n.length>0?$(n):void 0,className:`shrink-0 px-2 py-px leading-4`,children:(0,X.jsx)(G,{"aria-hidden":`true`,className:`size-3 text-success`})})}function an({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let a=(0,Y.useId)(),o=(0,Y.useId)(),[s,c]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e!==null&&c(``)},[e]);let l=e===`note`,u=W(t);return(0,X.jsx)(Ge,{open:e!==null,onOpenChange:e=>{e||c(``),r(e)},children:(0,X.jsx)(Ue,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(s.trim())},children:[(0,X.jsxs)(He,{className:`text-left`,children:[(0,X.jsx)(We,{children:l?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,X.jsx)(Ve,{children:(0,X.jsx)(`span`,{"data-webhook-destination":``,title:$(t),children:l?`${u} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${u} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:a,className:`text-[13px] font-medium`,children:`Note`}),(0,X.jsx)(St,{id:a,"data-slot":`handoff-note`,"aria-describedby":o,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:s,onChange:e=>c(e.target.value)}),(0,X.jsxs)(`p`,{id:o,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,X.jsx)(Pe,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,X.jsxs)(Be,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:w-full`,children:[(0,X.jsx)(A,{type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),(0,X.jsxs)(A,{type:`submit`,variant:`contrast`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,X.jsx)(G,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function on({id:e}){return(0,X.jsxs)(R,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,X.jsx)(Se,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function sn({id:e}){let t=s(e),n=t.data?z(t.data):e;return(0,X.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,X.jsxs)(R,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,X.jsx)(Se,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,X.jsx)(A,{variant:`outline`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var cn=3,ln=(e,t)=>e.kind===t.kind&&e.number===t.number;function un(e,t,n=cn){let r=t?e.findIndex(e=>ln(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var dn=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function fn({tab:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e.kind===`pr`?ve:we,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,X.jsx)(he,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function pn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function mn({servers:e,icon:t=!1}){let n=st();if(n===null)return null;let i=n.agentLive===!0,a=e[0],o=e.length+ +!!i,s=o===1?a?{port:a.port}:{agent:!0}:{};return t?(0,X.jsxs)(A,{variant:`ghost`,size:`icon`,"data-slot":`preview-toggle`,"data-entries":o,"aria-pressed":n.open,"aria-label":pn(e,i),className:r(`relative`,o>0?`text-foreground`:`text-soft-foreground`),onClick:()=>n.openPane(s),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),n.live?(0,X.jsx)(B,{tone:`success`,"aria-hidden":`true`,"data-slot":`preview-live-dot`,className:`absolute top-2 right-2`}):null]}):(0,X.jsxs)(A,{variant:`outline`,"data-slot":`preview-toggle`,"aria-pressed":n.open,onClick:()=>n.openPane(s),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),pn(e,i),n.live?(0,X.jsx)(B,{tone:`success`,"aria-label":`Preview is live`}):null]})}function hn({tab:e}){let t=nt();return!t?.available||e!==`session`&&e!==`changes`?null:(0,X.jsxs)(A,{variant:`outline`,"data-slot":`split-view-toggle`,className:r(t.showing&&`border-accent-text/40 bg-muted text-accent-text`),"aria-pressed":t.showing,title:t.showing?`Show Session alone`:`Show Changes beside Session`,onClick:()=>t.setOn(!t.showing),children:[(0,X.jsx)(Dt,{"aria-hidden":`true`}),`Split view`]})}function gn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function _n({run:e,compact:t=!1}){if(e.delegation?.role!==`worker`)return null;let n=e.delegation.supervisorRunId??e.delegation.parentRunId;return t?(0,X.jsx)(on,{id:n}):(0,X.jsx)(sn,{id:n})}function vn({isDesktop:e,desktopActivitySlot:t,attention:n,statusLine:r}){return e&&t?(0,X.jsx)(X.Fragment,{children:t}):(0,X.jsx)(`span`,{"data-slot":`run-status-slot`,className:`hidden`,children:(0,X.jsx)(K,{dot:n.tone,shape:n.shape,pulse:n.pulse,children:Wt(r)})})}function yn(e,t,n){return e.worktreePath&&t?(0,X.jsx)(mn,{servers:e.previewServers??[],icon:n}):null}function bn(e,t,n){return n&&!e.archiveBlocker&&t.archive?(0,X.jsx)(Pt,{run:e}):null}function xn({archived:e,className:t}){return e?(0,X.jsx)(K,{"data-slot":`run-archived-pill`,dot:V.tone,shape:V.shape,className:t,children:V.label}):null}function Sn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,X.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function Cn({run:e,statusLine:t,activityTrigger:n}){let{attention:r}=t;return(0,X.jsx)(`span`,{"data-slot":`mobile-status-room`,className:`flex min-w-0`,children:(0,X.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1.5`,children:[n??(0,X.jsx)(K,{"data-slot":`mobile-run-status`,dot:r.tone,shape:r.shape,pulse:r.pulse,className:`min-w-0 px-2 py-px text-xs leading-4`,children:(0,X.jsx)(`span`,{className:`truncate`,children:t.label})}),(0,X.jsx)(xn,{archived:e.archived,className:`shrink-0 px-2 py-px text-xs leading-4`}),(0,X.jsx)(rn,{run:e})]})})}function wn({run:e,tab:t,activeItem:n,inlineItemTabs:i,overflowItemTabs:a,phoneBar:o,isDesktop:s}){let c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=c.current;if(!e||s){u(!1);return}let t=()=>u(e.scrollWidth-e.clientWidth-e.scrollLeft>1),n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[s,i,a,e.diffStat?.files]);let d=n?`${n.kind}#${n.number}`:null;return(0,Y.useEffect)(()=>{!d||s||c.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[d,i.map(e=>`${e.kind}#${e.number}`).join(`,`),s]),(0,X.jsxs)(`div`,{ref:c,"data-slot":`run-tabs`,"data-phone-bar":o||void 0,"data-overflow-end":l||void 0,className:r(`flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-2 max-md:[&>a]:text-[13.5px]`,o?`mt-0`:`mt-3`),children:[(0,X.jsx)(J,{to:`/tasks/${e.id}`,active:t===`session`,replace:o,children:`Session`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:o,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:o,children:`Commits`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:o,children:`Files`}),i.map(t=>(0,X.jsx)(J,{to:dn(e.id,t),active:n!==null&&ln(t,n),replace:o,children:(0,X.jsx)(fn,{tab:t})},`${t.kind}-${t.number}`)),a.length>0?(0,X.jsxs)(L,{children:[(0,X.jsxs)(F,{"data-slot":`run-tabs-more`,"aria-label":`${a.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,a.length]}),(0,X.jsx)(I,{align:`end`,children:a.map(t=>(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(R,{to:dn(e.id,t),replace:o,children:(0,X.jsx)(fn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function Tn({run:e,tab:t=`session`,onMarkedUnread:n,desktopActivitySlot:i,mobileActivitySlot:a}){let o=re(e),s=H(e),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=En(e,n),p=Dn(e),m=(0,Y.useRef)(null),h=ee(),g=te(),_=Ut(e,{queuePosition:e.status===`queued`?Ye(h.data??[]).get(e.id):void 0}),v=ut(),y=q(),b=v!==null&&!y?v:null,x=b!==null,{referenceProjectId:ne,repoBase:S,requests:ie}=Kt(e),ae=(0,Y.useMemo)(()=>le(e,S),[e,S]),C=typeof t==`object`?t:null,{inline:oe,overflow:w}=un(ae,C),T=g.data?.capabilities?.preview===!0,se=yn(e,T,!1),E=(0,X.jsx)(An,{run:e,actions:f,triggerRef:m,onRename:x?p.editor.begin:void 0,onOpenChooser:()=>d(!0),onToggleNotes:()=>l(e=>!e)}),ce=bn(e,s,y);return(0,X.jsx)(pe,{projectId:ne,repoBase:S,requests:ie,children:(0,X.jsxs)(`header`,{"data-slot":`run-header`,"data-sticky":t===`session`||void 0,className:r(`relative z-20 shrink-0 bg-background px-4 md:px-9 md:pt-7`,x?`pt-0`:`pt-[18px]`,t===`session`&&`border-b border-border`),children:[(0,X.jsx)(Sn,{run:e}),(0,X.jsx)(Vt,{run:e}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(_n,{run:e}),b?(0,X.jsxs)(mt,{slot:b,children:[(0,X.jsx)(kn,{run:e,title:p,returnFocus:m,status:(0,X.jsx)(Cn,{run:e,statusLine:_,activityTrigger:a})}),yn(e,T,!0),(0,X.jsx)(_n,{run:e,compact:!0}),E]}):(0,X.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,X.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:gn(e.delegation)}),(0,X.jsx)(On,{run:e}),(0,X.jsx)(vn,{isDesktop:y,desktopActivitySlot:i,attention:o,statusLine:_}),(0,X.jsx)(xn,{archived:e.archived,className:`max-md:hidden`}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[ce,(0,X.jsx)(hn,{tab:t}),se,(0,X.jsx)(tn,{run:e}),E]})]}),(0,X.jsx)(wn,{run:e,tab:t,activeItem:C,inlineItemTabs:oe,overflowItemTabs:w,phoneBar:x,isDesktop:y}),c?(0,X.jsx)(Nn,{runId:e.id,onClose:()=>l(!1)}):null,u?(0,X.jsx)(Xt,{run:e,canResume:H(e).terminal,onResume:()=>f.terminal.mutate(),onClose:()=>d(!1)}):null]}),(0,X.jsx)(Mn,{run:e,actions:f})]})})}function En(e,t){let n=se(),r=Ke(),[i,o]=(0,Y.useState)(null),s=()=>n.invalidateQueries({queryKey:u.runs.all}),c=e=>w(e.message,{tone:`danger`}),l=a(),f={isPending:l.isPending,mutate:()=>l.mutate({id:e.id,pinned:!e.pinned})},p=d();return{pin:f,markUnread:{isPending:p.isPending,mutate:()=>{t?.(),p.mutate(e.id,{onError:c})}},delete:b({mutationFn:()=>C(e.id),onSuccess:()=>{s(),r(`/`)},onError:c}),terminal:qt(e),confirming:i,setConfirming:o}}function Dn(e){let t=f(e.id),n=z(e);return{title:n,editor:ht(n,e=>t.mutate({title:e},{onError:e=>w(e.message,{tone:`danger`})}))}}function On({run:e}){let{title:t,editor:n}=Dn(e);return n.editing?(0,X.jsx)(rt,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,X.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(ct,{className:`size-3.5`,"aria-hidden":`true`})})]})}function kn({run:e,title:{title:t,editor:n},returnFocus:r,status:i}){return(0,X.jsxs)(ze,{open:n.editing,onOpenChange:e=>{e||n.commit()},children:[(0,X.jsx)(Le,{asChild:!0,children:(0,X.jsxs)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 break-words text-[15px] leading-[18px] font-semibold text-foreground`,title:e.task,children:t}),i]})}),(0,X.jsx)(Re,{align:`start`,sideOffset:12,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},onCloseAutoFocus:e=>{e.preventDefault(),r.current?.focus()},children:(0,X.jsx)(rt,{editor:n,className:`text-[16px] font-semibold`})})]})}function An({run:e,actions:t,triggerRef:n,onRename:r,onToggleNotes:i,onOpenChooser:a}){let o=H(e),s=U(e),c=q(),l=kt(e.id),[u,d]=(0,Y.useState)(!1),p=f(e.id),m=(0,Y.useId)(),h=en(e),g=(0,Y.useRef)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Nt,{run:e,open:u,onOpenChange:d,onConfirm:()=>{l.mutate(!0),d(!1)}}),c?null:h.dialog,(0,X.jsxs)(L,{children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsx)(A,{ref:n,variant:`ghost`,size:`icon`,"aria-label":`Run actions`,children:(0,X.jsx)(ye,{"aria-hidden":`true`})})}),(0,X.jsxs)(I,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,onCloseAutoFocus:e=>{g.current&&(g.current=!1,e.preventDefault(),r?.())},children:[(0,X.jsx)(j,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),r?(0,X.jsxs)(M,{"data-action":`rename-task`,className:`min-h-11`,onSelect:()=>{g.current=!0},children:[(0,X.jsx)(ct,{"aria-hidden":`true`}),` Rename`]}):null,!c&&o.archive&&!e.archiveBlocker?(0,X.jsx)(M,{disabled:l.isPending,onSelect:()=>e.archived?l.mutate(!1):d(!0),children:jt(e)}):null,(0,X.jsxs)(M,{onSelect:i,children:[(0,X.jsx)(xt,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,X.jsx)(Xt,{run:e,canResume:o.terminal,onResume:()=>t.terminal.mutate(),onOpen:a}),s?(0,X.jsxs)(M,{onSelect:()=>void Z(s,`Command copied to clipboard.`),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),` Copy resume command`]}):null,o.markUnread?(0,X.jsxs)(M,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,X.jsx)(Et,{"aria-hidden":`true`}),` Mark unread`]}):null,o.pin?(0,X.jsxs)(P,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,X.jsx)(Ot,{"aria-hidden":`true`}):(0,X.jsx)(be,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,c?null:(0,X.jsx)(nn,{handoff:h}),(0,X.jsx)(N,{}),(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,X.jsx)(P,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:p.isPending,onCheckedChange:e=>p.mutate({archiveWhenDone:e},{onError:e=>w(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,X.jsx)(P,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:p.isPending,"aria-describedby":m,onCheckedChange:e=>p.mutate({autoMergePr:e},{onError:e=>w(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,X.jsx)(`p`,{id:m,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,X.jsx)(jn,{run:e,patch:p}),o.deleteRun?(0,X.jsx)(N,{}):null,o.deleteRun?(0,X.jsxs)(M,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,X.jsx)(De,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})]})}function jn({run:e,patch:t}){let n=(0,Y.useId)(),r=(0,Y.useId)(),i=(0,Y.useId)(),a=e=>w(e.message,{tone:`danger`});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,X.jsx)(P,{"data-slot":`allow-workers`,className:`min-h-11`,checked:ae(e),disabled:t.isPending,"aria-describedby":`${n} ${i}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:a}),children:`Allow Squawk workers`}),(0,X.jsx)(`p`,{id:n,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`}),(0,X.jsx)(P,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:oe(e),disabled:t.isPending,"aria-describedby":`${r} ${i}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:a}),children:`Allow task messaging`}),(0,X.jsx)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,X.jsx)(`p`,{id:i,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function Mn({run:e,actions:t}){let n=t.confirming;return(0,X.jsx)(pt,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,X.jsxs)(it,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(at,{children:[(0,X.jsx)(dt,{className:`text-danger`,children:`Delete task permanently?`}),(0,X.jsx)(gt,{children:(0,X.jsxs)(X.Fragment,{children:[`Delete “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:z(e),children:z(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!ie(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,X.jsxs)(yt,{children:[(0,X.jsx)(lt,{children:`Cancel`}),(0,X.jsx)(vt,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function Nn({runId:e,onClose:t}){let n=_(e);return(0,X.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 flex max-h-[min(45dvh,420px)] flex-col overflow-hidden rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`mb-4 flex shrink-0 items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,X.jsx)(A,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,X.jsx)(Te,{})})]}),(0,X.jsx)(`div`,{"data-slot":`notes-panel-body`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n.isPending?(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,X.jsx)(wt,{runId:e,children:(0,X.jsx)(Ct,{children:n.data})}):(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`})}),(0,X.jsxs)(`div`,{className:`mt-4 flex shrink-0 gap-3`,children:[(0,X.jsx)(A,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Z(n.data??``,`Notes copied`),children:`Copy notes`}),(0,X.jsx)(A,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{qt as a,Yt as i,Zt as n,Kt as o,Qt as r,Ut as s,Tn as t};
|
|
@@ -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{p as r}from"./dist-C_rn70hE.js";import{t as i}from"./button-B22ANdCY.js";import{Dn as a}from"./index-DJB0lid-.js";import{n as o}from"./save-cue-CpHgT93o.js";var s=e(t(),1),c=n(),l={dirty:0,invalid:0,busy:0},u=class{entries=new Map;listeners=new Set;snapshot=l;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;set(e,t,n){this.entries.set(e,{...t,draft:n}),this.publish()}delete(e){this.entries.delete(e)&&this.publish()}dirtyDrafts(){return[...this.entries.values()].filter(e=>e.dirty).map(e=>e.draft.current)}publish(){let e=0,t=0,n=0;for(let r of this.entries.values())r.dirty&&(e+=1,r.invalid&&(t+=1),r.busy&&(n+=1));let{snapshot:r}=this;if(!(e===r.dirty&&t===r.invalid&&n===r.busy)){this.snapshot=e===0&&t===0&&n===0?l:{dirty:e,invalid:t,busy:n};for(let e of this.listeners)e()}}},d=(0,s.createContext)(null);function f(e){let t=(0,s.useContext)(d);if(!t)throw Error(`useSettingsDraft needs a SettingsDraftScope above it`);let n=(0,s.useId)(),r=(0,s.useRef)(e);(0,s.useLayoutEffect)(()=>{r.current=e});let i=e.dirty,o=e.invalid===!0,c=e.busy===!0;(0,s.useLayoutEffect)(()=>{t.set(n,{dirty:i,invalid:o,busy:c},r)},[t,n,i,o,c]),(0,s.useLayoutEffect)(()=>()=>t.delete(n),[t,n]),a(e.holdsReload??i)}function p({children:e}){let[t]=(0,s.useState)(()=>new u);return(0,c.jsxs)(d.Provider,{value:t,children:[e,(0,c.jsx)(h,{store:t})]})}function m(e){return e===1?`1 field`:`${e} fields`}function h({store:e}){let{dirty:t,invalid:n,busy:a}=(0,s.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(0),{saved:p,flash:h}=o(),g=(0,s.useRef)(!0);(0,s.useLayoutEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let _=async()=>{u(!0),f(0);let t=r(),n=0;for(let i of e.dirtyDrafts()){if(!g.current||r()!==t)return;try{await i.save()}catch{n+=1}}g.current&&(u(!1),n>0?f(n):h())},v=()=>{f(0);for(let t of e.dirtyDrafts())t.discard()},y=l||a>0;if(t===0&&!y)return p?(0,c.jsx)(`div`,{"data-slot":`settings-save-bar`,"data-state":`saved`,className:`settings-save-bar`,children:(0,c.jsx)(`span`,{role:`status`,className:`settings-save-bar-message`,children:`Saved`})}):null;let b=`Unsaved changes`;return y?b=`Saving…`:n>0?b=`Unsaved changes — fix ${m(n)}`:d>0&&(b=`Unsaved changes — ${m(d)} did not save`),(0,c.jsxs)(`div`,{"data-slot":`settings-save-bar`,"data-state":y?`saving`:`dirty`,className:`settings-save-bar`,children:[(0,c.jsx)(`span`,{role:`status`,className:`settings-save-bar-message`,children:b}),(0,c.jsxs)(`span`,{className:`settings-save-bar-actions`,children:[(0,c.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,"data-action":`settings-discard`,disabled:y,onClick:v,children:`Discard`}),(0,c.jsx)(i,{type:`button`,variant:`primary`,size:`sm`,"data-action":`settings-save`,disabled:y||n>0,onClick:()=>void _(),children:`Save`})]})]})}function g(){return(0,c.jsx)(`button`,{type:`submit`,hidden:!0,tabIndex:-1,"aria-hidden":`true`,"data-slot":`settings-implicit-submit`})}export{p as n,f as r,g as t};
|
|
@@ -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{p as r}from"./dist-C_rn70hE.js";import{un as i,v as a}from"./queries-CchoEEzj.js";import{Hr as o,R as s,Vr as c,vi as l}from"./toaster-zMN8cNZQ.js";import{t as u}from"./button-B22ANdCY.js";import{r as d,t as f}from"./settings-save-bar-DFY_Km4X.js";var p=e(t(),1),m=n(),h=[[`overall`,`Overall`],[`needsYou`,`Needs You`],[`finished`,`Finished`],[`working`,`Working`]];function g(){let e=r(),t=a(e);return t.isPending?(0,m.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-muted-foreground`,children:`Loading sidebar settings…`}):t.isError?(0,m.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,m.jsxs)(`p`,{role:`alert`,children:[`Sidebar settings did not load: `,t.error.message]}),(0,m.jsx)(u,{onClick:()=>void t.refetch(),children:`Retry`})]}):(0,m.jsx)(_,{scope:e,initial:t.data.sidebarLimits??{}},e)}function _({scope:e,initial:t}){let n=l(),r=c(void 0),a=v(t),[u,g]=(0,p.useState)(()=>({values:a,saved:a,received:a})),{values:_,saved:b}=u,x=e=>g(t=>({...t,values:e})),S=o.safeParse(Object.fromEntries(h.map(([e])=>[e,_[e]===null?null:Number(_[e])]))),C=e=>_[e]!==null&&(_[e].trim()===``||!Number.isSafeInteger(Number(_[e]))||Number(_[e])<=0),w=h.some(([e])=>_[e]!==b[e]),T=!S.success||h.some(([e])=>C(e)),E=i({onMutate:()=>n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),mutationFn:t=>s({sidebarLimits:t},e),onSuccess:async t=>{await n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),n.setQueryData([e,`ui-state`],t);let r=v(t.sidebarLimits);g({values:r,saved:r,received:r})}}),D=()=>S.success?E.mutateAsync(S.data):Promise.reject(Error(`invalid sidebar limits`));return d({dirty:w,invalid:T,busy:E.isPending,save:D,discard:()=>g(e=>({...e,values:e.saved}))}),!E.isPending&&!y(u.received,a)&&g({values:w?_:a,saved:a,received:a}),(0,m.jsxs)(`form`,{"data-slot":`sidebar-settings`,"data-reports-dirty":``,className:`flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6`,onSubmit:e=>{e.preventDefault(),w&&!T&&!E.isPending&&D().catch(()=>{})},children:[(0,m.jsx)(`p`,{id:`sidebar-limits-help`,className:`text-sm text-muted-foreground`,children:`Limits apply to this project on desktop and mobile. The overall budget is shared in section order: Needs You, Finished, then Working. Each section also respects its own limit. Unlimited removes only that constraint.`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pinned tasks and groups containing a pin bypass both limits. A task group counts as one row. Archived uses only the overall limit; archived pins are not exempt.`}),h.map(([e,t])=>(0,m.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,m.jsx)(`label`,{htmlFor:`sidebar-${e}`,className:`text-sm font-medium`,children:t}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsx)(`input`,{id:`sidebar-${e}`,type:`number`,inputMode:`numeric`,min:`1`,step:`1`,value:_[e]??``,disabled:_[e]===null||E.isPending,"aria-invalid":C(e),"aria-describedby":C(e)?`sidebar-${e}-error sidebar-limits-help`:`sidebar-limits-help`,onChange:t=>x({..._,[e]:t.target.value}),className:`min-h-[44px] w-28 rounded-md border border-input bg-card px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`}),(0,m.jsxs)(`label`,{className:`flex min-h-[44px] cursor-pointer items-center gap-2 text-sm`,children:[(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`${t} Unlimited`,checked:_[e]===null,disabled:E.isPending,onChange:t=>x({..._,[e]:t.target.checked?null:String(r[e]??10)}),className:`size-4 accent-[var(--accent-strong)]`}),`Unlimited`]})]}),C(e)&&(0,m.jsx)(`p`,{id:`sidebar-${e}-error`,className:`text-sm text-danger`,children:`Enter a positive whole number or choose Unlimited.`})]},e)),E.isError&&(0,m.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save sidebar limits: `,E.error.message]}),(0,m.jsx)(f,{})]})}function v(e){let t=c(e);return Object.fromEntries(h.map(([e])=>[e,t[e]===null?null:String(t[e])]))}function y(e,t){return h.every(([n])=>e[n]===t[n])}export{g as SidebarSection};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n}from"./dist-C_rn70hE.js";import{t as r}from"./bot-TkDIw4y-.js";import{r as i}from"./button-B22ANdCY.js";e();var a=t(),o=i(`inline-block shrink-0`,{variants:{tone:{success:``,pending:``,danger:``,accent:``,info:``,running:``,neutral:``},shape:{filled:`size-[7px] rounded-full`,ring:`size-[7px] rounded-full border-[1.5px] bg-transparent`,workers:`inline-flex size-[12px] items-center justify-center`},pulse:{true:`animate-pulse motion-reduce:animate-none`,false:``}},compoundVariants:[{shape:`filled`,tone:`success`,className:`bg-success`},{shape:`filled`,tone:`pending`,className:`bg-pending-strong`},{shape:`filled`,tone:`danger`,className:`bg-danger`},{shape:`filled`,tone:`accent`,className:`bg-accent-strong`},{shape:`filled`,tone:`info`,className:`bg-info`},{shape:`filled`,tone:`running`,className:`bg-status-running`},{shape:`filled`,tone:`neutral`,className:`bg-soft-foreground`},{shape:`ring`,tone:`success`,className:`border-success`},{shape:`ring`,tone:`pending`,className:`border-pending-strong`},{shape:`ring`,tone:`danger`,className:`border-danger`},{shape:`ring`,tone:`accent`,className:`border-accent-strong`},{shape:`ring`,tone:`info`,className:`border-info`},{shape:`ring`,tone:`running`,className:`border-status-running`},{shape:`ring`,tone:`neutral`,className:`border-soft-foreground`},{shape:`workers`,tone:`success`,className:`text-success`},{shape:`workers`,tone:`pending`,className:`text-pending-strong`},{shape:`workers`,tone:`danger`,className:`text-danger`},{shape:`workers`,tone:`accent`,className:`text-accent-icon`},{shape:`workers`,tone:`info`,className:`text-info`},{shape:`workers`,tone:`running`,className:`text-status-running`},{shape:`workers`,tone:`neutral`,className:`text-soft-foreground`}],defaultVariants:{tone:`neutral`,shape:`filled`,pulse:!1}});function s({className:e,tone:t=`neutral`,shape:i=`filled`,pulse:s=!1,...c}){return(0,a.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,"data-shape":i,"data-pulse":s?`true`:void 0,className:n(o({tone:t,shape:i,pulse:s,className:e})),...c,children:i===`workers`?(0,a.jsx)(r,{className:`size-[12px]`,"aria-hidden":`true`}):null})}export{s as t};
|
|
@@ -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{o as r}from"./dist-C_rn70hE.js";import{$ as i,J as a,M as o,P as s,z as c}from"./queries-CchoEEzj.js";import{Rn as l,it as u,mt as d}from"./toaster-zMN8cNZQ.js";import{f,g as p,h as m,m as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{C as g,E as _,Q as v,Z as ee,ct as y,d as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{t as S}from"./run-header-BTRXYB4W.js";import{a as C,i as w,n as T,o as E,r as te}from"./file-preview-98pJhZJj.js";import{t as D}from"./button-B22ANdCY.js";import{l as O}from"./page-shell-BgabWJ3w.js";import{t as k}from"./centered-state-BgSV4e79.js";import{t as A}from"./use-search-params-writer-ClMScnNe.js";import{A as j,E as M,Hn as N,k as P,ur as F,w as I,yr as L}from"./index-DJB0lid-.js";import{t as R}from"./task-file-scope-CB3L3KQl.js";import{t as z}from"./code-workbench-CUkiQ1pF.js";import{t as B}from"./middle-truncated-name-D41ibfXD.js";import{n as V,t as H}from"./selected-file-CfBWFB6p.js";var U=x(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),ne=x(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),W=e(t(),1),G=n();function K({runId:e,path:t,artifactId:n,worktreePath:r}){let i=c(e,n?null:t),a=o(e,n),s=n?a:i,l=(0,W.useContext)(I),p=f(),m=p.pathname.replace(/\/files\/?$/,`/report`)+p.search,h=s.data,g=(0,W.useMemo)(()=>h?.type===`file`&&h.source!==`artifact`?{runId:e,...l,basePath:h.path}:null,[h,l,e]);if(!t&&!n)return(0,G.jsx)(te,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,G.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,G.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,G.jsx)(`h2`,{children:`Could not load this file`}),(0,G.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,G.jsx)(D,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!h)return(0,G.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});let _=w(h.path,r,t);if(h.type!==`file`)return(0,G.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,G.jsx)(`h2`,{children:h.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,G.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:_}),(0,G.jsx)(`p`,{className:`text-sm`,children:h.reason}),(0,G.jsx)(D,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let v=h.artifact;return(0,G.jsx)(I.Provider,{value:g,children:(0,G.jsx)(T,{runId:e,entry:h,displayPath:_,documentPreview:!0,readerHref:m,className:`min-w-0 flex-1`,imageUrl:v?u(e,v.id,`image`):d(e,t),...v?{downloadUrl:u(e,v.id,`download`),snapshot:(0,G.jsx)(N,{iso:v.createdAt})}:{}},v?.id??h.path)})}var q=new Map;function J(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var Y=(0,W.createContext)(null);function X(){let{key:e}=f(),t=h()===`POP`,[n,r]=(0,W.useState)({key:e,generation:0});if(n.key===e)return n.generation;let i={key:e,generation:t?n.generation+1:n.generation};return r(i),i.generation}var Z=()=>document.querySelector(`[data-slot="main"]`);function re(e,t){let n=(0,W.useRef)(null),r=f(),i=h()===`POP`?r.key:J(r.state),[a]=(0,W.useState)(()=>{let t=i?q.get(i):void 0;return t?.runId===e?t:null}),o=(0,W.useRef)(new Set(a?.folders??[])),s=(0,W.useRef)(new Set),[c,l]=(0,W.useState)(0),u=(0,W.useRef)(a===null),d=(0,W.useCallback)(()=>{u.current&&q.set(r.key,{runId:e,folders:new Set(o.current),tree:n.current?.scrollTop??0,main:Z()?.scrollTop??0})},[r.key,e]),p=(0,W.useMemo)(()=>({isOpen:e=>o.current.has(e),setOpen:(e,t)=>{t?o.current.add(e):o.current.delete(e),d()},loading:(e,t)=>{a?.folders.has(e)&&(t?s.current.add(e):s.current.delete(e),l(s.current.size))}}),[a,d]);return(0,W.useEffect)(()=>{if(u.current||!a||!t||s.current.size>0)return;n.current&&(n.current.scrollTop=a.tree);let e=Z();e&&(e.scrollTop=a.main),u.current=!0,d()},[a,t,c,d]),(0,W.useEffect)(()=>{d();let e=[n.current,Z()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,d,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,d)}},[d]),{tree:n,folders:p}}function ie({runId:e,selected:t,onSelect:n}){return(0,G.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,G.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,G.jsx)(Q,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function Q({runId:e,path:t,depth:n,selected:r,onSelect:a}){let o=i(e,t),s=(0,W.useContext)(Y);return(0,W.useEffect)(()=>{if(!(!t||!s))return s.loading(t,o.isPending),()=>s.loading(t,!1)},[s,t,o.isPending]),o.isPending?(0,G.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):o.isError?(0,G.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:o.error.message}):o.data.type===`dir`?o.data.entries.length===0?(0,G.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,G.jsx)(G.Fragment,{children:o.data.entries.map(i=>i.type===`dir`?(0,G.jsx)(ae,{runId:e,name:i.chain??i.name,path:t===``?i.chain??i.name:`${t}/${i.chain??i.name}`,depth:n,selected:r,onSelect:a},i.name):(0,G.jsx)(oe,{name:i.name,path:t===``?i.name:`${t}/${i.name}`,size:i.size,depth:n,selected:r,onSelect:a},i.name))}):null}function ae({runId:e,name:t,path:n,depth:i,selected:a,onSelect:o}){let s=(0,W.useContext)(Y),[c,l]=(0,W.useState)(()=>s?.isOpen(n)??!1);return(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+i*14}px`},children:[(0,G.jsx)(b,{size:16,"aria-hidden":`true`,className:r(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,G.jsx)(_,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{title:n,className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,G.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,G.jsx)(Q,{runId:e,path:n,depth:i+1,selected:a,onSelect:o})}):null]})}function oe({name:e,path:t,size:n,depth:i,selected:a,onSelect:o}){let s=a===t,c=E(t)?ne:g;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>o(t),className:r(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+i*14}px`},children:[(0,G.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,G.jsx)(B,{name:e,path:t}),n===void 0?null:(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-xs tabular-nums text-soft-foreground`,children:C(n)})]})})}function $(){let{id:e}=m(),t=a(e),n=X();return t.isPending?(0,G.jsx)(j,{tab:`files`}):t.isError?(0,G.jsx)(P,{tab:`files`,error:t.error}):(0,G.jsx)(R,{runId:t.data.id,children:(0,G.jsx)(le,{run:t.data},`${t.data.id}:${n}`)})}function se(e,t,n,r){let i=c(e,r||n!==null?null:t),a=o(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function ce(e,t,n,r){let i=e.id,a=e.worktreePath,[,o]=A(),s=h(),c=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(c.current)return;c.current=!0;let e=H(i);s===`POP`||t!==null||n!==null||e===null||o(t=>(t.set(`path`,e),t))},[s,n,t,i,o]),(0,W.useEffect)(()=>{t!==null&&!r&&V(i,M(t,a))},[r,t,i,a])}function le({run:e}){let t=i(e.id,``),n=s(e.id),[r,a]=p(),o=r.get(`path`),c=r.get(`artifact`),u=r.getAll(`path`).length>1||r.getAll(`artifact`).length>1||o!==null&&c!==null;ce(e,o,c,u);let[d,f]=(0,W.useState)(o??``);(0,W.useEffect)(()=>f(o??``),[o]);let m=(e,t)=>{let n=new URLSearchParams(r);n.delete(`path`),n.delete(`artifact`),n.set(e,t),a(n)},h=t.isError&&t.error instanceof l&&t.error.status===409,g=se(e.id,o,c,u),_=re(e.id,!t.isPending&&g);return(0,G.jsxs)(O,{route:`task-files`,density:ue(t.isError),flushPadding:!0,children:[(0,G.jsx)(S,{run:e,tab:`files`}),(0,G.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-4 pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&m(`path`,d.trim())},children:[(0,G.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(v,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,G.jsx)(F,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,G.jsx)(D,{type:`submit`,variant:`outline`,className:`shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,G.jsx)(z,{className:`flex-none gap-5 px-4 py-[22px] [--diff-sticky-top:1rem] md:gap-0 md:px-9`,treeRef:_.tree,treeSlot:`files-tree-pane`,treeClassName:`rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:overflow-y-auto md:overscroll-contain`,tree:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,G.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,G.jsx)(k,{icon:h?(0,G.jsx)(U,{}):(0,G.jsx)(y,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,G.jsx)(Y.Provider,{value:_.folders,children:(0,G.jsx)(ie,{runId:e.id,selected:o,onSelect:e=>m(`path`,e)})}),(0,G.jsx)(de,{artifacts:n,artifactId:c,onSelect:e=>m(`artifact`,e)})]}),children:u?(0,G.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):o!==null||c!==null||t.isSuccess?(0,G.jsx)(K,{runId:e.id,path:o,artifactId:c,worktreePath:e.worktreePath}):null}),(0,G.jsx)(`p`,{className:`px-4 pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}function ue(e){return e?`empty`:`full`}function de({artifacts:e,artifactId:t,onSelect:n}){return(0,G.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),e.isPending?(0,G.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):e.isError?(0,G.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):e.data.artifacts.length===0?(0,G.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,G.jsx)(`ul`,{children:e.data.artifacts.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,"data-slot":`artifact-row`,"aria-current":e.id===t?`true`:void 0,className:`group flex min-h-11 w-full items-center gap-2 rounded px-2 py-2 text-left text-xs text-foreground hover:bg-muted focus-visible:ring-2 aria-[current=true]:bg-muted aria-[current=true]:font-medium`,onClick:()=>n(e.id),children:[(0,G.jsx)(L,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 wrap-anywhere underline-offset-2 group-hover:underline`,children:e.name}),(0,G.jsx)(b,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-foreground`})]})},e.id))}),(0,G.jsxs)(D,{variant:`outline`,size:`sm`,"data-action":`refresh-artifacts`,className:`mt-2`,onClick:()=>void e.refetch(),children:[(0,G.jsx)(ee,{"aria-hidden":`true`}),`Refresh published files`]})]})}export{$ as TaskFilesRoute};
|
|
@@ -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{o as i,s as a}from"./dist-C_rn70hE.js";import{B as o,Ht as s,J as c,L as l,R as u,Ut as d,W as f,Yt as p,at as m,bt as h,cn as g,ct as _,g as v,ln as y,nn as b,nt as x,on as S,q as C,tt as w,un as T,ut as E,vt as D}from"./queries-CchoEEzj.js";import{$n as O,In as k,Ln as A,Nn as j,Nt as M,Qn as N,Rn as P,Sr as F,at as I,ct as ee,dt as L,er as R,ir as z,n as B,ni as V,ot as H,ri as te,si as U,tr as ne,vi as W,xr as re}from"./toaster-zMN8cNZQ.js";import{f as ie,h as ae,n as oe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{C as G,D as se,b as ce,d as le,g as ue,i as de,o as fe,t as pe}from"./reference-chip-z7dZJVH-.js";import{A as me,B as K,V as he,_ as ge,b as _e,c as ve,ct as ye,d as be,ft as xe,g as Se,h as Ce,j as we,m as Te,n as Ee,o as De,ot as Oe,p as ke,u as Ae}from"./design-icons-QbNMZniQ.js";import{t as je}from"./createLucideIcon-BHp8sXmF.js";import{A as Me,C as Ne,D as Pe,E as Fe,F as Ie,I as Le,L as Re,M as ze,N as Be,O as Ve,P as He,R as Ue,S as We,T as Ge,_ as Ke,a as qe,b as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,i as et,j as tt,k as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,v as ft,w as pt,x as mt,y as ht,z as gt}from"./ask-card-kqWOqKIc.js";import{a as _t,i as vt,n as yt,o as bt,r as xt,s as St,t as Ct}from"./run-header-BTRXYB4W.js";import{t as wt}from"./eye-B8okNWXU.js";import{t as Tt}from"./loader-circle-CPBhhDbB.js";import{a as Et}from"./tool-display-B9NN44oU.js";import{t as Dt}from"./search-x-I9Q8pgUa.js";import{a as Ot,i as kt,n as At,o as jt,r as Mt,t as Nt}from"./thread-state-qNczqxZQ.js";import{t as q}from"./button-B22ANdCY.js";import{n as Pt,r as Ft,t as It}from"./collapsible-Bx2vViFx.js";import{a as Lt,i as Rt,o as zt,r as Bt,t as Vt}from"./popover-CvL6hQ5c.js";import{s as Ht,t as Ut}from"./project-router-j0uBi7Ep.js";import"./attention-DnxGjw_R.js";import{D as Wt,E as Gt,O as Kt,S as qt,b as Jt,f as J,u as Yt,w as Xt,x as Zt}from"./task-groups-CGCnVqHE.js";import"./read-state-c_RNJaXO.js";import{t as Y}from"./status-dot-Drd4-nfa.js";import{c as Qt,i as $t,l as en,o as tn,r as nn,s as rn,t as an}from"./report-selection-BdGxjISG.js";import{l as on,m as sn}from"./page-shell-BgabWJ3w.js";import{i as cn,t as ln}from"./agent-accounts-D_7QcFSx.js";import{t as un}from"./centered-state-BgSV4e79.js";import{$ as dn,B as fn,C as pn,Cn as mn,D as hn,H as gn,In as _n,Kn as vn,Nn as yn,On as bn,Rn as xn,Sn,Tn as Cn,U as wn,V as Tn,Wn as En,_n as Dn,at as On,b as kn,bn as An,d as jn,et as Mn,g as Nn,gn as Pn,i as Fn,it as In,l as Ln,n as Rn,pn as zn,r as Bn,s as Vn,tt as Hn,u as Un,xn as Wn,z as Gn}from"./index-DJB0lid-.js";import{t as Kn}from"./markdown-BAPhDASs.js";import{t as qn}from"./task-file-scope-CB3L3KQl.js";import{t as Jn}from"./run-diff-BDMdnSv7.js";import{n as Yn,t as Xn}from"./use-finish-run-Dvm4JnAH.js";import{i as Zn}from"./automation-format-DB34jUyF.js";var Qn=je(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),X=e(t(),1),Z=r();function $n(e,t,n,r,i,a,o,s,c){let l=Kt(e,Dn(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=Tn(t,o,a,[p,f?.[t]]),h=wn(p,t,o,f,a),g=fn(h,a),_=r?``:c??d??``,v=gn(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function er(e,t,n,r){let i=Gt(e.steps),a=Kt(e,Dn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function tr(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 nr(e,t,n,r){return!!t&&(r!==Wt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function rr({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`Runner default`,effortLabel:n.find(e=>e.value===r)?.label??`Runner default`}}function ir(e){let t=_(),n=mn(e).continueRun,r=v(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),u=`${e.id}:${Kt(e,Dn(e))?.id??``}`,[d,f]=(0,X.useState)(u);d!==u&&(f(u),a(null),s(null),l(null));let m=Yn(e,i),{runners:h,canContinue:g,currentRunner:x,runner:C}=m,{sessionStep:w,workerStep:E,account:O}=er(e,C,C!==x,cn().repoAccount),k=D(),A=k.data?.capabilities?.localHandoff!==!1,j=b(),M=S(C,n&&!k.isPending&&!j.isPending,A?O:null),N=r.data?.modelsLocked===!0,F=C!==x,I=$n(e,C,F,N,r.data,M.data,j.data,o,c),{models:L,model:R,effortOptions:z,effort:B}=I,{modelLabel:V,effortLabel:H}=rr(I),te=T({mutationFn:({text:t,images:n})=>g?ee(y(e.id),tr(t,n,m.runnerOverride,N,F,o,c,I)):Promise.reject(Error(m.reason??`Connect an agent provider to continue.`)),onMutate:()=>y(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof P&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),U=e.delegation?.role===`worker`,ne=sn();return{skillRunner:C,skillAccount:O,available:n,canContinue:g,startsNewConversation:nr(e,w,E,C),reason:m.reason,providerPending:m.providerPending,pills:(0,Z.jsx)(ar,{compact:!ne||e.status===`review`,summary:`${p(j.data,C)} · ${V} · ${H}`,children:(0,Z.jsxs)(Mn,{children:[!U&&(h.length>1||m.signedOut.length>0)?(0,Z.jsx)(Hn,{icon:(0,Z.jsx)(Oe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:h,signedOut:m.signedOut,value:C,onPick:e=>{e!==C&&(a(e),s(null))}}):(0,Z.jsx)(dn,{icon:(0,Z.jsx)(Oe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:U?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:C,value:C,onPick:()=>{},options:[{value:C,label:C}]}),(0,Z.jsx)(dn,{icon:(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:V,value:R,readOnly:N,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=fn(e,M.data);B!==``&&gn(B,t)===``&&l(``)},options:L.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Gn(C,j.data,M)}),(0,Z.jsx)(dn,{icon:(0,Z.jsx)(me,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:H,value:B,readOnly:N,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:z.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},u),continueWith:(e,t)=>te.mutateAsync({text:e,images:t})}}function ar({compact:e,summary:t,children:n}){let[r,i]=(0,X.useState)(!1),a=On(),[o,s]=(0,X.useState)(a);a!==o&&(s(a),a&&i(!1));let c=(0,X.useRef)(null),l=e&&!r;return(0,X.useEffect)(()=>{r&&(c.current?.querySelector(`button:not([disabled])`)??c.current)?.focus()},[r]),(0,Z.jsx)(`div`,{ref:c,"data-slot":`follow-up-engine`,"data-folded":l||void 0,tabIndex:l?void 0:-1,className:l?`min-w-0`:`session-engine-controls outline-hidden`,children:l?(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)(Oe,{"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)(Ae,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var or=120,sr=e=>e!==`pending`&&e!==`running`,cr=e=>e.kind===`tool`&&e.toolKind===`task`,lr=e=>cr(e)&&e.parentItemId===void 0,ur=e=>Be(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function dr(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 fr(e){if(e.kind===`tool`)return pr(e.title);if(e.kind===`hook`)return pr(`${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 pr(n)}}}function pr(e){return e.length>or?`${e.slice(0,or-1).trimEnd()}…`:e}function mr(e,t=!1,n=e){let r=vr(e,e=>e.items.some(lr));if(r===-1)return[];let i=e=>!t&&!sr(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(lr);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(lr)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>hr(r,Sr(n,e,r.id),t))}function hr(e,t,n){let r={id:e.id,title:ze(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=dr(e);i!==void 0&&(r.agentType=i),n&&!sr(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=fr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function gr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function _r(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function vr(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function yr(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&&lr(e));if(a!==void 0)return hr(a,Sr(r,e,t),n)}}function br(e,t){return vr(e,e=>e.items.some(e=>e.id===t&&lr(e)))}function xr(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)ur(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function Sr(e,t,n){let r=br(t,n);if(r===-1)return[];let i=xr(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 xr(e,n,Math.max(br(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:Cr(t,e))}return[...s.values()].sort(wr).map(({entry:e})=>e)}function Cr(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 wr(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function Tr(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`?tt(e.children).flatMap(n=>Tr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Tr(e,t)):[]}function Er(e){return e.flatMap((e,t)=>e.content.kind===`block`?Tr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Dr(e,t,n,r){let i=(0,X.useContext)(an),{projectId:a}=ae(),o=(0,X.useMemo)(()=>Er(t),[t]);(0,X.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=Re(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=Le(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 Or(e){let t=W();return T({mutationFn:t=>L(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:d.runs.all})}})}var kr=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Ar=()=>navigator.onLine;function jr({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,Z.jsx)(Nr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,Z.jsx)(Mr,{permission:e,runId:t},e.requestId)}function Mr({permission:e,runId:t}){let n=Or(t),r=(0,X.useSyncExternalStore)(kr,Ar,()=>!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 P&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,Z.jsx)(Nr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Nr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,X.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,Z.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-card-edge bg-card shadow-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,Z.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,Z.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,Z.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`block`,disabled:s,"aria-pressed":e.optionId===t.id,className:`min-w-0 py-2 [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 Pr=(0,X.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Fr(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 Ir(e,t,n=[]){let r={};for(let e of n)r[e.id]=J(e);for(let e of t??[])r[e.id]=J(e);return r[e.id]=J(e),r}function Lr(e,t){return t?.[e]??`Task`}function Rr(e,t,n){return t?n?.[e]??`peer task`:Lr(e,n)}function zr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Br(e){return e?.relationship===`peer`}function Vr(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Hr(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 Ur(e){if(e.outcome)return Hr(e.outcome.status);if(e.delivery===`not-delivered`)return Wr(`not-delivered`)}function Wr(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Gr(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`?Br(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 ${bn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Kr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Lr(e,n),linkable:!0}):(0,Z.jsx)(qr,{id:e,children:r})}function qr({id:e,children:t}){let n=c(e);return n.data?t({title:J(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof P&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Jr={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`}},Yr=`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 Xr({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 a=zr(e.messages[0]??{senderRunId:e.senderRunId},t),o=Br(e.messages[0]),s=Jr[o?`peer`:a],c=oi(e.messages.map(e=>a===`outbound`?e.recipientRunId:e.senderRunId)),l=a===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>Rr(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":a,"data-relationship":o?`peer`:`family`,"data-kind":e.kind,className:i(`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:i(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,Z.jsx)(`span`,{children:l}),c.map((e,t)=>(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,Z.jsx)(Kr,{id:e,peer:o,taskTitles:n,children:t=>(0,Z.jsx)(ni,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),o?(0,Z.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,Z.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:Vr(e.kind)}),e.messages.length===1&&d?(0,Z.jsx)($r,{message:d}):null]}),(0,Z.jsx)(Qr,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-xs text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,Z.jsx)(ti,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Gr(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)(ei,{messages:e.messages,peer:o,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,Z.jsx)(ri,{message:d,runId:t,taskTitles:n}):null,(0,Z.jsx)(ii,{batch:e,heading:u})]})}function Qr({at:e,className:t,children:n}){return e===void 0||Ke(e)===void 0?null:(0,Z.jsxs)(`span`,{className:t,children:[n,(0,Z.jsx)($e,{ts:e})]})}function $r({message:e}){let t=Ur(e),n=Wr(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 ei({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=Ur(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)(Kr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,Z.jsx)(ni,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Wr(e.delivery)===i?null:(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Wr(e.delivery)}),(0,Z.jsx)(ri,{message:e,runId:n,taskTitles:r}),(0,Z.jsx)(Qr,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function ti({batch:e}){let t=Me(),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)(Kn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,Z.jsxs)(It,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,Z.jsxs)(Ft,{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)(be,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,Z.jsx)(Pt,{children:a})]})}function ni({view:e,to:t,label:n}){return e.linkable?(0,Z.jsx)(Ut,{className:Yr,to:t,"aria-label":n,children:e.title}):(0,Z.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function ri({message:e,runId:t,taskTitles:n}){let{targets:r,replies:a,navigate:o}=(0,X.useContext)(Pr),s=e.requestId?r.get(e.requestId):void 0,c=e.requestId?s?[s]:[]:a.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=zr(e.message,t)===`outbound`,a=r?e.message.recipientRunId:e.message.senderRunId;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:i(Yr,`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)(Kr,{id:a,peer:Br(e.message),taskTitles:n,children:e=>(0,Z.jsxs)(Z.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function ii({batch:e,heading:t}){return(0,Z.jsxs)(It,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,Z.jsxs)(Ft,{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)(be,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,Z.jsx)(Pt,{children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-xs text-muted-foreground`,children:[(0,Z.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>ai(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 ai(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Br(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Wr(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 oi(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var si=e(n(),1),ci=`pending-ask`;function li(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function ui(e,t){if(e.dataset.askMode===`reply`){let n=(t??e.closest(`[data-slot="thread-dock"]`)??document).querySelector(`[data-slot="thread-composer-slot"]:not([hidden]) textarea:not(:disabled)`);if(n)return n}return li(e)}function di(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?ui(t,e):null}function fi(e,t){let n=`${ci}:${e}`;return r=>{if(!t())return!1;let i=[...r.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);if(i)return di(i);let a=[...r.querySelectorAll(`[data-slot="ask-card"][data-pinned="true"]`)].find(t=>t.dataset.askId===e);return a?ui(a,r):null}}function pi(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function mi({onGoToQuestion:e}){return(0,Z.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}function hi(){let e=(0,X.useRef)(null);return(0,X.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.closest(`[data-slot="main"]`),r=t.querySelector(`[data-slot="run-header"]`),i=t.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),a=r.getBoundingClientRect(),o=getComputedStyle(document.documentElement),s=document.documentElement.style.getPropertyValue(`--kb`)||(typeof o.getPropertyValue==`function`?o.getPropertyValue(`--kb`):``),c=Number.parseFloat(s)||0;n.clientHeight>0&&n.clientHeight<420?t.dataset.compactViewport=`true`:delete t.dataset.compactViewport,c>0||Lt(window)?t.dataset.keyboardOpen=`true`:delete t.dataset.keyboardOpen,r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-a.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${gi(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),delete t.dataset.compactViewport,delete t.dataset.keyboardOpen,r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function gi(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var _i={viewKey:void 0,generation:0},vi=600,yi=24;function bi(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,X.useRef)(a);o.current=a;let c=(0,X.useRef)(e);c.current=e;let l=(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=l.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,X.useCallback)(()=>{let e=l.current;if(!e)return;let t=h.current?o.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=h.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?gi(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(l.current){if(C.current!==e){C.current=e,h.current=!0;let t=pt(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=We(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!==c.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),A=(0,X.useCallback)(e=>{d(e),e&&(l.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="thread-transcript"], [data-slot="main"]`),D())},[n,D]),j=(0,X.useCallback)(()=>{m.current&&E()},[E]),M=(0,X.useRef)(!1),N=(0,X.useRef)(0),P=(0,X.useRef)(!1),F=(0,X.useRef)(void 0),I=(0,X.useRef)(!1),ee=(0,X.useRef)(!1),L=(0,X.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),R=(0,X.useRef)(null),z=(0,X.useRef)(0);(0,X.useEffect)(()=>{if(!s())return;let e=e=>{x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let B=(0,X.useCallback)(()=>{let e=R.current,t=l.current;if(!e||!t)return;R.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:o.current.indexOf(e.anchor.key),a=w.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):T(Pe(t.scrollTop,r,e.anchor,L(t),n))},[L,T]),V=(0,X.useCallback)(()=>{let e=l.current;if(!e||!r||M.current)return;x.current=null,S.current=null,m.current=!1,M.current=!0;let t=N.current+1;N.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,s=ht(a,L(e)),u=s===void 0?-1:o.current.indexOf(s.key),d=c.current,f=z.current;r().then(()=>{c.current===d&&z.current===f&&(R.current={beforeHeight:n,beforeTop:i,anchor:s,anchorIndex:u})},()=>{}).finally(()=>{N.current===t&&(M.current=!1)})},[L,r]);(0,X.useEffect)(()=>()=>clearTimeout(F.current),[]);let H=(0,X.useRef)(null),te=(0,X.useRef)(0),U=(0,X.useCallback)(()=>n===`document`?++_i.generation:++te.current,[n]),ne=(0,X.useCallback)((e,t)=>n===`document`?_i.viewKey===e&&_i.generation===t:c.current===e&&te.current===t,[n]);(0,X.useEffect)(()=>()=>H.current?.disconnect(),[e,u]);let W=(0,X.useCallback)((t,n,r,i)=>{let a=l.current;if(!a||!u)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0,p(!0),U(),H.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=a.querySelector(`[data-slot="run-header"]`),c=s&&getComputedStyle(s).position===`sticky`?gi(s):0,d=(e,t)=>{let r=a.getBoundingClientRect(),o=t.getBoundingClientRect(),s=w.current;if(s&&i===void 0){let t=o.top-e.getBoundingClientRect().top;c+t+o.height>r.height&&s.scrollToIndex(n,{align:`start`,offset:t-c-12})}else(o.top<r.top+c||o.bottom>r.bottom)&&T(a.scrollTop+o.top-r.top-c-12)},f=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e?e.tabIndex=-1:d(e,t),t.focus({preventScroll:!0}),document.activeElement===t?(H.current?.disconnect(),!0):!1},h=w.current;if(i!==void 0)T(i);else if(h)h.scrollToIndex(n,{align:`start`,...c>0?{offset:-c}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-c)}f()||(H.current=new MutationObserver(()=>{f()}),H.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Fe(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,U]),re=(0,X.useCallback)(t=>{let n=U(),r=c.current;H.current?.disconnect();let a=l.current;if(!a)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),Fe(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},s=a.closest(`[data-slot="main"]`)??a.closest(`[data-route="task-thread"]`)??a,u=()=>ne(r,n),d=()=>{let e=t?.(s);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!u()||d())return;H.current?.disconnect();let e=new MutationObserver(()=>{u()?d()&&e.disconnect():e.disconnect()});H.current=e,e.observe(s,{childList:!0,subtree:!0})})})})},[i,e,E,U,ne,y]),ie=a.at(-1),ae=a.length;return(0,X.useLayoutEffect)(()=>{z.current+=1,R.current=null,M.current=!1,n===`document`?_i.viewKey!==e&&(_i.viewKey=e,_i.generation+=1):te.current+=1},[e,n]),(0,X.useLayoutEffect)(()=>{let e=R.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?B():R.current=null:m.current&&E()},[ie,ae,B,E]),(0,X.useLayoutEffect)(()=>{!l.current||!u||D()},[u,D]),(0,X.useEffect)(()=>{let t=l.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,c,d=()=>{h.current&&!Je(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),c=e},v=()=>{U(),H.current?.disconnect(),x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,z.current+=1,R.current=null,g.current=Date.now()},C=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){v();let e=!P.current;P.current=!0,clearTimeout(F.current),F.current=setTimeout(()=>{P.current=!1},180),e&&mt(t)&&V()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&mt(t)&&V()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),b())},D=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,ee.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(h.current=!1,x.current=null,S.current=null,Je(t,80)||(v(),b()))},k=()=>{i=!1},A=e=>{I.current=!1,r=e.touches[0]?.clientY??null},j=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),v(),!I.current&&mt(t)&&(I.current=!0,V())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},M=e=>{if(e===0||!i&&Date.now()-_.current>=vi)return;let n=e<0?`up`:`down`;!i&&n!==c||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=yi&&(0,si.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},N=()=>{let n=m.current;M(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!ee.current&&t.scrollTop<a&&mt(t)&&(ee.current=!0,V()),a=t.scrollTop;let r=Je(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)&&Fe(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,N,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,A,{passive:!0}),t.addEventListener(`touchmove`,j,{passive:!0}),t.addEventListener(`pointerdown`,D,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,w);let L;if(typeof ResizeObserver<`u`){L=new ResizeObserver(()=>{let e=x.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;T(Math.min(e,n)),n>=e&&(x.current=null)}else m.current&&E()}),L.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&L.observe(r),i&&L.observe(i)}return()=>{t.removeEventListener(`scroll`,N),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,A),t.removeEventListener(`touchmove`,j),t.removeEventListener(`pointerdown`,D),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,w),L?.disconnect()}},[e,u,V,T,E,O,U,y]),{attachContent:A,scrollElRef:l,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:re,jumpToRow:W,loadOlder:V,restickIfStuck:j,subscribeReaderScroll:b}}function xi({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Z.jsx)(Si,{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 Si({runId:e,rows:t,controls:n}){return(0,Z.jsx)(Ci,{runId:e,rows:t,controls:n},e)}function Ci({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)(()=>We(e)),[l,u]=(0,X.useState)(()=>({cache:Ne(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)||Ge(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)(Vn,{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 wi({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)(Ee,{"aria-hidden":!0,className:`size-3.5`}),pi(t)]})}function Ti(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function Ei(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ti(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 Di(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 Oi=new WeakMap;function ki(e,t){let n=Oi.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:(Oi.set(e,t),t)}function Ai(e,t){if(t!=null)return e.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===t&&!e.resolved)}function ji(e,t,n=t,r,i){let a=Ai(n,r),o=i?.pinPendingAskInTranscript!==!1,s=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),c=new Set,l=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),u=[];e.task&&u.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])u.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let d=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===d?Ni(n.items):n.items;u.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:ki(n.items,Ei(e,t.filter(t=>!e.task||!Ot(t,`opening`)).map(e=>e.kind===`ask`&&l.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Di(e,r,a):e.kind===`permission`?(c.add(e.requestId),s.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let f=[...s.values()].filter(e=>e.status===`pending`&&!c.has(e.requestId));return f.length>0&&u.push({id:`pending-permissions`,entries:f,inDaySequence:!1}),a!==void 0&&o&&u.push({id:ci,entries:[{...a,placement:`pinned`}],inDaySequence:!1}),u}var Mi=`changes ready for review`;function Ni(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(Mi)))}function Pi(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 Fi(e,t){return[{id:`agent:${e}`,entries:t}]}function Ii(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Li(e,t){let n=[],r;for(let t of e){let e=Ii(t),i=ft(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 tt(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 Ri({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)(()=>Li(n,e),[n,e]),p=bi(`${e}:${t}`,{surface:r}),m=c??p;Dr(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:zi(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??Ve(``,g.length),v=g.length===0?i??null:(0,Z.jsx)(xi,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,Z.jsx)(qn,{runId:e,children:(0,Z.jsx)(nt,{runId:e,children:(0,Z.jsx)(Pr.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)(wi,{onJump:m.jumpToLatest})}):null]}):v})})})}function zi(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,Z.jsx)(Bi,{message:e.content.message,actions:t});case`day-separator`:return(0,Z.jsx)(it,{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)(Vi,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Gi(e.content)}}function Bi({message:e,actions:t}){return(0,Z.jsx)(Xe,{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)(Ue,{ask:e.ask})}):void 0})}function Vi({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,Z.jsx)(He.Provider,{value:`${t}:${e.entry.id}`,children:(0,Z.jsx)(Ui,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,Z.jsx)(rt,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Z.jsx)(Hi,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,Z.jsx)(et,{group:e,scope:t});case`streak`:return(0,Z.jsx)(dt,{count:e.count,children:e.blocks.map(e=>(0,Z.jsx)(Vi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,Z.jsx)(Xr,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Gi(e)}}function Hi({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return tt(e).map(e=>(0,Z.jsx)(Vi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Ui({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)(Xe,{text:e.text,ts:e.ts});case`reasoning`:return(0,Z.jsx)(Ye,{text:e.text});case`tool`:return(0,Z.jsx)(rt,{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?` · ${Wr(e.delivery)}`:``]}),(0,Z.jsx)(st,{note:e})]}):(0,Z.jsx)(st,{note:e});case`conversation`:return(0,Z.jsx)(Xr,{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)(ot,{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)(jr,{permission:e,runId:i});case`provider-auth-required`:return(0,Z.jsx)(lt,{incident:e});case`preview-server`:return(0,Z.jsx)(Wi,{entry:e});case`hook`:return(0,Z.jsx)(qe,{item:e,cacheKey:`${t}:${e.id}`});default:return Gi(e)}}function Wi({entry:e}){let t=Nn(),n=D().data?.capabilities?.preview===!0;return(0,Z.jsx)(jt,{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 Gi(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Ki({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,onBeforeOpenReport:o,onRestoreAgentFocus:s,taskTitles:c,recipientBackends:l}){let u=(0,X.useContext)(an),d=(0,X.useRef)(void 0),f=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{d.current?.()},[u,e]),(0,Z.jsx)($t,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,Z.jsx)(tn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{f.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,Z.jsx)(Ie.Provider,{value:e=>{let t=r?.id,n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);d.current?.(),d.current=u?.registerOpener(e,()=>{if(t&&s){s(t);return}n?.focus({preventScroll:!0})}),f.current=!0,o?.(),a()},children:(0,Z.jsx)(qi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:c,recipientBackends:l})})})})}function qi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Qt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Z.jsxs)(en,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,Z.jsxs)(rn,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(Ji,{status:r.status}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Z.jsx)(Ri,{runId:e,viewId:`agent:${r.id}`,sections:Fi(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 Ji({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:i(`rounded-full px-2 py-0.5 text-xs font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function Yi(e){let t=W(),[n,r]=(0,X.useState)(),i=Jt(e);(0,X.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=T({mutationFn:async()=>{r(e.id);try{if(!(await H(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 Xi({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)(Zi,{agent:e,onSelect:t},e.id))})}function Zi({agent:e,onSelect:t}){let n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Qi,{status:e.status,stalled:e.stalled===!0}),(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:_r(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 Qi({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 $i(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function ea({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)(ta,{entry:e},`${t}:${e.content}`))})}function ta({entry:e}){return(0,Z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:i(`flex min-h-5 min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 text-[13px] [&>svg]:mt-[3px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-disabled-foreground line-through`),children:[(0,Z.jsx)(na,{status:e.status}),(0,Z.jsx)(`span`,{"data-slot":`plan-text`,className:`min-w-0 flex-1 basis-40 break-words`,children:e.content}),e.status===`in_progress`?(0,Z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function na({status:e}){return e===`cancelled`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-disabled-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Z.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function ra(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 ia(e,t){let n=ra(e);return n===`active`&&t===`waiting`?`paused`:n}function aa(e){return e===`active`?`running`:e}function oa(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 sa({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=oa(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":ia(n.status,t),className:`flex min-h-[22px] min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5 text-[13px] text-muted-foreground [&>svg]:mt-[3px]`,children:[(0,Z.jsx)(ca,{visual:ia(n.status,t)}),(0,Z.jsx)(`span`,{"data-slot":`step-name`,className:`min-w-0 flex-1 basis-32 break-words 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`,{"data-slot":`step-meta`,className:`ml-auto max-w-full min-w-0 pl-2 text-right text-xs leading-5 break-words 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 ca({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Z.jsx)(ke,{"aria-hidden":!0,className:i(t,`text-success`)});case`active`:return(0,Z.jsx)(Tt,{role:`status`,"aria-label":`Step running`,className:i(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Te,{role:`img`,"aria-label":`Step paused`,className:i(t,la)});case`failed`:return(0,Z.jsx)(ge,{"aria-hidden":!0,className:i(t,`text-danger`)});case`pending`:return(0,Z.jsx)(Ce,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}}var la=`stroke-pending [html.light_&]:stroke-pending-strong`,ua={done:`done`,failed:`failed`,cancelled:`cancelled`};function da(e){let t=ua[e.status];return t?e.steps.map(e=>ra(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):fa(e)}function fa(e){let t=pa(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 pa(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ra(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 ma(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function ha(e){return typeof e==`object`&&!!e&&!(0,X.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:a,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:i(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),a??(ha(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:i(`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)(Ae,{"aria-hidden":!0,className:i(`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 ga(e){return re(e.delegation)}function _a(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 va(e){let t=e.delegation,n=ga(e),r=w(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=_a(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 ya(e){let t=w(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>Zt(e.status))}function ba({run:e,open:t,onToggle:n}){let r=w(e.id),a=x(),o=sn(),s=e.delegation,c=new Map(r.data?.workers.map(e=>[e.workerId,e])),l=_a(s,r.data),u=N(e)??O(e),d=u?xa(e,u):void 0,f=e=>a.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),p=e=>{let t=f(e);return t?J(t):`worker ${e.slice(0,8)}`};return(0,Z.jsx)(Q,{slot:`workers`,icon:(0,Z.jsx)(we,{className:`size-4`}),title:`Workers`,meta:Sa({ids:l,workers:c,desktop:o,query:r}),aside:r.data?.capacity?(0,Z.jsx)(ka,{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)(Ea,{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),a=f(t),o=n?wa(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)(Ut,{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)(Ca,{status:n?.status}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate`,children:a?J(a):`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:i(`max-w-[45%] shrink-0 truncate text-xs`,Ta(n?.status)),children:o}),(0,Z.jsx)(De,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,Z.jsx)(ja,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,Z.jsx)(Fa,{state:n.destroy}):null]},t)})}):ga(e)&&r.isSuccess?(0,Z.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,Z.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,Z.jsx)(q,{variant:`outline`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function xa(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return A(e)??k(n.role,t,`requestIds`in t&&ne(n,t.requestIds))}function Sa({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 Ca({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,Z.jsx)(ke,{"aria-hidden":!0,className:i(t,`text-semantic-green`)}):e===`failed`?(0,Z.jsx)(ge,{"aria-hidden":!0,className:i(t,`text-semantic-red`)}):e===`cancelled`?(0,Z.jsx)(Se,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)}):e===`review`?(0,Z.jsx)(wt,{"aria-hidden":!0,className:i(t,`text-semantic-info`)}):e===`waiting`?(0,Z.jsx)(Te,{"aria-hidden":!0,className:i(t,`text-semantic-amber`)}):e===`running`?(0,Z.jsx)(Tt,{role:`status`,"aria-label":`Worker running`,className:i(t,`animate-spin stroke-status-running motion-reduce:animate-none`)}):(0,Z.jsx)(Ce,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}function wa(e){return _n(e)}function Ta(e){return e===`done`?`text-semantic-green`:e===`failed`?`text-semantic-red`:e===`review`?`text-semantic-info`:e===`waiting`?`text-semantic-amber`:`text-muted-foreground`}function Ea({wait:e,dependencyLabel:t}){return(0,Z.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?yn(`waiting-on-workers`,t):`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting for request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting for workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,Z.jsxs)(Z.Fragment,{children:[` `,`Deadline: `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function Da(e){return e.delegation?.role===`worker`&&O(e)?.phase===`wake-pending`}function Oa({run:e}){let t=O(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,Z.jsx)(Ea,{wait:t,dependencyLabel:k(`worker`,t)}):null}function ka({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 Aa=new Set([`review`,`done`,`failed`,`cancelled`]);function ja({parentRunId:e,worker:t}){let n=l(e),[r,i]=(0,X.useState)(!1);if(!Aa.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 P?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:F(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,Z.jsx)(q,{variant:`danger-ghost`,size:`sm`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,Z.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>i(!1),children:`Cancel`})]}):(0,Z.jsx)(q,{variant:`outline`,size:`sm`,"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)(q,{variant:`danger-ghost`,size:`sm`,"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 Ma=(e,t,n)=>`${e} ${e===1?t:n}`;function Na(e){return[...e.uncommittedFiles?[Ma(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Ma(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Pa(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Fa({state:e}){if(!Pa(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,Z.jsx)(Ia,{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 Ia({at:e}){let t=nn(3e4);return(0,Z.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Zn(t,Date.parse(e))})}function La({items:e,lead:t=0,room:n,className:r}){let a=(0,X.useRef)(null),[o,s]=(0,X.useState)(-1/0);return(0,X.useLayoutEffect)(()=>{let r=a.current;if(!r)return;let i=n?r.closest(n):null,o=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=n+Ra(i),o=getComputedStyle(r),c=Number.parseFloat(o.width),l=c>0?n/c:1,u=(Number.parseFloat(o.columnGap)||0)*l,d=Array.from(r.children,e=>e.getBoundingClientRect().width),f=e.map((e,t)=>({...e,width:d[t]??0})),p=-1/0,m=()=>f.reduce((e,t)=>e+t.width,0)+Math.max(0,f.length-1)*u+(f.length>0?t*l:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(m()<=a)break;p=t,f=f.filter(e=>e.priority>t)}s(e=>e===p?e:p)};if(o(),typeof ResizeObserver>`u`)return;let c=new ResizeObserver(o);c.observe(r);for(let e of r.children)c.observe(e);return i&&c.observe(i),()=>c.disconnect()},[e,t,n]),(0,Z.jsx)(`span`,{ref:a,"data-slot":`activity-summary`,className:i(`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`,r),children:e.map(n=>{let r=n.priority<=o,i=n===e.find(e=>e.priority>o);return(0,Z.jsxs)(`span`,{"data-summary-item":n.id,"data-hidden":r,"aria-hidden":r||void 0,inert:r||void 0,style:i&&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:[!i||t>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ra(e){let t=e?.firstElementChild;return!e||!t?0:Math.max(0,e.getBoundingClientRect().width-t.getBoundingClientRect().width)}function za({run:e,references:t}){return(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,Z.jsx)(pe,{reference:t,taskTitle:J(e),inert:!0},ue(t)))})}function Ba(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?ln(e.accounts,e.accountBackend)?`default`:void 0:e.known?ln(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Va(e){let t=b(),n=v(),r=E(),{accounts:i}=cn(),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),f=Ba({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:d,accounts:i,accountBackend:u}),m=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?p(t.data,a):V(e.removedRunner),...f?{account:f}:{},model:o,effort:s,...m?{identity:m}:{}}}var Ha=[`running`,`queued`,`waiting`];function Ua(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 Wa(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 Ga(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Ka(e){let t=Ua(e.waits),n=Ha.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&Ga(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Ua(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 qa(e){return Ka(e)!==void 0}function Ja(e){return(Ka(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Ya({run:e}){let t=Ka(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)(Za,{run:e,wait:t},t.id):t.kind===`worker`?(0,Z.jsx)(Qa,{wait:t},t.id):t.kind===`process`?(0,Z.jsx)(io,{run:e,wait:t},t.id):t.kind===`peer`?(0,Z.jsx)($a,{wait:t},t.id):t.kind===`subagent`?(0,Z.jsx)(eo,{wait:t},t.id):t.kind===`plugin`?(0,Z.jsx)(to,{run:e,wait:t},t.id):(0,Z.jsx)(no,{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)(Za,{run:e,wait:r,settled:!0}):null,a?(0,Z.jsx)(io,{run:e,wait:a,settled:!0}):null]})}function Xa(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?En(r.headSha):`unknown`} → ${r?.observedHeadSha?En(r.observedHeadSha):`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Wa(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function Za({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=Xa(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:a(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:[i,` deadline unavailable`]})]})]})})}function Qa({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,r,` `,i]}),a?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,Z.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function $a({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`task`:`tasks`]}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function eo({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 to({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`?Wa(t.summary,e):t.summary}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function no({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:Wa(`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 ro(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 io({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?ro(t):t.phase===`resolved`?Wa(ro(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 ao=new Map,oo=new Map;function so(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=bt(e.run);return(0,Z.jsx)(de,{projectId:t,repoBase:n,requests:i,children:(0,Z.jsx)(co,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!G(e.run)||!!ce(e.run,n)})})}function co({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,presentation:s=`card`,prNumbers:c,hasReferences:l,references:u}){let d=sn(),f=Va(e),[p,m]=(0,X.useState)(()=>i?!1:ao.get(e.id)??!1),h=Eo(o,p),g=s===`panel`||h.open,[_,v]=(0,X.useState)({}),y=uo(e,t??n,n,r,c),b=_t(e),x=t=>_[t]??oo.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);oo.set(`${e.id}:${t}`,n),v(e=>({...e,[t]:n}))},C=e=>({open:x(e),onToggle:()=>S(e)}),w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,Z.jsx)(yo,{run:e,activity:y,...C(`status`)}),(0,Z.jsx)(bo,{run:e,desktop:d,automations:y.automations,...C(`workflow`)}),(0,Z.jsx)(xo,{activity:y,desktop:d,onOpenWorker:a,...C(`subagents`)}),(0,Z.jsx)(So,{run:e,...C(`workers`)}),(0,Z.jsx)(Co,{activity:y,desktop:d,...C(`plan`)}),(0,Z.jsx)(wo,{run:e,identity:f,activity:y,...C(`usage`)}),(0,Z.jsx)(To,{run:e,references:u,conflicts:y.conflicts,hasReferences:l,onResume:()=>b.mutate(),...C(`workspace`)})]});return s===`panel`?(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-presentation":`panel`,"data-state":`open`,"aria-label":`Session activity`,className:`flex min-w-0 flex-col bg-card`,children:[(0,Z.jsxs)(`div`,{className:`sticky inset-bs-0 z-10 flex items-center gap-2 bg-card px-3.5 py-2.5 text-[13px]`,children:[(0,Z.jsx)(K,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Session activity`}),y.cost?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums`,children:y.cost}):null]}),w]}):(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:h.ref,"data-state":g?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Z.jsx)(go,{run:e,identity:f,activity:y,references:u,open:g,onToggle:()=>{ao.set(e.id,!g),m(!g),h.chose(!g)}}),g?w:null]})}function lo(e,t,n,r){let i=D(),a=Rn(i.data),o=x(),s=St(e,{queuePosition:e.status===`queued`?Yt(o.data??[]).get(e.id):void 0}),c=!qt(e)&&e.status!==`queued`,l=(0,X.useMemo)(()=>r?mr(n.turns,c,t.turns):[],[r,n.turns,c,t.turns]),u=Nt(n)??[],d=va(e),f=gr(l),p=$i(u);return{health:i,line:s,...fo(e,s,d,r?f:void 0,p),...po(e,a),agents:l,agentCounts:f,planEntries:u,planCounts:p}}function uo(e,t,n,r,i){let a=lo(e,t,n,r),o=fe(i);return{...a,conflicts:o,waitReferences:Ja(e),automations:vn(a.health.data)}}function fo(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`,glyph:o?(0,Z.jsx)(ke,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function po(e,t){return{cost:t.cost&&e.costUsd!==void 0?le(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,Z.jsx)(Fn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function mo(e){return e.allComplete?`text-semantic-green`:e.failed&&`text-semantic-red`}function ho(e){let t=da(e),n=pa(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function go({run:e,identity:t,activity:n,references:r,open:a,onToggle:o}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[ue(e),e])).values()];return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-label":_o(e,t,n,c,a),onClick:o,className:i(`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`,a?`gap-2.5`:`gap-2`),children:[(0,Z.jsx)(K,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),a?null:(0,Z.jsx)(vo,{run:e,identity:t,activity:n,summaryReferences:c}),a&&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)(Ae,{"aria-hidden":!0,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,a&&!s&&`ms-auto`,a&&`rotate-180`)})]})}function _o(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=ho(e)?.step,u=l?`; step ${l.name}, ${aa(ia(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 vo({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:a,cost:o,conflicts:s}=n,c=ho(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)(za,{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)(ye,{"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:a,className:i(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,mo(n)),children:[n.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:a})]}),c?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-step`,className:i(`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)(Ao,{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)(La,{items:l,lead:8})})]})}function yo({run:e,activity:t,open:n,onToggle:r}){let{line:a,waitReferences:o}=t,s=Da(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:i(`truncate`,mo(t)),children:t.statusText}),a.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:a.nextCheck.at,children:a.nextCheck.text})]}):null]}),summary:!n&&o.length>0?(0,Z.jsx)(La,{items:[{id:`chips`,priority:0,content:(0,Z.jsx)(za,{run:e,references:o})}]}):void 0,open:n,onToggle:qa(e)||s?r:void 0,children:[(0,Z.jsx)(Ya,{run:e}),s?(0,Z.jsx)(Oa,{run:e}):null]})}function bo({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=se(e),o=ho(e);return!a&&!o?null:(0,Z.jsxs)(Q,{slot:`workflow`,icon:o?(0,Z.jsx)(Ao,{step:o.step,runStatus:e.status}):(0,Z.jsx)(xe,{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:ma(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,Z.jsx)(sa,{steps:o.steps,runStatus:e.status}):null,(0,Z.jsx)(ko,{run:e,available:n})]})}function xo({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)(ve,{className:`size-4`}),title:`Subagents`,meta:ma(o.done,o.total,t),open:r,onToggle:i,children:(0,Z.jsx)(Xi,{agents:a,onSelect:n})})}function So({run:e,open:t,onToggle:n}){return ga(e)?(0,Z.jsx)(ba,{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)(he,{className:`size-4`}),title:`Plan`,meta:ma(a.done,a.total,t),open:n,onToggle:r,children:(0,Z.jsx)(ea,{entries:i})})}function wo({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)(Qn,{className:`size-4`}),title:`Usage & agent`,summary:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(La,{items:c})}),open:r,onToggle:i,children:(0,Z.jsx)(Oo,{run:e,tokens:o,cost:a})})}function To({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||Sn(e)||Pa(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)(we,{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)(La,{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)(za,{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)(ye,{"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)(Fa,{state:s}):null,(0,Z.jsx)(xt,{run:e}),e.branch?(0,Z.jsx)(Do,{label:`Branch`,children:(0,Z.jsx)(yt,{branch:e.branch})}):null,e.worktreePath?(0,Z.jsx)(Do,{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)(vt,{run:e,canResume:mn(e).terminal,onResume:i})]})})}function Eo(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 Do({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 Oo({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Va(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 ko({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)(Ut,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:i(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 Ao({step:e,runStatus:t,decorative:n=!1}){let r=ia(e.status,t),a=`size-4 shrink-0`;switch(r){case`active`:return(0,Z.jsx)(Tt,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Te,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,la)});case`failed`:return(0,Z.jsx)(ge,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-danger`)});case`pending`:return(0,Z.jsx)(Ce,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-soft-foreground`)});case`done`:return(0,Z.jsx)(ke,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-success`)})}}function jo(e,t,n,r){let i=lo(e,t,n,r),a=ga(e),o=w(e.id,{enabled:a}),s=(0,X.useMemo)(()=>{let t=e.delegation?.role===`root`?e.delegation.receipts.map(e=>e.workerId):[],n=o.data?.workers.map(e=>e.workerId)??[];return new Set([...t,...n]).size},[e.delegation,o.data?.workers]),c=da(e),l=c.length>0?c[pa(e.currentStepId,c)]:void 0;return{statusText:i.statusText,glyph:i.glyph,allComplete:i.allComplete,failed:i.failed,activeStepName:l?.name,shownStepName:l&&ia(l.status,e.status)!==`done`?l.name:void 0,workerCount:s,agentCounts:i.agentCounts,cost:i.cost,nextCheckText:i.line.nextCheck?.text,line:i.line}}function Mo(e,t){let n=[`Session activity: ${e.statusText}`];return e.nextCheckText&&n.push(`Next check ${e.nextCheckText}`),e.activeStepName&&n.push(`step ${e.activeStepName}`),e.workerCount>0&&n.push(`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`),e.agentCounts.total>0&&n.push(`${e.agentCounts.done}/${e.agentCounts.total} subagents`),e.cost&&n.push(`cost ${e.cost}`),t===`sidebar`&&n.push(`toggle activity sidebar`),n.join(`; `)}function No({props:e,align:t,sideOffset:n,collisionPadding:r=0,contentClassName:i,children:a}){let{run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u,open:d,onOpenChange:f,keepOpen:p=!1,onOpenAutoFocus:m}=e,h=e=>{p&&e.preventDefault()};return(0,Z.jsxs)(Vt,{open:d,onOpenChange:e=>{!e&&p||f(e)},children:[(0,Z.jsx)(Rt,{asChild:!0,children:a}),(0,Z.jsx)(Bt,{align:t,sideOffset:n,collisionPadding:r,"data-slot":`run-activity-popover`,className:i,onOpenAutoFocus:m,onInteractOutside:h,onPointerDownOutside:h,onFocusOutside:h,onEscapeKeyDown:h,children:(0,Z.jsx)(so,{presentation:`panel`,run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u})})]})}function Po(e,t=!1){let n=t?`${e.workerCount}w`:`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`,r=`${e.agentCounts.done}/${e.agentCounts.total}${t?``:` agents`}`;return[...e.shownStepName?[{id:`step`,priority:0,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-step`,className:i(`truncate`,t?`max-w-[96px]`:`max-w-[140px]`),children:e.shownStepName})}]:[],...e.workerCount>0?[{id:`workers`,priority:3,content:(0,Z.jsx)(`span`,{"data-slot":`activity-workers-badge`,children:n})}]:[],...e.agentCounts.total>0?[{id:`subagents`,priority:2,content:(0,Z.jsx)(`span`,{"data-slot":`activity-subagents-badge`,children:r})}]:[],...e.cost?[{id:`cost`,priority:1,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`font-mono text-xs`,children:e.cost})}]:[]]}function Fo(e){let{run:t,thread:n,currentThread:r,currentComplete:a,mode:o,open:s,onOpenChange:c}=e,l=jo(t,n,r,a),u=Mo(l,o),d=l.allComplete?`text-semantic-green`:l.failed?`text-semantic-red`:`text-foreground`,f=(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger`,"data-activity-mode":o,"aria-expanded":s,"aria-label":u,onClick:o===`sidebar`?()=>c(!s):void 0,className:i(`inline-flex min-h-9 max-w-full items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-[12px] font-medium text-foreground shadow-xs transition-colors`,`pointer-hover:bg-muted/60 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,s&&`border-accent-strong/60`),children:[(0,Z.jsxs)(`span`,{"data-slot":`pill`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[l.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:d,children:(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,children:l.statusText})})]}),(0,Z.jsx)(`span`,{className:`-ms-2 grid min-w-0 grid-cols-[minmax(0,max-content)]`,children:(0,Z.jsx)(La,{items:Po(l),lead:8,room:`[data-slot='run-status-slot']`})}),(0,Z.jsx)(Ae,{"aria-hidden":`true`,className:i(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,s&&`rotate-180`)})]});return(0,Z.jsx)(`span`,{"data-slot":`run-status-slot`,className:`hidden`,children:o===`sidebar`?f:(0,Z.jsx)(No,{props:e,align:`end`,sideOffset:6,contentClassName:`w-[380px] max-w-[calc(100vw-2rem)] max-h-[min(70dvh,540px)] overflow-y-auto overscroll-contain p-0`,children:f})})}var Io=`[data-slot='mobile-status-room']`;function Lo(e){let{run:t,thread:n,currentThread:r,currentComplete:a,open:o}=e,s=jo(t,n,r,a),c=Mo(s,`popover`),{attention:l}=s.line;return(0,Z.jsx)(No,{props:e,align:`start`,sideOffset:10,collisionPadding:8,contentClassName:`w-[420px] max-w-[calc(100vw-1rem)] max-h-[min(65dvh,460px)] overflow-y-auto overscroll-contain p-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger-mobile`,"aria-expanded":o,"aria-label":c,className:i(`-mt-[18px] -mb-2 inline-flex h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md pt-[18px] pb-2 text-start md:hidden`,`focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-ring`),children:[(0,Z.jsx)(Bn,{"data-slot":`mobile-run-status`,dot:l.tone,shape:l.shape,pulse:l.pulse,className:`min-w-0 px-2 py-px text-xs leading-4`,children:(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`truncate`,children:s.line.label})}),(0,Z.jsx)(`span`,{className:`-ms-1.5 grid min-w-0 shrink-[1000] grid-cols-[minmax(0,max-content)]`,children:(0,Z.jsx)(La,{items:Po(s,!0),lead:6,room:Io,className:`h-[18px] gap-1.5 text-xs`})}),(0,Z.jsx)(Ae,{"aria-hidden":`true`,className:i(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,o&&`rotate-180`)})]})})}var Ro=2e3;function zo(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 Bo(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 Vo(e,t){let n=W(),r=(0,X.useMemo)(()=>zo(t),[t]),i=(0,X.useMemo)(()=>Bo(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()})},Ro);return()=>clearTimeout(e)},[r,i,a,o,n])}function Ho(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Uo({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=Pi(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Ho);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}var Wo=12;function Go({run:e}){let t=W(),n=T({mutationFn:()=>I(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:d.runs.detail(e.id)}),t.invalidateQueries({queryKey:d.runs.list()}),B(`This task will not resume itself`)},onError:e=>B(e.message,{tone:`danger`})});if(!z(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,Z.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Z.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Wo,`)`]}):(0,Z.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Z.jsx)(oe,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Ko({pinnedAskId:e,run:t,askModeState:n,replyPending:r,composerPending:i}){let a=e!==void 0,o=pn(t,a),s=n.askId===e?n.mode:`options`;return{hasPendingAsk:a,isReviewGate:o,askMode:s,decisionMode:a?`ask`:o?`review`:`composer`,unifiedReplyActive:a&&s===`reply`,composerHidden:o||a&&s===`options`,optionDeliveryPending:a&&r&&!i}}function qo(e){let{run:t,thread:n,pinnedAsk:r,pendingQuestions:a,scroll:o,onJump:s,onShowOrigin:c,sessionOpen:l,attention:u,queued:d,continuable:f,continueAction:p,stopAction:m,finishAction:h,needsAnswer:g,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,removedRunnerNotice:x}=e,S=mn(t,ya(t)).cancel,[C,w]=(0,X.useState)({askId:r?.id,mode:`options`}),[T,E]=(0,X.useState)(!1),D=e=>w({askId:r?.id,mode:e}),{hasPendingAsk:O,isReviewGate:k,askMode:A,decisionMode:j,unifiedReplyActive:M,composerHidden:N,optionDeliveryPending:P}=Ko({pinnedAskId:r?.id,run:t,askModeState:C,replyPending:v.isPending,composerPending:T});return(0,Z.jsxs)(`div`,{"data-slot":`thread-dock`,"data-pending-ask":g||void 0,"data-decision-mode":j,className:i(`relative z-10 shrink-0 bg-background py-1.5 md:pt-2.5 md:pb-4`,k&&`py-0 md:pt-0 md:pb-0`),children:[o.pillVisible?(0,Z.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,Z.jsx)(wi,{pendingQuestions:a,onJump:s})}):null,(0,Z.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:i(`mx-auto flex w-full min-w-0 max-w-[var(--measure)] flex-col px-[14px] md:px-16`,M?`gap-0`:`gap-1.5 md:gap-2`),children:[k?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Go,{run:t}),(0,Z.jsx)(Jo,{run:t,sessionOpen:l,attention:u,queued:d,continuable:f,startsNewConversation:p.startsNewConversation,removedRunnerNotice:x})]}),r===void 0?null:(0,Z.jsx)(ut,{ask:{...r,placement:`pinned`},run:t,surface:`decision-zone`,mode:A,onModeChange:D,hideReplyBody:!0,delivery:v,onShowOrigin:c,onStop:S?m.stop:void 0,stopping:m.stopping,onFinish:An(t)?()=>h.mutateAsync():void 0,finishing:h.isPending},r.id),(0,Z.jsx)(`div`,{"data-slot":`thread-composer-slot`,hidden:N,className:i(`min-w-0 w-full`,N&&`hidden`,M&&`rounded-b-xl border border-t-0 border-accent-strong/30 bg-accent-strong/[0.04] p-2.5 [html:not(.light)_&]:bg-card`),children:(0,Z.jsx)(Zo,{run:t,thread:n,canStop:S,hasPendingAsk:O,composerHidden:N,optionDeliveryPending:P,onComposerPendingChange:E,stopAction:m,finishAction:h,attention:u,needsAnswer:g,continuable:f,continueAction:p,queued:d,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,sessionOpen:l})})]})]})}function Jo({run:e,sessionOpen:t,attention:n,queued:r,continuable:i,startsNewConversation:a,removedRunnerNotice:o}){if(e.status===`waiting`&&t)return(0,Z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:n.tone,shape:n.shape,pulse:n.pulse}),n.bucket===`permission`?`Choose an approval option above to continue`:n.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${xn(e,n).label} — you can send a message to resume`]});if(e.status===`running`){let t=St(e,{}),n=da(e),r=n.length>0?n[pa(e.currentStepId,n)]:void 0;return(0,Z.jsxs)(`div`,{"data-slot":`running-hint`,className:`flex min-w-0 items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[t.label,r?` · ${r.name}`:``]})]})}return r?(0,Z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):o===void 0?i&&a?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null:(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:o})}function Yo(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 Xo(e,t){let{run:n,hasPendingAsk:r,optionDeliveryPending:i,continuable:a,continueAction:o,queued:s,sendMessage:c,reply:l,providerBlocked:u,providerReason:d,sessionOpen:f}=e,p=async(e,t)=>{let n=await l.send(e,t);if(n!==void 0)throw Error(n)};return r?{onSubmit:p,pendingLabel:l.mode===`resume`?`Continuing…`:`Sending…`,disabled:u||l.blockedBy!==void 0||i,disabledReason:u?d:i?`Sending your answer…`:l.reason,placeholder:t?`Reply`:`Reply — / for skills, @ for files…`}:{onSubmit:a?(e,t)=>o.continueWith(e,t??[]):s?(e,t)=>c.mutateAsync({text:e,images:t}):p,pendingLabel:a?`Continuing…`:`Sending…`,disabled:u||!f&&!s&&!a,disabledReason:u?d:`Session closed — no session to resume.`,placeholder:(t?$o:es)(n,s,a)}}function Zo(e){let{run:t,thread:n,canStop:r,hasPendingAsk:i,composerHidden:a,onComposerPendingChange:o,stopAction:s,finishAction:c,attention:l,needsAnswer:u,continuable:d,continueAction:f,providerBlocked:p}=e,m=!sn(),h=Xo(e,m),g=!i&&d&&!u;return(0,Z.jsx)(In,{...Yo(t,d,f),onPendingChange:o,onStop:r?s.stop:void 0,onFinish:An(t)?()=>c.mutateAsync().catch(()=>void 0):void 0,finishing:c.isPending,stopOnEmpty:!i&&Qo(t,l,u),stopping:s.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:h.pendingLabel,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:!i&&d?f.pills:void 0,onSubmit:h.onSubmit,disabled:h.disabled,disabledReason:h.disabledReason,footerEnd:p&&!f.providerPending?(0,Z.jsx)(Ut,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:g,emptySubmitVariant:t.status===`review`?`outline`:`primary`,emptySubmitLabel:g?`Continue`:void 0,placeholder:h.placeholder,autocompleteSkills:!0,phoneRest:m,quickReplies:!a,getMentionCandidates:()=>Mt(n)})}function Qo(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function $o(e,t,n){return t?`Add to the prompt`:n?`Add a prompt…`:e.status===`waiting`?`Reply`:`Message the agent`}function es(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 ts(){let{id:e}=ae(),t=c(e),n=Ln(e),r=t.data?.status,i=(0,X.useMemo)(()=>At(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,X.useMemo)(()=>At(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),s=(0,X.useRef)(void 0),l=(0,X.useCallback)(e=>{s.current=e},[]),{mutate:u}=o();if((0,X.useEffect)(()=>{t.data&&s.current!==t.data.id&&Xt(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Vo(t.data,n.visibleEvents),t.isPending)return(0,Z.jsx)(hn,{});if(t.isError){let e=t.error instanceof P&&t.error.status===404;return(0,Z.jsx)(on,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,Z.jsx)(un,{icon:e?(0,Z.jsx)(Dt,{}):(0,Z.jsx)(gt,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,Z.jsx)(q,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(Ut,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Z.jsx)(hn,{}):(0,Z.jsx)(rs,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:l})}var ns=e=>({titles:Object.fromEntries(e.map(e=>[e.id,J(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function rs({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Ht();let a=U({queryKey:d.runs.list(),queryFn:({signal:e})=>M(g(),{signal:e}),select:ns}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=cs(r,n),u=j(e),f=kt(e.status,e.error,t),p=Pn(e),_=!p&&e.status!==`queued`,v=e.status===`queued`,y=ir(e),b=Yi(e),x=Xn(e.id),S=s||R(e),{hasContinuation:C,continuable:w}=ls(p,v,y),{openAgentId:T,setOpenAgentId:E,activityMode:D,activityOpen:O,setActivityOpen:k,showActivitySidebar:A,closeActivityPopover:N}=os(e.id),P=(0,X.useRef)(void 0),F=(0,X.useCallback)(e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(t=>t.dataset.agentId===e);if(t){t.focus({preventScroll:!0});return}P.current=e,k(!0)},[k]),I=(0,X.useCallback)(e=>{let t=P.current;if(!t)return;P.current=void 0;let n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);n&&(e.preventDefault(),n.focus({preventScroll:!0}))},[]),{openAgent:ee,openAgentChildren:L}=is(T,n,t,_),z=m(e.id),B=zn(e),{providerBlocked:V,providerReason:H}=us(p,Cn(e),C,y),ne=ss(e,v),W=l?void 0:c??null,re=(0,X.useMemo)(()=>Ai(n,W),[n,W]),ae=re?.questions.length??0,oe=(0,X.useMemo)(()=>ji(e,t,n,W,{pinPendingAskInTranscript:!1}),[e,t,n,W]),G=(0,X.useMemo)(()=>Li(oe,e.id),[oe,e.id]),{taskTitles:se,recipientBackends:le}=as(e,a.data),ue=(0,X.useCallback)(t=>(0,Z.jsx)(jr,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),de=w&&e.removedRunner!==void 0?te(e.removedRunner):void 0,fe=ce(e,h()),{search:pe}=ie(),me=Ve(pe,G.length),K=bi(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:G.map(({key:e})=>e)}),he=Uo({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:G,history:r,jumpToRow:K.jumpToRow}),ge=(0,X.useRef)(c);l||(ge.current=c);let _e=hi(),ve=(0,X.useRef)({reveal:he.reveal});ve.current={reveal:he.reveal};let ye=(0,X.useCallback)(()=>{di(_e.current??document.body)?.focus({preventScroll:!0})},[_e]),be=(0,X.useCallback)(t=>t.placement===`origin`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.context?(0,Z.jsx)(at,{text:t.context}):null,t.resolved?null:(0,Z.jsx)(mi,{onGoToQuestion:ye})]}):(0,Z.jsx)(ut,{ask:t,run:e,onShowOrigin:()=>ve.current.reveal()}),[e,ye]);zt(K.restickIfStuck);let xe=r?.currentComplete??!0,Se={run:e,thread:t,currentThread:n,currentComplete:xe,onOpenWorker:E,mode:D,open:O,onOpenChange:k,keepOpen:T!==void 0,onOpenAutoFocus:I};return(0,Z.jsxs)(on,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,fillHeight:!0,flushPadding:!0,rootRef:_e,rootProps:{"data-run-id":e.id},className:`overflow-clip`,children:[(0,Z.jsx)(Ct,{run:e,onMarkedUnread:()=>i?.(e.id),desktopActivitySlot:(0,Z.jsx)(Fo,{...Se}),mobileActivitySlot:(0,Z.jsx)(Lo,{...Se})}),(0,Z.jsxs)(`div`,{"data-slot":`thread-workspace`,children:[(0,Z.jsxs)(`div`,{"data-slot":`thread-main`,children:[(0,Z.jsx)(`div`,{"data-slot":`thread-transcript`,role:`region`,"aria-label":`Session transcript`,tabIndex:0,children:(0,Z.jsx)(ds,{run:e,thread:t,history:r,footer:f,issueUrl:fe,sections:oe,renderAsk:be,renderPermission:ue,messageActions:ne,scroll:K,mode:me,taskTitles:se,recipientBackends:le})}),(0,Z.jsx)(qo,{run:e,thread:t,pinnedAsk:re,pendingQuestions:ae,scroll:K,onJump:()=>{let e=ae>0?re?.id:void 0;K.jumpToLatest(e===void 0?void 0:fi(e,()=>ge.current===e))},onShowOrigin:()=>ve.current.reveal(),sessionOpen:p,attention:u,queued:v,continuable:w,continueAction:y,stopAction:b,finishAction:x,needsAnswer:S,sendMessage:z,reply:B,providerBlocked:V,providerReason:H,removedRunnerNotice:de})]}),A?(0,Z.jsx)(`aside`,{"data-slot":`thread-activity-sidebar`,"aria-label":`Session activity`,children:(0,Z.jsx)(so,{presentation:`panel`,run:e,thread:t,currentThread:n,currentComplete:xe,onOpenWorker:E})}):null]}),(0,Z.jsx)(Ki,{runId:e.id,renderAsk:be,renderPermission:ue,agent:ee,entries:L,taskTitles:se,recipientBackends:le,onBeforeOpenReport:N,onRestoreAgentFocus:F,onClose:()=>E(void 0)})]})}function is(e,t,n,r){return{openAgent:(0,X.useMemo)(()=>e===void 0?void 0:yr(t.turns,e,r,n.turns),[t.turns,e,r,n.turns]),openAgentChildren:(0,X.useMemo)(()=>e===void 0?[]:Sr(n.turns,t.turns,e),[n.turns,t.turns,e])}}function as(e,t){let n=e.delegation?.role===`root`||e.delegation?.role===`worker`,r=w(e.id,{enabled:n});return{taskTitles:(0,X.useMemo)(()=>({...Ir(e,void 0,r.data?.titles),...t?.titles,[e.id]:J(e)}),[e,t,r.data]),recipientBackends:(0,X.useMemo)(()=>({...t?.backends,...Fr(e,void 0)}),[e,t])}}function os(e){let[t,n]=(0,X.useState)(void 0),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!0),[s,c]=(0,X.useState)(e);s!==e&&(c(e),n(void 0),i(!1));let l=Nn(),u=jn()||l?.open===!0,d=kn(`(min-width: 1600px)`,!1)&&!u?`sidebar`:`popover`;return{openAgentId:t,setOpenAgentId:n,activityMode:d,activityOpen:d===`sidebar`?a:r,setActivityOpen:d===`sidebar`?o:i,showActivitySidebar:d===`sidebar`&&a,closeActivityPopover:(0,X.useCallback)(()=>i(!1),[])}}function ss(e,t){let{mutateAsync:n}=f(e.id),{mutateAsync:r}=u(e.id),{mutateAsync:i}=C(e.id);return(0,X.useMemo)(()=>{if(!t)return;let a={task:{onEdit:async e=>{await n({task:e})},editLabel:`Edit the prompt`}};for(let t of e.queuedMessages??[])a[`queued:${t.id}`]={onEdit:e=>r({msgId:t.id,message:{text:e}}).then(()=>void 0),onRemove:()=>i(t.id).then(()=>void 0)};return a},[t,e.queuedMessages,n,r,i])}function cs(e,t){let n=e?Et(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 ls(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function us(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function ds({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}){let h=Un()===`changes`;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)(fs,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,Z.jsx)(Ri,{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)(ps,{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:i(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[r.label,a(G(e))?(0,Z.jsx)(`a`,{"data-slot":`pr-link`,href:G(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,a(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`&&!h?(0,Z.jsx)(Jn,{runId:e.id}):null]})}function fs({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Z.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,Z.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-xs text-soft-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Z.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function ps({run:e}){let t=Wn(x().data??[],e.id);return(0,Z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),(0,Z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{ts as TaskThreadRoute};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{o as t}from"./dist-C_rn70hE.js";import{ii as n,vr as r,yr as i}from"./toaster-zMN8cNZQ.js";import{h as a,p as o,v as s}from"./live-protocol-DMhTnCmf.js";import{t as c}from"./createLucideIcon-BHp8sXmF.js";import{t as l}from"./app-window-CSHwDX9N.js";import{t as u}from"./play-CmVAj_fu.js";import{i as d,n as ee,o as te,r as ne}from"./tool-display-B9NN44oU.js";import{t as re}from"./square-terminal-B6RYYieR.js";import{t as ie}from"./button-B22ANdCY.js";import{t as ae}from"./status-dot-Drd4-nfa.js";import{a as oe,o as se}from"./format-BU7D3IfE.js";import{h as ce,m as f,yr as p}from"./index-DJB0lid-.js";var m=c(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),h=e(),g={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function _(e){let{text:t,...n}=ce(e),r={...n,status:t},i=g[e.state](e);return i?{...r,action:i}:r}var v={"Run and open":u,Open:l,View:p,"Start again":te};function y({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=_(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=f(i.command),l=oe(i.registeredAt);return(0,h.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,h.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,h.jsx)(`span`,{children:`worktree removed`}):l?(0,h.jsx)(`span`,{children:se(l)}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(ae,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,h.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,h.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,h.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,h.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,h.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,h.jsx)(`span`,{children:`cwd`}),(0,h.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,h.jsx)(b,{icon:(0,h.jsx)(re,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,h.jsx)(b,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:e,inPreview:t,action:n,onOpen:r}){let{server:i}=e,a=t&&n!==void 0&&!n.run,o=a?`In preview`:n?.label,s=a?l:n?v[n.label]:null;return n&&o&&s?(0,h.jsxs)(ie,{variant:a||n.label===`View`||n.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:px-3.5`,onClick:()=>r?.({port:i.port,run:n.run}),children:[(0,h.jsx)(s,{"aria-hidden":`true`}),o]}):null}function b({icon:e,children:t}){return(0,h.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,h.jsx)(`span`,{children:t})]})}function x(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}function ue(){return{turns:[],itemsById:new Map,turnSeq:0,eventSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return typeof e==`string`?e:void 0}function w(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}`}function T(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function de(e){return n.safeParse(e).data}function E(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function D(e){return e.turns.at(-1)??E(e)}function O(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return D(e).entries.push(n),n}var k=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],A=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function j(e){return e.trim().replace(/\s+/g,` `)}function M(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of k){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return j(t)}function N(e,t,n){if(t===e.primarySource&&n===e.primaryText||e.draft.entry.kind!==`note`)return;let r=e.draft.entry;r.details?.some(e=>e.source===t&&e.text===n)||(r.details=[...r.details??[],{source:t,text:n}])}function P(e,t,n){let r=e.failures;if(r)for(let e=r.length-1;e>=0;--e){let i=r[e];if(t!==``&&i.cause===t||t===``&&i.fatal&&(n===void 0||i.stepId===void 0||i.stepId===n))return i}}function F(e,t,n){let r=D(e),i=P(r,n.cause,n.stepId);if(i){i.draft.lastSeq=Math.max(i.draft.lastSeq,t.seq),n.fatal&&(i.fatal=!0),n.stepId!==void 0&&i.stepId===void 0&&(i.stepId=n.stepId),N(i,n.source,n.text);return}let a={draft:O(e,{kind:`note`,id:n.id,text:n.text,tone:`danger`}),cause:n.cause,primarySource:n.source,primaryText:n.text,...n.stepId===void 0?{}:{stepId:n.stepId},fatal:n.fatal};r.failures=[...r.failures??[],a]}function I(e,t,n){if(!A.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=M(n);if(i===``)return!1;let a=P(r,i,C(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,N(a,`lifecycle`,n),!0):!1}function L(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=P(r,n?M(n):``,C(t.stepId));i&&(i.fatal=!0)}function R(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function z(e,t){let n=C(e.stepId);return n===void 0?t:`${n}:${t}`}function B(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function V(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&B(e,t);let s=e.itemsById.get(r);if(s&&s.turn===t){s.entry.entry=o,s.entry.lastSeq=e.eventSeq,s.entry.streaming=a;return}let c={origin:`v2`,entry:o,firstSeq:e.eventSeq,lastSeq:e.eventSeq,streaming:a};t.entries.push(c),e.itemsById.set(r,{turn:t,entry:c})}var H={"not-delivered":0,queued:1,delivered:2,consumed:3},fe=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of fe)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function W(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function pe(e,t){let n=e.conversationEntries.get(t);n&&W(e,n)}function me(e,t,n,r){(H[e.delivery]<H.delivered||H[n]>H[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,U(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function G(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){me(i,t,n,r),W(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...U(t)};W(e,a),e.conversationEntries.set(t.id,a),O(e,a)}function he(e,t){let n=w(t.ts),r=C(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function ge(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=C(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${C(t.event)?` (${C(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${C(t.error)??`unknown error`}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function _e(e,t){let n=C(t.webhookName)??`webhook`,r=C(t.title),i=`v1:${t.seq}`;if(t.ok===!1){O(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${C(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${w(t.ts)}${r?` — ${r}`:``}`;O(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function ve(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${C(t.event)??`delivery`}${C(n.status)?` · ${C(n.status)}`:``}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function ye(e,t){let n=r.safeParse(t.server);if(!n.success)return;let i=e.previewByPort.get(n.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=D(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function be(e,t){let n=i.safeParse(t.state),r=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!r||r.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=r.draft.entry;r.draft.lastSeq=t.seq,r.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function xe(e,t){let n=a.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:o,consumedAt:s,ts:c}=n.data;G(e,r,i,{deliveredAt:o,consumedAt:s,recordedAt:c})}function Se(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),pe(e,r.requestId))}function Ce(e,t){let n=o.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){G(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}O(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function we(e,t){let n=C(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=E(e,t.seq),a=T(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Te(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:E(e,t.seq);r.turnId=C(t.turnId),r.startedAt??=T(t.ts)}function Ee(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function De(e,t){R(e);let n=Ee(e,C(t.turnId));if(!n)return;let r=T(t.ts);n.completed={stopReason:C(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),Oe=e=>K.has(e.kind);function ke(e){if(!(!S(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=ke(t.item);if(!n)return;let r=z(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);V(e,i?.turn??D(e),n,r,a?T(t.ts):void 0,o)}function Ae(e,t){let n=e.itemsById.get(z(t,C(t.itemId)??``)),r=C(t.delta)??``;if(!n||r===``||!Oe(n.entry.entry))return;let i=n.entry.entry;n.entry.lastSeq=t.seq,t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function je(e,t){let n=D(e),r=C(t.text)??``;if(r===``)return;let i=T(t.ts);n.entries.push({origin:`v1`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var Me=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ne(e){if(!S(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!S(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Me.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Pe=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Fe(e,t){let n=D(e),r=C(t.tool)??`Tool`;if(n.v2Items||Pe.has(r))return;let i=ee(r,t.input),a=i.toolKind===`plan`?Ne(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:C(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o,firstSeq:t.seq,lastSeq:t.seq};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Ie(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Le(e,t){let n=e.itemsById.get(C(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(n.entry.lastSeq=t.seq,r.status=`completed`,r.output=Ie(t.result))}function Re(e,t,n,r){let i=C(t.message)??``;i!==``&&O(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){let n=C(t.message)??``;t.type===`lifecycle`&&n!==``&&I(e,t,n)||Re(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ze(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:!1})}function Be(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:t.fatal===!0})}function Ve(e,t){if(t.status!==`failed`)return;let n=C(t.stepId),r=C(t.error),i=r?` — ${r}`:``;F(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?M(r):``,stepId:n,fatal:!0})}function He(e,t){let n=C(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;O(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:C(t.text)??``,exitCode:r})}function Ue(e,t){let n=de(t.provider),r=C(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||O(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function We(e,t){let n=C(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=C(t.name);i!==void 0&&(r.name=i),O(e,r)}function Ge(e,t){Array.isArray(t.entries)&&(D(e).planEntries=t.entries)}function Ke(e,t){R(e);let n=C(t.reason)??`end_turn`,r=C(t.message);n===`error`&&L(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var qe=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function Je(e){return S(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&qe.has(e.kind)}function Ye(e){if(!(!Array.isArray(e)||e.length===0||!e.every(Je)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Xe(e,t){let n=C(t.requestId),r=C(t.title),i=Ye(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=C(t.itemId),o=C(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),O(e,s)}function Ze(e,t){let n=e.permissions.get(C(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=C(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=C(t.reason);i!==void 0&&(n.reason=i)}function Qe(e,t){let n=d(t),r=n&&ne(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};O(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function $e(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=C(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function et(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function tt(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var nt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function rt(e,t){let n=Y(e,t);n&&nt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function it(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Z=()=>{},at=new Map([[`handoff`,he],[`webhook.failed`,ge],[`webhook.dry-run`,ve],[`webhook.report`,_e],[`preview.server-registered`,ye],[`preview.server-state`,be],[`conversation-message`,xe],[`request-outcome`,Se],[`agent-input`,Ce],[`user-message`,we],[`turn.started`,Te],[`turn.completed`,De],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,Ae],[`text`,je],[`tool-call`,Fe],[`tool-result`,Le],[`note`,J],[`lifecycle`,J],[`error`,ze],[`session.error`,Be],[`step-end`,Ve],[`check-output`,He],[`provider-auth-required`,Ue],[`image`,We],[`plan.updated`,Ge],[`session.started`,e=>R(e)],[`session.ended`,Ke],[`permission.requested`,Xe],[`permission.resolved`,Ze],[`ask.requested`,Qe],[`worker-question-routed`,$e],[`worker-question-fallback`,et],[`worker-question-undelivered`,tt],[`human-ask-closed`,rt],[`human-input-delivered`,it],[`step-start`,Z],[`token-usage`,Z],[`cost`,Z],[`turn-end`,Z],[`done`,Z],[`session`,Z]]);function ot(e,t){e.eventSeq=t.seq,at.get(t.type)?.(e,t)}function st(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ct(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=new Set;for(let e=t.length-1;e>=0;--e)n.add(t[e]);return[...n]}function lt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=M(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&M(e.text)===r)}function ut(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!lt(n,t)?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function Q(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
|
|
2
|
-
`)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
|
|
3
|
-
`).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
|
|
4
|
-
`):n}var dt=/\s*(?:^|\n)C(?:E(?:Z(?::.*)?)?)?$/,ft=/[ \t]+CEZ(?::[A-Z]*)?$/;function $(e){return e.replace(dt,``).replace(ft,``)}function pt(e,t,n){return t!==``&&e.some(e=>e.norm===``?n>e.firstSeq:e.norm.startsWith(t)||t.startsWith(e.norm))}function mt(e,t){let n=e=>Q(e,!0).replace(/\s+/g,``),r=new Set,i=[],a=[];for(let{origin:o,entry:s,firstSeq:c,streaming:l}of e.entries)if(o===`v2`&&s.kind===`message`){let e=n(s.text);r.add(e),i.push(e),t&&l===!0&&a.push({norm:e,firstSeq:c})}if(i.length===0)return;r.add(i.join(``));let o=[],s={entries:[],texts:[]},c=()=>{let e=n(s.texts.join(``)),t=s.entries[0],i=s.entries.length>=2&&r.has(e);if(t&&(i||pt(a,e,t.firstSeq))){s={entries:[],texts:[]};return}o.push(...s.entries),s={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(s.entries.push(t),s.texts.push(t.entry.text)):(c(),o.push(t));c(),e.entries=o}function ht(e,t){let n=new Set;for(let{origin:t,entry:r}of e.entries)t===`v2`&&r.kind===`message`&&n.add(Q(r.text,!0).trim());n.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&n.has(Q(e.entry.text,!0).trim()))),mt(e,t))}function gt(e){let t=e.failures?.filter(e=>e.fatal&&e.cause!==``);if(!t||t.length===0)return;let n=new Map;for(let e of t)n.set(e.cause,e);e.entries=e.entries.filter(e=>{if(e.entry.kind!==`message`||e.entry.role!==`assistant`)return!0;let t=Q(e.entry.text,!0).trim();if(t===``)return!0;let r=n.get(j(t));return r?(r.draft.firstSeq=Math.min(r.draft.firstSeq,e.firstSeq),r.draft.lastSeq=Math.max(r.draft.lastSeq,e.lastSeq),N(r,`assistant`,t),!1):!0})}function _t(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!x(e,`human`)))}function vt(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function yt(e,t,n){let{entry:r}=e;if(r.kind!==`message`||r.role!==`assistant`)return r;let i=Q(r.text,t);return n&&e.streaming===!0?{...r,text:$(i),streaming:!0}:{...r,text:i}}function bt(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(e=>yt(e,n,t)),itemSeqs:xt(e.entries)}}function xt(e){let t=new Map;for(let{entry:n,firstSeq:r,lastSeq:i}of e)t.has(n.id)||t.set(n.id,{first:r,last:i});return t}function St(e,t={}){let n=ue();for(let t of e)ot(n,t);let r=n.turns.length-1;for(let[e,i]of n.turns.entries())i.v2Items&&ht(i,t.activeTurn===!0&&e===r),gt(i),_t(i);return vt(n),{turns:n.turns.map((e,n)=>bt(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{x as a,ut as i,St as n,y as o,ct as r,m as s,st as t};
|