@hearsay-tools/squawk 0.19.0-dev.9291 → 0.19.0-dev.9298

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/hosts.d.ts +76 -1
  3. package/dist/contract/index.d.ts +1 -0
  4. package/dist/contract/index.js +1354 -1288
  5. package/dist/contract/project-signal.d.ts +31 -0
  6. package/dist/delegation/routes.d.ts +4 -4
  7. package/dist/delegation/transport.d.ts +10 -10
  8. package/dist/features/hosts/index.js +2 -0
  9. package/dist/features/hosts/index.js.map +1 -1
  10. package/dist/features/hosts/routes.d.ts +45 -1
  11. package/dist/features/hosts/routes.js +109 -1
  12. package/dist/features/hosts/routes.js.map +1 -1
  13. package/dist/features/hosts/runs-index-patch.d.ts +5 -0
  14. package/dist/features/hosts/runs-index-patch.js +36 -0
  15. package/dist/features/hosts/runs-index-patch.js.map +1 -1
  16. package/dist/features/hosts/runs-index.d.ts +9 -1
  17. package/dist/features/hosts/runs-index.js +27 -0
  18. package/dist/features/hosts/runs-index.js.map +1 -1
  19. package/dist/features/reports/routes.d.ts +2 -2
  20. package/dist/runs/run-exits.d.ts +352 -352
  21. package/dist/runs/run-index.d.ts +2 -0
  22. package/dist/runs/run-index.js +9 -1
  23. package/dist/runs/run-index.js.map +1 -1
  24. package/dist/server/activity-routes.d.ts +23 -23
  25. package/dist/server/live-routes.d.ts +6 -6
  26. package/dist/server/live-trace.d.ts +30 -0
  27. package/dist/server/live-trace.js +114 -0
  28. package/dist/server/live-trace.js.map +1 -0
  29. package/dist/server/projects-routes.d.ts +41 -41
  30. package/dist/server/runs-routes.d.ts +1008 -1008
  31. package/dist/server/server.d.ts +126 -126
  32. package/dist/server/start-server.js +2 -1
  33. package/dist/server/start-server.js.map +1 -1
  34. package/dist/server/ws.d.ts +3 -0
  35. package/dist/server/ws.js +22 -3
  36. package/dist/server/ws.js.map +1 -1
  37. package/dist/workflows/continuation-admission.d.ts +72 -72
  38. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  39. package/package.json +4 -4
  40. package/web/dist/assets/accounts-section-BHP8K_nY.js +1 -0
  41. package/web/dist/assets/activity-motion-DEEIuaki.js +1 -0
  42. package/web/dist/assets/{activity-route-CruXBXE5.js → activity-route-vtZmQsDB.js} +1 -1
  43. package/web/dist/assets/agent-accounts-BC78GKYv.js +1 -0
  44. package/web/dist/assets/{agent-config-section-BUxTgHrB.js → agent-config-section-CbnVaIx7.js} +1 -1
  45. package/web/dist/assets/{agent-defaults-section-BXUzcpEv.js → agent-defaults-section-Blxd9IpY.js} +1 -1
  46. package/web/dist/assets/{appearance-DnPsNI40.js → appearance-B_y9StVj.js} +1 -1
  47. package/web/dist/assets/{archive-on-merge-field-DR-KA2nj.js → archive-on-merge-field-DlChylWt.js} +1 -1
  48. package/web/dist/assets/{ask-card-DqWVy7zb.js → ask-card-DzWKRJ1x.js} +3 -3
  49. package/web/dist/assets/attention-C33sN0aA.js +1 -0
  50. package/web/dist/assets/automations-route-DxE9u9p0.js +2 -0
  51. package/web/dist/assets/{commit-list-zMKEapLK.js → commit-list-SxBDO_q5.js} +1 -1
  52. package/web/dist/assets/diff-B6Ye5Xg9.js +3 -0
  53. package/web/dist/assets/{diff-controls-DbkfJxfp.js → diff-controls-BFQOIJ97.js} +1 -1
  54. package/web/dist/assets/{diff-view-Cl7rXVa_.js → diff-view-BkF3xtYW.js} +1 -1
  55. package/web/dist/assets/{discard-changes-dialog-BYLEBMpG.js → discard-changes-dialog-CaS0koto.js} +1 -1
  56. package/web/dist/assets/{file-preview-CBjQS3sX.js → file-preview-ByWn2eDz.js} +1 -1
  57. package/web/dist/assets/{folder-browser-_2PCbZWK.js → folder-browser-CHTNDBIU.js} +1 -1
  58. package/web/dist/assets/{git-toolbar-CAAZ5T8F.js → git-toolbar-COI-N232.js} +1 -1
  59. package/web/dist/assets/github-CAQJIg-J.js +1 -0
  60. package/web/dist/assets/{global-activity-route-BQz9m_XA.js → global-activity-route-99-UqSlC.js} +1 -1
  61. package/web/dist/assets/hosts-BDfuQnus.js +1 -0
  62. package/web/dist/assets/index-BAXboPqe.js +21 -0
  63. package/web/dist/assets/label-Qj4HjGeN.js +1 -0
  64. package/web/dist/assets/{markdown-CcQNTOHx.js → markdown-D7p7x8Pe.js} +1 -1
  65. package/web/dist/assets/{open-in-menu-WJ8dhdTo.js → open-in-menu-D07DgRwh.js} +1 -1
  66. package/web/dist/assets/{option-select-DGRezng8.js → option-select-BvsSDWBz.js} +1 -1
  67. package/web/dist/assets/{preferences-section-DfiqoVZx.js → preferences-section-DkdcKxmS.js} +1 -1
  68. package/web/dist/assets/{preview-DXX3jdRy.js → preview-7NPVVq1D.js} +1 -1
  69. package/web/dist/assets/{preview-pane-connected-Bf6SWOsM.js → preview-pane-connected-B3f0fR6q.js} +2 -2
  70. package/web/dist/assets/{project-location-8EYHMbCE.js → project-location-CvZY7aOx.js} +1 -1
  71. package/web/dist/assets/{project-router-TP6DSj1S.js → project-router-l_pJCK5X.js} +1 -1
  72. package/web/dist/assets/project-scope-context-_6sNMsAf.js +4 -0
  73. package/web/dist/assets/{projects-section-CaKm84OL.js → projects-section-DGzDfKN_.js} +1 -1
  74. package/web/dist/assets/{prompt-templates-section-Bh6YEqh0.js → prompt-templates-section-DbHe-j9Z.js} +1 -1
  75. package/web/dist/assets/queries-CPNrCEon.js +1 -0
  76. package/web/dist/assets/read-state-BXLUf0Xi.js +1 -0
  77. package/web/dist/assets/reference-chip-B32qTHb5.js +1 -0
  78. package/web/dist/assets/{remote-settings-notice-cNffux8C.js → remote-settings-notice-ByPYNQyB.js} +1 -1
  79. package/web/dist/assets/{repo-git-nFi9DHBQ.js → repo-git-4rKalM-L.js} +1 -1
  80. package/web/dist/assets/{report-reader-BbA7ERJe.js → report-reader-IAYhP0KQ.js} +1 -1
  81. package/web/dist/assets/{report-selection-DOq2dcjz.js → report-selection-DCC-F7i6.js} +1 -1
  82. package/web/dist/assets/{reports-iMUK2IiW.js → reports-BP_hajNp.js} +1 -1
  83. package/web/dist/assets/{resources-section-BsPU-yD9.js → resources-section-QNbLbu3j.js} +1 -1
  84. package/web/dist/assets/{review-notes-drafts-BncrXliY.js → review-notes-drafts-CB8u-M0E.js} +1 -1
  85. package/web/dist/assets/{review-panel-CTc1ypIJ.js → review-panel-Bw8yG2xg.js} +1 -1
  86. package/web/dist/assets/{review-strip-D1gmgNIH.js → review-strip-BojRnCkg.js} +1 -1
  87. package/web/dist/assets/{run-detail-refresh-B4t_zvMa.js → run-detail-refresh-CZ7VyCgP.js} +1 -1
  88. package/web/dist/assets/{run-diff-CbyXSgBK.js → run-diff-CMZgQG9B.js} +1 -1
  89. package/web/dist/assets/run-header-D7LZBbaL.js +2 -0
  90. package/web/dist/assets/{select--NKdUD0C.js → select-D9BIA_Kn.js} +1 -1
  91. package/web/dist/assets/{session-context-section-D02yRmGY.js → session-context-section-CxFRidmv.js} +1 -1
  92. package/web/dist/assets/{settings-agent-picker-GPhOc6Lz.js → settings-agent-picker-Cy_ZpuNd.js} +1 -1
  93. package/web/dist/assets/{settings-save-bar-CroXxZIi.js → settings-save-bar-DzbndGGQ.js} +1 -1
  94. package/web/dist/assets/settings-shell-DS8k_xP6.js +1 -0
  95. package/web/dist/assets/{sidebar-section-BOtjR98E.js → sidebar-section-CY978tNF.js} +1 -1
  96. package/web/dist/assets/{skills-C7MuiePR.js → skills-WZ5YRCbF.js} +1 -1
  97. package/web/dist/assets/{status-dot-Bn3O77El.js → status-dot-Dvy-rnDJ.js} +1 -1
  98. package/web/dist/assets/{tab-link-BeONvGY1.js → tab-link-BPkGPOYd.js} +1 -1
  99. package/web/dist/assets/task-changes-Dd2KHRQ6.js +5 -0
  100. package/web/dist/assets/task-commits-De0FVgKP.js +1 -0
  101. package/web/dist/assets/{task-file-scope-BfJ7TDbf.js → task-file-scope-C_cr_ix-.js} +1 -1
  102. package/web/dist/assets/{task-files-CNz4PSKs.js → task-files-resMdu9u.js} +1 -1
  103. package/web/dist/assets/{task-github-item-B0mRxbLm.js → task-github-item-Hz1RbO88.js} +1 -1
  104. package/web/dist/assets/task-groups-Bc_WNTMe.js +1 -0
  105. package/web/dist/assets/task-thread-D7vUf0g7.js +2 -0
  106. package/web/dist/assets/{thread-state-B_uTIWzc.js → thread-state-Bjh3rImx.js} +1 -1
  107. package/web/dist/assets/{unified-diff-JD9Q6oCe.js → unified-diff-weWjKedZ.js} +1 -1
  108. package/web/dist/assets/use-finish-run-BuyJkeEN.js +1 -0
  109. package/web/dist/assets/{use-hand-to-agent-state-zwUimLza.js → use-hand-to-agent-state-CSDPzpM7.js} +1 -1
  110. package/web/dist/assets/use-path-bases-DgEkRWYi.js +1 -0
  111. package/web/dist/assets/use-workspace-config-save-M2ethek2.js +1 -0
  112. package/web/dist/assets/{workflows-BXDmsEl-.js → workflows-DtnnAq4w.js} +1 -1
  113. package/web/dist/assets/{workspace-tools-Ehk2KrtT.js → workspace-tools-CSLTEwLa.js} +1 -1
  114. package/web/dist/assets/{worktrees-section-DWZwtc3-.js → worktrees-section-Crp31i8F.js} +1 -1
  115. package/web/dist/index.html +17 -14
  116. package/web/dist/assets/accounts-section-uuhrLHok.js +0 -1
  117. package/web/dist/assets/activity-motion-CHyZRjxl.js +0 -1
  118. package/web/dist/assets/agent-accounts-CSU96w_T.js +0 -1
  119. package/web/dist/assets/automations-route-BmCWqncy.js +0 -2
  120. package/web/dist/assets/diff-BPw0S-BU.js +0 -3
  121. package/web/dist/assets/github-DehUrgzW.js +0 -1
  122. package/web/dist/assets/hosts-BEeMKHcf.js +0 -1
  123. package/web/dist/assets/index-D0RESQCN.js +0 -21
  124. package/web/dist/assets/label-VKt-7Z5C.js +0 -1
  125. package/web/dist/assets/project-scope-context-BWHk0niI.js +0 -4
  126. package/web/dist/assets/queries-Byfl3YoC.js +0 -1
  127. package/web/dist/assets/reference-chip-rDOAte2y.js +0 -1
  128. package/web/dist/assets/run-header-BREol2Ej.js +0 -2
  129. package/web/dist/assets/settings-shell-CEDsPkJW.js +0 -1
  130. package/web/dist/assets/task-changes-CPDdG-BK.js +0 -5
  131. package/web/dist/assets/task-commits-BFWXi7xF.js +0 -1
  132. package/web/dist/assets/task-thread-DH9xiw7O.js +0 -2
  133. package/web/dist/assets/use-finish-run-D7Ll1bwP.js +0 -1
  134. package/web/dist/assets/use-path-bases-BmFE7O79.js +0 -1
  135. package/web/dist/assets/use-workspace-config-save-71tIi9IP.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{g as n,m as r,n as i}from"./host-context-KsSKxKbI.js";import{$ as a,$t as o,A as s,Ar as c,Bi as l,Br as u,C as d,Cn as f,Ct as ee,D as te,Dr as ne,Dt as re,E as ie,Ei as p,En as m,Et as h,F as g,Fr as _,Ft as ae,G as v,Gi as y,Gr as oe,Gt as b,Hi as se,Hr as x,Ht as ce,In as le,Ir as S,J as ue,Ji as de,Jt as fe,K as pe,Ki as me,Kr as he,L as ge,Lr as C,Lt as _e,Mn as ve,Mt as ye,N as be,Ni as w,Nn as T,Nt as xe,O as Se,On as E,Ot as Ce,Pn as we,Pr as Te,Pt as Ee,Q as De,Qn as Oe,Qt as ke,Rr as Ae,S as je,Sn as Me,St as Ne,Ti as Pe,Tn as Fe,Ui as D,Ur as Ie,Ut as Le,Vr as Re,Wi as ze,Wr as Be,X as Ve,Xi as He,Xt as Ue,Y as We,Yi as Ge,Yt as Ke,Zi as qe,Zt as Je,_a as Ye,_n as Xe,_t as Ze,a as Qe,an as $e,b as et,ba as tt,bi as nt,bn as rt,bt as it,cn as at,ct as ot,ea as O,en as st,er as ct,et as lt,fa as ut,ga as dt,gn as ft,gt as pt,h as mt,hn as ht,ia as gt,jn as _t,jr as vt,k as yt,kn as k,kr as bt,kt as xt,la as St,ln as Ct,m as wt,ma as A,mi as Tt,mn as Et,nn as Dt,on as Ot,or as kt,pn as At,pt as jt,q as Mt,qi as Nt,qt as Pt,r as Ft,ra as It,rn as Lt,sa as Rt,sn as zt,sr as Bt,ta as Vt,tn as Ht,tr as Ut,un as Wt,v as Gt,vn as Kt,vt as qt,wn as Jt,wt as Yt,x as Xt,xn as Zt,xt as Qt,y as $t,yt as en,zr as tn}from"./project-scope-context-BWHk0niI.js";import{A as nn,B as j,F as M,H as N,I as P,N as F,P as I,W as L,Z as rn,a as an,j as R,z}from"./live-protocol-CNUmr-VT.js";import{c as on}from"./dist-CCX8mhHc.js";import{n as sn}from"./host-storage-BHtMSWBL.js";function cn(e,t){return e??t}function ln(e,t){let n=cn(e,t);return n===`1`||n===`true`}function un(e,t,n){return e?.trim()||cn(t,n)||``}var dn=class extends It{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||fn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=gt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),rn.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function fn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var pn=class extends tt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),dt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Rt(t.mutationKey)!==Rt(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??fn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){rn.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function mn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function hn(e,t,n){let r=e.slice(0);return r[t]=n,r}var gn=class extends tt{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,rn.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!dt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(mn(e,n).forEach(e=>{e.destroy()}),mn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=A(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Vt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=hn(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&rn.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},B=e(t(),1);function _n({queries:e,...t},n){let r=O(n),i=qe(),a=He(),o=B.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{ze(e);let t=r.getQueryCache().get(e.queryHash);Nt(e,a,t)}),Ge(a);let[s]=B.useState(()=>new gn(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;B.useSyncExternalStore(B.useCallback(e=>d?s.subscribe(rn.batchCalls(e)):ut,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),B.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>me(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&me(n,e)?y(n,new Vt(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let ee=c.find((e,t)=>{let n=o[t];return n&&de({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(ee?.error)throw ee.error;return l(u())}function V(e,t){let n=O(t),[r]=B.useState(()=>new pn(n,e));B.useEffect(()=>{r.setOptions(e)},[r,e]);let i=B.useSyncExternalStore(B.useCallback(e=>r.subscribe(rn.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=B.useCallback((e,t)=>{r.mutate(e,t).catch(ut)},[r]);if(i.error&&Ye(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function H(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function U(e,t={}){return{...H(t),runId:e}}function vn(){return ln(void 0,void 0)}function W(e){return!vn()&&e}async function yn(e){return ve(await k.api.v1.health.$get({},E(e)),`/health`)}async function bn(e){return T(await k.api.v1.hosts.$get({},E(e)),`/hosts`,Ae)}async function xn(e){return T(await k.api.v1.hosts.projects.$get({},E(e)),`/hosts/projects`,tn)}async function Sn(e){return T(await k.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},E(e)),`/hosts/runs-index`,u)}async function Cn(e,t){return T(await k.api.v1.hosts[`runs-search`].$get({query:{q:e,...t?.limit===void 0?{}:{limit:t.limit}}},E(t)),`/hosts/runs-search`,Re)}async function wn(e){return ve(await k.api.v1.workspace[`ui-state`].$get({},E(e)),`/workspace/ui-state`)}async function Tn(e,t={}){return ve(await k.api.v1.workspace[`ui-state`].$put({json:e},{init:{...on({keepalive:t.keepalive})}}),`/workspace/ui-state`)}j({runs:P(`summary`).optional()});var En=L().min(1),Dn=z().int().positive(),On=j({project:En,seq:Dn,run:he,relationships:L().min(1)}),kn=j({project:En,seq:Dn,id:L().min(1)}),An=j({generation:L().min(1),seq:z().int().nonnegative()}),jn=j({project:En,usage:N(L(),Ie)});j({runs:F(oe),referenceStatuses:Be,perProjectLimit:z(),truncated:F(L()),generation:L().min(1),eventSeq:z().int().nonnegative()});function Mn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=On.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=kn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=jn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=An.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var Nn=[c,bt,vt,ne];function Pn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case c:{let e=_.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case bt:{let e=Te.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case vt:{let e=S.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case ne:{let e=C.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function Fn(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function In(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function Ln(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var Rn=Object.freeze({});function zn(){let e=Rn,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function Bn(e){return nt[Pe(e).bucket]<=nt.waiting}function Vn(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function Hn(e,t){return e?.backend??t?.runner??`claude`}function Un(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function Wn(e){let t=Vn(e.steps),n=Un(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:Hn(n,e),profileId:n?.profileId}}function Gn(e){return e.command===void 0&&e.kind!==`plugin`}function Kn(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=Vn(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function qn(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(Gn);let r=Kn(e);return(r?n.find(e=>e.id===r&&Gn(e)):void 0)??[...n].reverse().find(Gn)}var Jn=new Set([`queued`,`running`,`waiting`]);function Yn(e){return Jn.has(e)}function Xn(e){return w(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Zn(e){return Xn(e)&&e.status!==`queued`}function Qn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&x(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var $n=[`done`,`failed`];function er(e){return e.archived||w(e)||!$n.includes(e.status)?!1:e.finishedAt!==void 0}function tr(e){let t=e.finishedAt;return t===void 0||!er(e)?!1:e.seenAt===void 0||e.seenAt<t}var nr=[`Needs you`,`Finished`,`Working`,`Archived`],rr={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ir=3,ar=e=>w(e)?ir:rr[e.status]??9;function or(e){let t=e=>nt[Pe(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||ar(e)-ar(n))[0]}function sr(e,t){return t===`archived`?`Archived`:p(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function cr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function lr(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function ur(e,t){return t!==void 0&&lr(e).ref===t}var dr=(e,t)=>e<t?-1:+(e>t);function fr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>dr(e.createdAt,t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function pr(e,t,n){if(n!==`archived`){let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n}let r=ar(e)-ar(t);if(r!==0)return r;if(w(e)&&w(t)){let n=dr(e.autoResumeAt,t.autoResumeAt);if(n!==0)return n}return e.status===`queued`&&t.status===`queued`?dr(e.createdAt,t.createdAt):dr(t.createdAt,e.createdAt)}function mr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>pr(e,n,t))}function G(e){return e.delegation?.role===`worker`}function hr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!G(n)?e:n.delegation?.parentRunId??e}function gr(e,t,n=fr(e)){let r=mr(e,t).filter(e=>!G(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(sr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return nr.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function _r(e,t={}){let n=typeof t==`number`?{overall:t}:Oe(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function vr(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function yr(e){let t=0,n=0,r=0;for(let i of e)if(!G(i)){if(i.archived){n+=1;continue}t+=1,p(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function br(e,t,n){return e.filter(e=>!e.archived&&(!n||x(e)===(t===`automations`)))}var xr={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},Sr=Object.keys(xr),Cr=`section`;function wr(e,t,n){let r=`${Cr}=${xr[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function Tr(e){return Sr.find(t=>xr[t]===e)??null}function Er(e,t){let n={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let r of e){if(G(r)||r.archived)continue;let e=+!!p(r);t&&x(r)?(n.automations+=1,n.automationsWaiting+=e):(n.active+=1,n.activeWaiting+=e)}return n}var Dr=[`done`,`failed`,`cancelled`];function Or(e){return Dr.includes(e)}function kr(e){return!w(e)&&Or(e.status)&&!tr(e)}function Ar(e){return e.reduce((e,t)=>G(t)||!tr(t)?e:e+1,0)}function jr(e){return e.status===`failed`?`danger`:`success`}var Mr={needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0};function Nr(e){if(e.archived||G(e))return null;if(p(e))return`needsYou`;if(Pe(e).tone===`running`)return`inMotion`;if(tr(e)){if(e.status===`failed`)return`failedUnread`;if(e.status===`done`)return`finishedUnread`}return null}function Pr(e,t){return e===t?!0:!e||!t?!1:e.needsYou===t.needsYou&&e.failedUnread===t.failedUnread&&e.inMotion===t.inMotion&&e.finishedUnread===t.finishedUnread}function Fr(e){let t={...Mr};for(let n of e){let e=Nr(n);e&&(t[e]+=1)}return t}function Ir(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e?e.push(n):t.set(n.projectId,[n])}return new Map([...t].map(([e,t])=>[e,Fr(t)]))}function Lr(e,t,n={}){if(n.unknown)return`${e} · activity unknown`;let r=Rr(t).map(e=>e.text);return[e,r.length>0?r.join(` · `):`idle`].join(` · `)}function Rr(e){let{needsYou:t,failedUnread:n,inMotion:r,finishedUnread:i}=e??Mr,a=[];return t>0&&a.push({tone:`amber`,text:`${t} needs you`}),n>0&&a.push({tone:`red`,text:`${n} failed`}),r>0&&a.push({tone:`violet`,text:`${r} working`}),i>0&&a.push({tone:`green`,text:`${i} finished`}),a}function zr(e){let t={...Mr};for(let n of e)n&&(t.needsYou+=n.needsYou,t.failedUnread+=n.failedUnread,t.inMotion+=n.inMotion,t.finishedUnread+=n.finishedUnread);return t}function Br(e){let t=e.split(/[-_ .]+/).filter(e=>e!==``);return(t.length>=2?[t[0],t[1]].map(e=>[...e][0]):[...t[0]??``].slice(0,2)).join(``).toLowerCase()}var K=new WeakMap;function Vr(){return{needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0}}function Hr(e){return e.needsYou===0&&e.failedUnread===0&&e.inMotion===0&&e.finishedUnread===0}function Ur(e,t,n,r){let i=e.get(t),a=i?{...i}:Vr();a[n]=Math.max(0,a[n]+r),Hr(a)?e.delete(t):e.set(t,a)}function Wr(e){let t=new Map;for(let n of e){let e=Nr(n);if(!e)continue;let r=t.get(n.projectId);r||(r=Vr(),t.set(n.projectId,r)),r[e]+=1}return t}function Gr(e){let t=new Map;for(let n of e){let e=Nr(n);if(!e)continue;let r=t.get(n.hostId);r||(r=new Map,t.set(n.hostId,r));let i=r.get(n.projectId);i||(i=Vr(),r.set(n.projectId,i)),i[e]+=1}return t}function Kr(e,t){if(e===t)return;let n=K.get(e);n&&K.set(t,n)}function qr(e,t,n){if(e===t)return;let r=K.get(e);if(!r)return;if(n.length===0){K.set(t,r);return}let i=null,a=new Set,o=e=>{if(i||=new Map(r),!a.has(e)){let t=i.get(e),n=t?new Map(t):new Map;return i.set(e,n),a.add(e),n}return i.get(e)};for(let e of n){let t=e.previous?Nr(e.previous):null,n=e.next?Nr(e.next):null;if(t===n)continue;let r=o(e.hostId);t&&Ur(r,e.projectId,t,-1),n&&Ur(r,e.projectId,n,1)}let s=i;if(s)for(let e of a)s.get(e)?.size===0&&s.delete(e);K.set(t,s??r)}function Jr(e,t,n,r){if(e===t)return;let i=K.get(e);if(!i)return;let a=new Map(i),o=Wr(r);o.size===0?a.delete(n):a.set(n,o),K.set(t,a)}function Yr(e){let t=K.get(e.runs);t||(t=Gr(e.runs),K.set(e.runs,t));let n=new Map,r=new Set;for(let i of e.hosts){if(i.state!==`connected`||!i.loaded||i.stale)continue;r.add(i.id);let e=t.get(i.id);e&&e.size>0&&n.set(i.id,e)}return{byHost:n,knownHosts:r}}function Xr(e,t){if(e===t)return!0;if(!e||!t||e.knownHosts.size!==t.knownHosts.size||e.byHost.size!==t.byHost.size)return!1;for(let n of e.knownHosts)if(!t.knownHosts.has(n))return!1;for(let[n,r]of e.byHost){let e=t.byHost.get(n);if(!e)return!1;if(r!==e){if(r.size!==e.size)return!1;for(let[t,n]of r)if(!Pr(n,e.get(t)))return!1}}return!0}function Zr(e){return e.type===`run`?e.run.id:e.id}function Qr(e,t){return{...e,runs:t}}function $r(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var ei=new WeakMap,ti=new WeakMap;function ni(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return ei.set(e,n),ti.set(e,r),{positions:n,liveUsage:r}}var ri=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=ei.get(e),r=ti.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=ni(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=ni(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&ti.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,ei.set(this.runs,this.positions),ti.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},ii=e=>e.projectId,ai=(e,t)=>`${e}\u0000${t}`,oi=e=>ai(e.hostId,e.projectId);function si(e,t,n,r){return e.length===0?!1:(ei.get(e)??ni(e,oi).positions).get(ai(t,n))?.has(r)??!1}function ci(e,t,n){let r=new ri(e.runs,ii),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=_i(i,e.project,e.usage,r);else{let t=pi(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function li(e,t,n){let r=new ri(e.runs,oi),i=e.runs,a=new Set,o=[],s=!1;for(let c of t){if(c.type===`usage`){i=gi(i,ai(c.hostId,c.project),c.usage,r);continue}let{hostId:t,project:l}=c.change,u=e.hosts.find(e=>e.id===t);if(!u||!u.loaded){a.add(t);continue}let d=n?.(t,l);c.change.type===`run`&&d===!1&&(s=!0);let f=fi(i,c.change,{scope:ai(t,l),id:Zr(c.change),inScope:e=>e.hostId===t&&e.projectId===l,truncated:u.truncated.includes(l),perProjectLimit:u.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:l,...e}),onDelta:(e,n)=>o.push({hostId:t,projectId:l,previous:e,next:n})},r);i=f.runs,f.reconcile&&a.add(t)}return i!==e.runs&&(o.length===0?Kr(e.runs,i):qr(e.runs,i,o)),{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:s}}function ui(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function di(e,t,n,r,i,a){return n?(i.onDelta?.(n,void 0),{runs:a.remove(t),reconcile:r}):{runs:e,reconcile:!1}}function fi(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return di(e,i,a,!!(n.truncated&&a?.archived),n,r);let{run:o}=t;if(o.delegation?.role===`worker`)return di(e,i,a,!1,n,r);if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=A(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};n.onDelta?.(a,s);let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&$r(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return hi(e,s,n.inScope,r,n.onDelta);n.onDelta?.(void 0,s);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&$r(c,n.inScope)>n.perProjectLimit}}function pi(e,t,n,r){let{project:i}=t,a=fi(e.runs,t,{scope:i,id:Zr(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>ui(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Qr(e,a.runs),reconcile:a.reconcile}}function mi(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function hi(e,t,n,r,i){let a=mi(e,n),o=a!==void 0&&t.createdAt>a;return t.archived&&!o?{runs:e,reconcile:!1}:(i?.(void 0,t),{runs:r.insert(t),reconcile:t.archived||a===void 0||t.createdAt<a})}function gi(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=A(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function _i(e,t,n,r){let i=gi(e.runs,t,n,r);return i===e.runs?e:Qr(e,i)}function vi(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function yi(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function bi(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0:Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function xi(e){e.stream=void 0}function Si(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Zr(t)]):JSON.stringify([e,t.project,Zr(t)])}function Ci(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=Si(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var wi=1e3;function Ti(e,t=wi){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function Ei(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function Di(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function Oi(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function ki(e,t,n){if(!Di(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=Oi(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=ci(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function Ai(e,t,n){if(!Di(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=Oi(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=li(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function ji(e,t,n){if(e.length===0)return t;let r=ei.get(e)??ni(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:A(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function Mi(e,t){if(!e||e.generation!==t.generation)return t;let n=ji(e.runs,t.runs,ii),r=A(e.referenceStatuses,t.referenceStatuses),i=A(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function Ni(e,t){if(!e||e.generation!==t.generation)return t;let n=ji(e.runs,t.runs,oi),r=A(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function Pi(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].createdAt??``)>=t[i].createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function Fi(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=li(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n),u=e.runs.filter(e=>e.hostId!==n),d=o.index.runs.filter(e=>e.hostId===n),f=Pi(u,d);return Jr(e.runs,f,n,d),{index:{runs:f,hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var Ii=[`workspace`,`runs-index`],q=[`main`,`hosts`,`runs-index`],Li=[`workspace`,`projects`],Ri=[`main`,`hosts`,`projects`],zi=6e4,Bi=100,Vi=new WeakMap,Hi=new WeakMap;function Ui(e){let t=Vi.get(e);return t||(t=ea(e),Vi.set(e,t)),t}function Wi(e){let t=Hi.get(e);return t||(t=ia(e),Hi.set(e,t)),t}function Gi(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Ui(t).merge(e)}function Ki(e){let t=e.getQueryData(Li)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function qi(e){let t=e.getQueryData(Ri)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function Ji(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function Yi(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function Xi(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function Zi(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,Bi),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Qi(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function $i(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function ea(e){let t=yi(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(Ii),c=Qi(()=>$i(e,Ii)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Ki(e),{index:o,reconcile:l}=ci(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=Zi(u),f=t=>{d.markWrite(),e.setQueryData(Ii,t)};return{ready(e,n){bi(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){xi(t)},run(e,i,a=!1){if(r.has(e))return;let o=Yi(e,i);if(!Ci(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),Ei(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=vi(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=ki(t,n,Ki(e));for(let e of r)a.index=vi(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Ji(i,n,t.stream)??Mi(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var ta=[1e3,2e3,4e3,8e3,15e3],na=6e4;function ra(e,t){e.setQueryData(q,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function ia(e,t=e=>Sn({hostId:e}),n=ta,r=na,i=e=>Sn({signal:e})){let a=yi(),o=Fn(),s=new Map,c=new Map,l=new Map,u=0,d,f=[],ee=!1,te,ne=!1,re=!1,ie=!1,p,m,h,g=!1,_=0,ae=0,v=!1,y=new Map,oe=()=>e.getQueryData(q),b=()=>e.getQueryCache().find({queryKey:q,exact:!0}),se=()=>{ie||(ie=!0,e.invalidateQueries({queryKey:Ri,exact:!0}).finally(()=>{ie=!1}))},x=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},ce=()=>{d!==void 0&&(clearTimeout(d),d=void 0),u=0},le=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear(),ce()},S=Qi(()=>b()?(re=!0,$i(e,q)):Promise.resolve()),ue=()=>{if(!ee){if(ee=!0,te?.()){ne=!0;return}S.reconcile({hold:!0})}},de=()=>{if((b()?.getObserversCount()??0)===0)return;let e=n[u]??r;u+=1,d!==void 0&&clearTimeout(d),d=setTimeout(()=>{d=void 0,S.reconcile()},e)},fe=e=>{if((b()?.getObserversCount()??0)===0)return;let t=c.get(e)??0,i=n[t]??r;c.set(e,t+1),x(e),l.set(e,setTimeout(()=>{l.delete(e),_e([e])},i))},pe=t=>{ra(e,t),fe(t)},me=(t,n)=>{let r=oe();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return S.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return pe(t),!1;let o=Fi(r,n,t,a,qi(e));if(o.fullReconcile)return S.reconcile(),!0;let l=o.index.hosts.find(e=>e.id===t);l?(s.set(t,n.eventSeq),l.state===`connected`&&l.stale?fe(t):(x(t),c.delete(t))):(x(t),c.delete(t),s.delete(t));let u=Ni(r,o.index);return u!==r&&be(u),o.reconcileHosts.length>0&&_e(o.reconcileHosts,{hold:!0}),!1},he=(t={})=>{let n=b();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:q,exact:!0,refetchType:`none`}),Promise.resolve();if(!oe())return S.reconcile(t)},ge=()=>{let t=b();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},C=()=>{clearTimeout(p),p=void 0;let e=_;if(h||g)return(h??Promise.resolve()).then(()=>{if(!(_!==e||y.size===0))return C()});if(m)return m;let n=[...y.entries()];if(y.clear(),v=!1,n.length===0)return Promise.resolve();let r=he();if(r)return r;let i=e=>{for(let t=e;t<n.length;t+=1){let[e,r]=n[t];y.has(e)||y.set(e,r)}},a=(async()=>{for(let r=0;r<n.length;r+=1){let[a]=n[r];if(_!==e)break;if(g){i(r);break}try{let n=await t(a);if(_!==e)break;if(me(a,n)){i(r+1);break}}catch{if(_===e){if(g){i(r);break}pe(a)}}}})().finally(()=>{m===a&&(m=void 0,!g&&!h&&_===e&&y.size>0&&(v?C():p??=setTimeout(()=>{C()},400)))});return m=a,a},_e=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=he(t);if(n)return n;for(let t of e)y.set(t,++ae);return t.hold||(v=!0),m||(t.hold&&!v&&!h&&!g?(p??=setTimeout(()=>{C()},400),Promise.resolve()):C())},ve=()=>{ye.cancelPending();let t=f;f=[];let n=oe();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=li(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),qi(e));r!==n&&be(r),a&&se(),i.length>0&&_e(i,{hold:!0})},ye=Zi(ve),be=t=>{ye.markWrite(),e.setQueryData(q,t)},w=e=>{let t=new Set(e.filter(e=>e.state===`connected`&&e.stale).map(e=>e.id));for(let e of[...l.keys()])t.has(e)||(x(e),c.delete(e));for(let e of[...c.keys()])t.has(e)||c.delete(e);for(let e of t)l.has(e)||fe(e)},T=t=>{let n=oe(),r=Ai(a,t,qi(e)),i=Ji(n,t,a.stream)??(s.clear(),w(r.index.hosts),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),Ni(n,r.index)),c=_;return r.refreshProjects&&queueMicrotask(()=>{_===c&&se()}),r.reconcile?queueMicrotask(()=>{_===c&&S.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{_===c&&_e(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;bi(a,e),ee=!1;let n=oe(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||b()?.state.fetchStatus===`fetching`),s=re&&S.isInFlight();re=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||ne||i)&&!s?(ne=!1,S.reconcile({hold:!0})):s&&(ne=!1)},detach(){xi(a),o.reset(),re=!1},run(e){let t=o.frame(e.seq),n=Xi(e);if(!Ci(a,n,t)){ue();return}Ti(a),f.push({type:`change`,change:n,generation:a.stream}),ye.schedule(),t&&S.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ue();return}f.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),ye.schedule()},setUnknownGenerationHandler(e){te=e},fetchFull:e=>{g=!0,clearTimeout(p),p=void 0;let t=_,n=h,r=m,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),_!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);let a=ae,o;try{o=await i(e)}catch(n){throw _===t&&!e?.aborted&&de(),n}if(_!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);ce();for(let[e,t]of[...y.entries()])t<=a&&y.delete(e);return T(o)})(),o;return o=a.then(()=>ge(),()=>void 0).then(()=>{h===o&&(h=void 0,g=!1,_===t&&y.size>0&&C())}),h=o,a},merge:T,reconcile:S.reconcile,reconcileHosts:_e,reconcileFinite(){let t=oe();if(!t)return S.reconcile();let n=e.getQueryData(Ri)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?S.reconcile():_e(r)},flush:ve,stop(){_+=1,g=!1,h=void 0,m=void 0,ye.cancelPending(),S.stop(),clearTimeout(p),p=void 0,le(),v=!1,y.clear(),f=[]}}}var aa=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],J={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],result:(e,t=!1,r,i=n(),a)=>a===void 0?[i,`runs`,`result`,e,t,r??null]:[i,`runs`,`result`,e,t,r??null,a],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},Y={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:Ii,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]},oa=[`workspace`,`runs-index`],sa=e=>[e.cacheScope,`runs`,`list`],X=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:aa(e.hostId,e.projectId,e.runId),Z=e=>typeof e==`function`?e():e;function ca(e){let{seenAt:t,...n}=e;return n}function la(e,t){let n=ca(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function ua(e,t,n){return t?{...e,seenAt:n}:ca(e)}function da(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function fa(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function pa(e){let t=()=>{e.invalidateQueries({queryKey:oa})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Ut(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?ua(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(X(t)),l=e.getQueryData(q)?.runs.find(o);return e.setQueryData(X(t),e=>e&&ua(e,n,a)),s(e=>ua(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(X(t),e=>e&&la(e,c)),l&&s(e=>la(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(X(t),e=>e?o(e):a),s(o)}}}async function o(n,r){let o=Z(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:sa(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let s=e.getQueryData(sa(Z(n))),c=e.getQueryData(X(Z(n))),l=Z(n).runId,u=new Date().toISOString();return e.setQueryData(sa(Z(n)),e=>e?.map(e=>e.id===l?ua(e,r,u):e)),e.setQueryData(X(Z(n)),e=>e&&ua(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(sa(Z(n)),s),c&&e.setQueryData(X(Z(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(sa(Z(n)),e=>e?.map(e=>e.id===l?la(e,t):e)),c&&e.setQueryData(X(Z(n)),e=>e&&la(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(sa(Z(n)),e=>e?.map(o));let s={...Z(n),runId:r?l:a.id};e.setQueryData(X(s),e=>e?o(e):a),t()}}}async function s(t,n){if(t.hostId!==void 0){let r=e.getQueryData(q),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?fa(i,o):[];return e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?da(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:oa});let i=e.getQueryData(oa),a=n();return e.setQueryData(oa,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(oa,i)},settle(){r(`indexed`,t)}}}return{patchRead:o,patchIndex:s,invalidateAfter:r}}function ma(){let e=O();return(0,B.useMemo)(()=>pa(e),[e])}function ha(e,t){if(!an(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),Bt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ga(e,t,n,r){let i=O(),a=JSON.stringify(t),o=(0,B.useMemo)(()=>JSON.parse(a),[a]);(0,B.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=ha({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function _a(e,t=!1){return ve(await Fe.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),_t(e,`/worker-destroy`))}function va(){return D({queryKey:J.openTargets,queryFn:({signal:e})=>Qt({signal:e}),staleTime:5*6e4})}function ya(e=!0,t){return D({queryKey:t?J.runs.list(t):J.runs.list(),queryFn:({signal:e})=>Ee(H(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function ba(e,t){return se({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>pt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function xa(e){let t=e.trim();return D({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>Pt(t,{signal:e}),enabled:t.length>=2,placeholderData:St,staleTime:1e4})}function Sa(e=!0,t=zi,n){let r=Ui(O());return ga(`/api/v1/workspace/runs-index`,Y.runsIndex,W(e?t:!1),Gi),D({queryKey:Y.runsIndex,queryFn:({signal:e})=>ae({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Ca(e){let t=O();return V({mutationFn:({workerId:e,discardWork:t=!1})=>_a(e,t),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function wa(e,t={}){return D({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>ye(e,{signal:t}),enabled:t.enabled??!0})}function Ta(e){return D({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Ne(U(e),{signal:t}),enabled:!!e})}function Ea(e,t,n=!0,r){let i=r?.hostId;return D({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:aa(i,e??`default`,t??``),queryFn:({signal:n})=>Ne(U(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Da(e,t){return D({queryKey:t?[t,`runs`,`diff`,e??``]:J.runs.diff(e??``),queryFn:({signal:n})=>re(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function Oa(e,t=!1){return ga(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),W(t?4e3:!1)),D({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>ee(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function ka(e){return`${e.executionRevision??0}:${e.result?.snapshotId??``}:${e.worktreeReclaimedAt??``}`}function Aa(e,t={}){let n=t.includeDiff===!0,r=n?t.maxChars??2e5:void 0;return D({queryKey:J.runs.result(e??``,n,r,t.projectId,t.version),queryFn:({signal:i})=>xe(e,{signal:i,includeDiff:n,...r===void 0?{}:{maxChars:r},...t.projectId?{projectId:t.projectId}:{}}),enabled:!!e&&(t.enabled??!0),retry:!1,refetchOnWindowFocus:!0,staleTime:0})}function ja(e,t){return D({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Ce(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Ma(e,t){return D({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>it(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Na(e,t){return D({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pa(e,t){return D({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>qt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fa(e){return D({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>en(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ia(e,t=!1){return ga(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),W(t?5e3:!1)),D({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function La(e,t){return D({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>Yt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Ra(e,t=!0){return D({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>xt(U(e),{signal:t}),enabled:!!e&&t})}function za(e,t,n,r){return D({queryKey:r===void 0?e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>xt(U(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function Ba(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Va(e,t){let r=new Map;for(let t of e){let e=Ba(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=_n({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Gt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,B.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function Ha(e){let t=O();return V({mutationFn:t=>_e(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ua(e){let t=O();return V({mutationFn:t=>ce(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Wa(e){let t=ma(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=V({mutationFn:e=>Ke(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,B.useCallback)(e=>({...U(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,B.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:c,mutateAsync:l}=a,u=(0,B.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,B.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ga(e){let t=ma(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return V({mutationFn:e=>Ke(U(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>U(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ka(e){let t=ma();return V({mutationFn:({id:t,pinned:n})=>Le(U(t,e),n),onError:e=>Qe(`Could not update pin. ${m(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??H(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function qa(e,t,r){let i=ma();return V({...r===void 0?{}:{mutationKey:aa(r,t??n(),e)},mutationFn:n=>fe(U(e,{projectId:t,hostId:r}),n),onMutate:()=>H({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof Jt&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ja(e,t,r){let i=ma();return V({...r===void 0?{}:{mutationKey:aa(r,t??n(),e)},mutationFn:(n={})=>ot(U(e,{projectId:t,hostId:r}),n),onMutate:()=>H({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Ya(e){let t=O();return V({mutationFn:({msgId:t,message:n})=>jt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Xa(e){let t=O();return V({mutationFn:t=>b(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Za(e,t=!0,n=!1,r){return D({queryKey:[H({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Ee(H({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Qa(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function $a(e,t=!0,n){return D({...eo(e,n),enabled:t})}var eo=(e,t)=>({queryKey:Y.models(e,t),queryFn:({signal:n})=>we(e,{signal:n},t),staleTime:300*1e3});function to(e,t=!0){let n=_n({queries:e.map(e=>({...eo(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var no=R([`own`,`provider-spanning`]),ro=j({suggested:F(j({id:L(),label:L(),desc:L()})),retired:F(L())}),io=j({id:R([`settings`,`mcp`,`memory`]),label:L(),note:L().optional(),empty:L().optional(),showsUserMcp:P(!0).optional()}),ao=j({label:L(),note:L().optional(),groups:F(io)}),oo=j({runners:F(j({id:l,displayName:L(),modelListName:L(),modelIdScope:no,pickerLabel:L(),pickerDescription:L(),icon:L(),installHint:L(),loginCommand:L(),terminalLogin:I().optional(),browserLogin:I().optional(),managedInstall:P(!0).optional(),accountFolderExample:L().optional(),models:ro,agentConfig:ao}))}),so=[`workspace`,`runners`];async function co(e){return T(await Fe.api.v1.runners.$get({},E(e)),`/runners`,oo)}var lo={queryKey:so,queryFn:({signal:e})=>co({signal:e}),staleTime:1/0};function uo(){return D(lo)}function fo(e){return e?.runners??[]}function po(e){return fo(e).map(e=>e.id)}function mo(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function ho(e){let t=uo();return{runner:t.isSuccess?mo(e,po(t.data))??e:e,ready:!t.isPending}}function go(e,t){return e?.runners.find(e=>e.id===t)}function _o(e,t){return go(e,t)?.displayName??t}function vo(e,t){return go(e,t)?.pickerLabel??t}function yo(e,t){return go(e,t)?.modelListName}function bo(e,t,r=!0,i){let a=As(i,r),o=ys(),{runner:s,ready:c}=ho(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=D({queryKey:J.runnerSkills(s,l,u),queryFn:({signal:e})=>ie(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var xo={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},So={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Co(e){return typeof e==`string`&&Object.hasOwn(xo,e)}function wo(e){return e!==void 0&&Co(e)?xo[e]:void 0}var To=`cez.reference-statuses.v1`,Eo=`cez.reference-conflicts.v1`,Q=new Map(Mo()),Do=1e3,$=new Set(No()),Oo=i()??`__local__`;function ko(){let e=i()??`__local__`;if(Oo!==e){Oo=e,clearTimeout(Po),Po=void 0,Q.clear();for(let[e,t]of Mo())Q.set(e,t);$.clear();for(let e of No())$.add(e)}}function Ao(e,t){if(ko(),Q.get(e)!==t){for(Q.delete(e),Q.set(e,t);Q.size>Do;){let e=Q.keys().next().value;if(e===void 0)break;Q.delete(e)}Fo()}}function jo(e,t){if(ko(),$.has(e)!==t){if(t)for($.add(e);$.size>Do;){let e=$.values().next().value;if(e===void 0)break;$.delete(e)}else $.delete(e);Fo()}}function Mo(){try{let e=globalThis.sessionStorage?.getItem(sn(To));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Co(e[1])):[]}catch{return[]}}function No(){try{let e=globalThis.sessionStorage?.getItem(sn(Eo));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Po;function Fo(){if(Po!==void 0)return;let e=sn(To),t=sn(Eo);Po=setTimeout(()=>{Po=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...Q])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...$]))}catch{}},250)}var Io=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function Lo(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Ro(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function zo(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;Ao(t,o),s!==void 0&&jo(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Bo(e,t,n){ko();let r=Io(t),i=Q.get(r),a=$.has(r)?!0:void 0,o=n.data;if(o?.available){zo(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Lo(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Lo(i,a)});return}e.set(r,{state:`loading`,...Lo(i,a)})}function Vo(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Ro(i))Bo(n,e,t)}),n}function Ho(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Uo(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Wo(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Go(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Ko(e,t){return Bt({kind:`topic`,topic:e},{value:t})}function qo(){let e=O();return D({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await at(!1,{signal:t});return le(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:W(!1),refetchOnWindowFocus:!0})}function Jo(){let e=O();return V({mutationFn:()=>at(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>le(r,e,t)),Qa(e)}})}function Yo(){let e=O();return V({mutationFn:({provider:e,authFailureId:t})=>Xe(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>le(r,e,t,n.authFailureId)),Qa(e,n.provider)}})}function Xo(e={}){return D({queryKey:Y.projects,queryFn:({signal:e})=>zt({signal:e}),...e})}function Zo(e,t=!1){return D({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Ue(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Qo(){let e=O();return V({mutationFn:e=>At(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function $o(){let e=O();return V({mutationFn:e=>ht(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:Y.projects})}})}function es(){let e=O();return V({mutationFn:e=>{let{id:t,...n}=e;return Me(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?ts(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function ts(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Go(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function ns(e){let t=O();return V({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function rs(){return ns(e=>{let{projectId:t,...n}=e;return Ht(t,n)})}function is(){return ns(e=>{let{projectId:t,webhookId:n,...r}=e;return f(t,n,r)})}function as(){return ns(({projectId:e,webhookId:t})=>ft(e,t))}function os(){return V({mutationFn:({projectId:e,webhookId:t})=>rt(e,t),retry:!1})}function ss(e){let t=O();return V({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),Qa(t)])},onError:()=>{t.invalidateQueries({queryKey:J.health}),t.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function cs(){return ss(e=>o(e))}function ls(){return ss(e=>{let{id:t,...n}=e;return Zt(t,n)})}function us(){return ss(e=>Et(e))}function ds(){return ss(e=>Kt(e))}function fs(e,t){return D({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>Dt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function ps(){let e=O();return V({mutationFn:({provider:e,profileId:t})=>ke(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),Qa(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:J.health}),e.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function ms(){let e=O();return V({mutationFn:e=>Dt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),Qa(e,t.status.provider)}})}function hs(){let e=O();return V({mutationFn:e=>Je(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function gs(){let e=O();return V({mutationFn:e=>st(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function _s({enabled:e}){return D({queryKey:Y.githubOwners,queryFn:({signal:e})=>$e({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function vs(){let e=O();(0,B.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(J.health);n&&(ct({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:r()}),t??=Ko(`health`,t=>{e.setQueryData(J.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),kt()}},[e])}function ys(){return D({queryKey:J.health,queryFn:({signal:e})=>Ot({signal:e})})}function bs(e,t){let n=ys().data,r=Xo(t).data?.projects,i=Ft(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?Ho(n?.repo?.remote):void 0}function xs(e=!0){return D({queryKey:Y.uiState,queryFn:({signal:e})=>Wt({signal:e}),enabled:e})}function Ss(){return D({queryKey:Y.config,queryFn:({signal:e})=>Ct({signal:e})})}function Cs(){return D({queryKey:Y.agentProfiles,queryFn:({signal:e})=>Lt({signal:e})})}function ws(){return D({queryKey:J.workflows,queryFn:({signal:e})=>yt({signal:e})})}function Ts(e){return D({queryKey:e?[e,`repo`]:J.repo,queryFn:({signal:t})=>et({signal:t},e)})}function Es(e){return D({queryKey:[e,`repo`],queryFn:({signal:t})=>et({signal:t},e)})}function Ds(){return D({queryKey:J.repoBranches,queryFn:({signal:e})=>Xt({signal:e})})}function Os(){return D({queryKey:J.repoChanges,queryFn:({signal:e})=>je({signal:e}),retry:!1})}function ks(e){return D({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>d(e,{signal:t}),enabled:!!e,retry:!1})}function As(e,t=!0){return D({queryKey:e?[e,`config`]:J.config,queryFn:({signal:t})=>$t({signal:t,...e?{projectId:e}:{}}),enabled:t})}function js(){return D({queryKey:J.worktrees,queryFn:({signal:e})=>s({signal:e})})}function Ms(e){return D({queryKey:[e,`worktrees`],queryFn:({signal:t})=>s({signal:t},e),staleTime:0})}function Ns(e,t=!0,n=!1){return D({queryKey:[H({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>Se({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Oe(e.sidebarLimits)},enabled:t})}function Ps(e=!0,t){return Ns(t??n(),e)}function Fs(){return D({queryKey:J.agentConfig,queryFn:({signal:e})=>wt({signal:e})})}function Is(e){return D({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>mt(e,{signal:t}),enabled:e!==null})}function Ls(){return D({queryKey:J.sessionContext,queryFn:({signal:e})=>te({signal:e})})}function Rs(e,t,n=``){return D({queryKey:J.sessionContextPreview(e,t,n),queryFn:({signal:n})=>be({content:e,role:t},{signal:n}),placeholderData:St,staleTime:0,retry:!1})}function zs(){let e=O();return V({onMutate:()=>({fileKey:J.sessionContext}),mutationFn:e=>ge(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Bs(e){let t=O(),n=J.agentConfig,r=J.agentConfigFile(e);return V({mutationFn:t=>g(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Vs=R([`passing`,`failing`,`pending`]).nullable(),Hs=j({kind:R([`issue`,`pr`]),number:z(),title:L(),author:L(),createdAt:L(),labels:F(L()),body:L().optional(),url:L(),comments:z(),assignees:F(L()).optional(),projectIds:F(L()).optional(),isDraft:I().optional(),additions:z().optional(),deletions:z().optional(),checks:Vs.optional()});M(`available`,[j({available:P(!0),item:Hs.nullable(),labelColors:N(L(),L()).optional()}),j({available:P(!1),reason:L()})]),j({kind:R([`issue`,`pr`]),number:nn().int().positive().safe()});var Us=j({id:L(),title:L(),url:L()});j({available:I(),reason:L().optional(),repo:L().optional(),syncedAt:L().optional(),issues:F(Hs),prs:F(Hs),labelColors:N(L(),L()).optional(),viewerLogin:L().optional(),projects:F(Us).optional(),projectsReason:L().optional(),projectsState:R([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:L().optional(),issuesTotal:z().int().nonnegative().optional(),prsTotal:z().int().nonnegative().optional(),issuesNextCursor:L().nullable().optional(),prsNextCursor:L().nullable().optional(),commentsDeferred:P(!0).optional()});var Ws=L().min(1).max(2e3).optional();j({limit:L().optional(),refresh:L().optional(),issuesCursor:Ws,prsCursor:Ws,issuesDone:P(`1`).optional(),prsDone:P(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),j({kind:R([`issue`,`pr`]),numbers:L().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:P(`1`).optional()}),M(`available`,[j({available:P(!0),counts:N(z(),z().int().nonnegative())}),j({available:P(!1),reason:L()})]),M(`available`,[j({available:P(!0),checks:N(z(),Vs)}),j({available:P(!1),reason:L()})]),j({kind:R([`issue`,`pr`]),q:L().trim().min(1).max(256),limit:nn().int().positive().max(50).optional()}),j({available:I(),projectsReason:L().optional(),reason:L().optional(),items:F(Hs),truncated:I().optional(),labelColors:N(L(),L()).optional()});var Gs=z().nullable();M(`available`,[j({available:P(!0),prs:N(z(),Tt),issues:N(z(),Tt),conflicts:F(z()).optional(),recheckAfterMs:Gs}),j({available:P(!1),reason:L(),recheckAfterMs:Gs})]);var Ks=j({id:z(),author:L(),avatarUrl:L().optional(),createdAt:L(),body:L(),kind:R([`comment`,`review`]),reviewState:R([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:L()}),qs=R([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Js=j({id:L(),kind:qs,actor:L(),avatarUrl:L().optional(),createdAt:L(),url:L().optional(),sha:L().optional(),message:L().optional(),checks:Vs.optional(),label:j({name:L(),color:L().optional()}).optional(),subject:L().optional(),refNumber:z().optional(),refTitle:L().optional(),refIsPr:I().optional()});j({available:I(),reason:L().optional(),comments:F(Ks),truncated:I().optional(),events:F(Js).optional(),detail:j({body:L(),additions:z().int().nonnegative().optional(),deletions:z().int().nonnegative().optional()}).optional()});var Ys=R([`merge`,`squash`,`rebase`]),Xs=j({name:L(),state:R([`passing`,`failing`,`pending`,`unknown`]),required:I().nullable(),url:L().optional()}),Zs=j({number:z(),title:L(),url:L(),state:R([`open`,`closed`,`merged`]),isDraft:I(),headRef:L(),baseRef:L(),headSha:L(),mergeable:R([`mergeable`,`conflicting`,`unknown`]),reviewDecision:R([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:F(Xs),methods:F(Ys),defaultMethod:Ys.nullable(),eligibility:R([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:F(j({code:L(),message:L()})),canMerge:I(),canOverride:I()});M(`available`,[j({available:P(!0),mergeState:Zs}),j({available:P(!1),reason:L()})]),j({merged:P(!0),number:z(),url:L(),method:Ys,mergeCommitSha:L().optional()});var Qs=j({path:L(),previousPath:L().optional(),status:R([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:z(),deletions:z(),patch:L().optional(),patchUnavailableReason:R([`binary`,`too-large`,`not-provided`]).optional(),truncated:I().optional()});M(`available`,[j({available:P(!0),number:z(),headSha:L(),files:F(Qs),additions:z(),deletions:z(),truncated:I(),reason:L().optional()}),j({available:P(!1),reason:L()})]),j({generation:L().uuid()}),M(`state`,[j({generation:L().uuid(),state:P(`ready`),projects:F(Us),membership:N(L(),F(L()))}),j({generation:L().uuid(),state:P(`unavailable`),reason:L()})]);function $s(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function ec(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function tc(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function nc(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){tc(t.issues,a,r),tc(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:ee,...te}=t;return{...te,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var rc=e=>e.map(e=>e.number).join(`,`);function ic(e,t){let n=e[0];if(e.length>1&&n&&(rc(n.issues)!==rc(t.issues)||rc(n.prs)!==rc(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var ac=class extends Error{};function oc(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await v({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new ac(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>$s(e),retry:(e,t)=>!(t instanceof ac)&&!(t instanceof Jt&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function sc(e=50,t=!0){let r=O(),i=J.githubPages(e),a=J.githubPagesHead(e);ga(`/api/v1/p/${n()}/github?limit=${e}`,a,W(t?6e4:!1));let o=se({...oc(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=D({queryKey:a,queryFn:({signal:t})=>v({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,B.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ic(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=_n({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>De(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,B.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,B.useMemo)(()=>nc(o.data?.pages??[]),[o.data])}}function cc(e,t=50,n=!0){let r=se({...oc([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,B.useMemo)(()=>nc(r.data?.pages??[]),[r.data])}}function lc(e,t,n=!0){let r=_n({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>Mt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,B.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function uc(e,t,n,r=!0){return D({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>lt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function dc(e,t=!0){return D({queryKey:J.githubChecks(e),queryFn:({signal:t})=>pe(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function fc(e,t,n=!0){return D({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>lt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var pc=100;function mc(e){return[...e].sort((e,t)=>t-e).slice(0,pc).sort((e,t)=>e-t)}function hc(){let e=Ft(),t=ys();return e.projectId??t.data?.bootProject??void 0}function gc(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))Ao(Io({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))Ao(Io({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var _c=5*6e4;function vc(e){return e?e.recheckAfterMs:_c}function yc(e,t=!0){let n=(0,B.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:mc(e.prs),issues:mc(e.issues)}))},[e.map(Io).sort().join(`|`)]),r=_n({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>vc(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>W(t&&!vn()?vc(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=O(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:vc(r[t]?.data)??!1}]:[]));(0,B.useEffect)(()=>{if(!t||vn())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=J.githubRefStatus(t.projectId,t.prs,t.issues);return ha({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,i]);let s=(0,B.useMemo)(()=>Vo(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,B.useCallback)(e=>{let t=Io(e),n=s.get(t);if(n)return n;let r=Q.get(t);return{state:`idle`,...r?{status:r}:{},...$.has(t)?{conflicting:!0}:{}}},[s])}function bc(e,t,n=!0){return D({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function xc(e,t,n=!0){return D({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>We(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Sc(e){return D({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>Ve(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{os as $,qn as $n,Sa as $t,js as A,G as An,Va as At,ys as B,br as Bn,Ka as Bt,Ds as C,nr as Cn,$a as Ct,Rs as D,_r as Dn,Na as Dt,Ls as E,sr as En,ba as Et,cs as F,ur as Fn,Wa as Ft,ms as G,Xn as Gn,La as Gt,bs as H,ar as Hn,Xa as Ht,gs as I,cr as In,Ga as It,us as J,Qn as Jn,ja as Jt,Jo as K,Yn as Kn,Ia as Kt,rs as L,wr as Ln,Ha as Lt,Cs as M,or as Mn,Ca as Mt,hs as N,Tr as Nn,Ya as Nt,Ps as O,pr as On,Pa as Ot,ps as P,fr as Pn,Ma as Pt,ds as Q,Hn as Qn,ya as Qt,Zo as R,hr as Rn,va as Rt,Ts as S,jr as Sn,un as Sr,to as St,ks as T,Sr as Tn,ka as Tt,Xo as U,vr as Un,Ta as Ut,vs as V,lr as Vn,Ea as Vt,qo as W,er as Wn,Oa as Wt,as as X,Wn as Xn,wa as Xt,$o as Y,tr as Yn,Ra as Yt,Yo as Z,Vn as Zn,Aa as Zt,Es as _,Pr as _n,H as _r,yo as _t,xc as a,aa as an,zn as ar,Ko as at,Bs as b,kr as bn,_n as br,uo as bt,fc as c,q as cn,Mn as cr,Ho as ct,hc as d,si as dn,xn as dr,bo as dt,xa as en,Bn as er,ls as et,yc as f,Yr as fn,wn as fr,mo as ft,As as g,Rr as gn,vn as gr,po as gt,Is as h,Lr as hn,W as hr,go as ht,bc as i,ma as in,In as ir,xs as it,fs as j,yr as jn,Ja as jt,ws as k,gr as kn,Fa as kt,cc as l,Wi as ln,yn as lr,So as lt,Fs as m,Br as mn,Cn as mr,fo as mt,dc as n,za as nn,Nn as nr,is as nt,sc as o,J as on,Fn as or,Uo as ot,ec as p,Xr as pn,Tn as pr,_o as pt,Qo as q,Zn as qn,Da as qt,lc as r,ha as rn,Ln as rr,Ss as rt,Sc as s,Y as sn,Pn as sr,Wo as st,gc as t,qa as tn,Rn as tr,es as tt,uc as u,Ui as un,bn as ur,wo as ut,Ns as v,Ir as vn,U as vr,vo as vt,Os as w,Cr as wn,Za as wt,zs as x,Ar as xn,dn as xr,Qa as xt,Ms as y,zr as yn,V as yr,ho as yt,_s as z,Er as zn,Ua as zt};
@@ -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{An as r,Cn as i,En as a,Hn as o,In as s,Jn as c,On as l,Pn as u,f as d,jn as f,kn as p,lt as m,ut as h}from"./queries-Byfl3YoC.js";import{Hr as g,Ni as _,Ti as v}from"./project-scope-context-BWHk0niI.js";import{n as ee}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as y,s as b}from"./dist-CCX8mhHc.js";import{F as x,I as S,N as C,P as w,U as T,_ as E,ct as D,g as O,h as k,m as A,p as j}from"./design-icons-QbNMZniQ.js";import{n as M,r as te,t as ne}from"./popover-BQolmvDR.js";function re(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=e(t(),1),P=[{value:`all`,label:`All`},{value:`direct`,label:`Direct`},{value:`automations`,label:`Automations`}];function ie(e){return e?P:P.filter(e=>e.value!==`automations`)}function ae(e,t){return e===`automations`&&!t?`all`:e}function oe(e){return e===`direct`||e===`automations`?e:`all`}function se(e,t){return t===`all`||g(e)===(t===`automations`)}function ce(e){return e===`all`?void 0:e===`automations`}function F(e,t){let n={all:0,direct:0,automations:0};for(let i of e)r(i)||i.archived!==(t===`archived`)||(n.all+=1,g(i)?n.automations+=1:n.direct+=1);return n}function le(e,t,n,r,i){let a=f(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=F(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function ue(e){return e.rows.map(e=>e.run)}function de(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>v(e).bucket===`error`)?`danger`:`success`}}function fe(e,t,n){return p(e,t,u(n))}var I=(e,t,n)=>n===void 0?`\u0000${e}\u0000${t}`:`${n}\u0000${e}\u0000${t}`,pe=(e,t)=>t===void 0?`\u0000${e}`:`${t}\u0000${e}`;function me(e){let t=new Map;for(let n of e){if(n.archived||n.status!==`queued`)continue;let e=pe(n.projectId,n.hostId),r=t.get(e);r||(r={projectId:n.projectId,hostId:n.hostId,runs:[]},t.set(e,r)),r.runs.push(n)}let n=new Map;for(let{projectId:e,hostId:r,runs:i}of t.values())for(let[t,a]of u(i))n.set(I(e,t,r),a);return n}function he(e){let t=Array.from({length:20},()=>[]);for(let n of e){let e=o(n.run);t[(n.run.pinned?0:10)+e].push(n)}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];if(r.length===0)continue;let i=e%10;(i===3||i===4)&&r.length>1&&r.sort((e,t)=>l(e.run,t.run,`active`));for(let e of r)n.push(e)}return n}function ge(e,t){let n=t===`archived`,i=[],a,o=!0;for(let t of e)t.run.archived!==n||r(t.run)||(o&&a!==void 0&&t.run.createdAt>a&&(o=!1),a=t.run.createdAt,i.push(t));return n||!o?i.sort((e,n)=>l(e.run,n.run,t)):he(i)}function _e(e,t,n){let r=ge(e,t),o=me(n),s=new Map;for(let e of r){let n=a(e.run,t),r={kind:`run`,run:e,queuePosition:e.run.status===`queued`?o.get(I(e.run.projectId,e.run.id,e.hostId))??null:null},i=s.get(n);i?i.push(r):s.set(n,[r])}return i.filter(e=>s.has(e)).map(e=>({label:e,rows:s.get(e)}))}function L(e){return[e.run]}function ve(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function ye(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ve(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var be=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:ye},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function xe(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function Se(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function Ce(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:Se(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of be)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function R(e,t,n={}){let r=xe(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=Ce(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var we=new Set([`running`,`waiting`]);function z(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Te(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Ee(e,t=new Date){if(!_(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function De(e){return e.steps?re({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Oe(e,t,n=()=>``){let i=e.filter(e=>!r(e));return t.trim()?i.filter(e=>R(e,t,{scope:`shown`,extras:{displayTitle:s(e),automation:n(e),references:()=>B(e)}})):[...i]}function B(e){return K(e).map(e=>e.number)}function V(e,t){return e.filter(e=>c(e,t)).length}function ke(e){return V(e)}function Ae(e){return H(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function H(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function U(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function W(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}var G=new WeakMap;function K(e,t,n=e.projectId){let r=G.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=je(e,t,n);return G.set(e,{repoBase:t,projectId:n,refs:i}),i}function je(e,t,n){let r=H(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>J(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:U(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(J(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Me(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=W(a);o.has(c)||(o.add(c),s.push(a))}return s}function Me(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Ne(e){return K(e)[0]}function q(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ie(t);return n!==void 0&&Ie(e.url)===n}var Pe=new WeakMap;function Fe(e,t,n=e.projectId){let r=Pe.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=K(e,t,n).filter(e=>q(e,t));return Pe.set(e,{repoBase:t,projectId:n,refs:i}),i}function Ie(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Le(e,t){let n=[];for(let r of K(e,t)){if(!q(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Re(e,t,n,r){if(q(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function J(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function ze(e,t){let n=we.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:z(n.rssBytes),kind:`live`}};let r=z(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Be(e,t,n=!1){return n||e.filter(e=>!t(e.label)).some(e=>e.rows.flatMap(L).some(e=>Ne(e)!==void 0))}var Y=n(),Ve=(0,N.createContext)(null);function He({children:e}){let[t,n]=(0,N.useState)(()=>new Map),r=(0,N.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,N.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=d((0,N.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,N.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,Y.jsx)(Ve.Provider,{value:o,children:e})}var X=(0,N.createContext)(null);function Ue({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,N.useContext)(Ve),a=(0,N.useContext)(X),o=(0,N.useId)();(0,N.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,(0,N.useMemo)(()=>n.map(e=>`${e.hostId??``}:${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`),[n])]);let s=d(i?We:n),c=i?.lookup??s,l=t??(a&&a.projectId===e?a.repoBase:void 0),u=(0,N.useMemo)(()=>({lookup:c,projectId:e,repoBase:l}),[c,e,l]);return(0,Y.jsx)(X.Provider,{value:u,children:r})}var We=[];function Z(e,t,n,r){let i=(0,N.useContext)(X),a=n??i?.projectId;return!i||!a||t===void 0?qe:i.lookup({...r===void 0?{}:{hostId:r},projectId:a,kind:e,number:t})}function Ge(e,t,n){let r=(0,N.useContext)(X),i=t??r?.projectId;return!r||!i?[]:e.filter(e=>r.lookup({...n===void 0?{}:{hostId:n},projectId:i,kind:`PR`,number:e}).conflicting===!0)}function Ke(){let e=(0,N.useContext)(X);return{projectId:e?.projectId,repoBase:e?.repoBase}}var qe=Object.freeze({state:`idle`}),Je={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},Ye={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},Xe={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},Ze={draft:x,"review-required":S,"changes-requested":T,"checks-pending":null,"checks-failing":E,ready:j,merged:C,closed:w,open:A,completed:j,"not-planned":O};function Q(e){return e===`PR`?`pr-chip`:`issue-chip`}function $(e){return e?{"data-conflicting":`true`}:{}}function Qe(e,t,n,r){return!n||r!==void 0&&q({kind:e,number:t??0,url:n},r)}function $e(e,t,n){return e===`PR`&&(t??n)===!0}function et({plain:e,inert:t,conflicting:n,className:r,tone:i}){return e?y(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):y(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,Je[i],r)}function tt(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function nt(e){return e===`PR`?`pull request`:`issue`}function rt(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function it(e,t){return e&&t?Ye[t.tone]:void 0}function at(e,t){return!e&&(!t||!b(t))}function ot({conflicting:e,presentation:t,status:n,plain:r,compact:i,inert:a,kind:o,label:s,glyphClass:c}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(D,{className:y(`size-2.5 shrink-0`,c),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:t?n:void 0,className:r?y(`size-2.5`,c):void 0}),r&&i?o===`PR`?(0,Y.jsx)(S,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(A,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,Y.jsx)(`span`,{className:a?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:s}):s]})}function st({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,Y.jsx)(`span`,{"data-slot":Q(e),"data-status":t,"data-inert":`true`,...$(n),className:r,children:i})}function ct({kind:e,number:t,tooltip:n,url:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,Y.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&b(r)?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function lt({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:i,projectId:a,hostId:o,repoBase:s,to:c,fullPage:l=!1,className:u,compact:d=!1,plain:f=!1,inert:p=!1}){let{kind:g,number:_,url:v}=e,ee=Ke(),b=Z(g,Qe(g,_,v,s??ee.repoBase)?_:void 0,a,o),x=n??b.status,S=h(x),C=$e(g,r,b.conflicting),w=C?m:S,T=w?.tone??`accent`,E=et({plain:f,inert:p,conflicting:C,className:u,tone:T}),D=gt(b,w,C?S:void 0),O=tt(g,_,f,d),k=nt(g),A=rt(k,_,t,w),j=(0,Y.jsx)(ot,{conflicting:C,presentation:w,status:x,plain:f,compact:d,inert:p,kind:g,label:O,glyphClass:it(f,w)});if(p)return(0,Y.jsx)(st,{kind:g,status:x,conflicting:C,chipClass:E,body:j});let M=at(c,v)?(0,Y.jsx)(`span`,{"data-slot":Q(g),"data-status":x,...$(C),"aria-label":w?`${k} ${O} — ${w.label}`:void 0,className:E,children:j}):(0,Y.jsx)(ut,{to:c,fullPage:l,url:v,"data-slot":Q(g),"data-status":x,...$(C),title:D?void 0:v,"aria-label":A,className:f?E:y(E,Xe[T]),children:j});return D?(0,Y.jsx)(ht,{chip:M,action:C?i:void 0,state:b.state,children:(0,Y.jsx)(ct,{kind:g,number:_,tooltip:D,url:v})}):M}function ut({to:e,fullPage:t,url:n,children:r,...i}){return e?t?(0,Y.jsx)(`a`,{href:e,...i,children:r}):(0,Y.jsx)(ee,{to:e,...i,children:r}):(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var dt=(0,N.createContext)(()=>{});function ft(){return(0,N.useContext)(dt)}var pt=150,mt=120;function ht({chip:e,action:t,state:n,children:r}){let[i,a]=(0,N.useState)(!1),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,N.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,N.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,Y.jsxs)(ne,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,Y.jsx)(M,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,pt)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,Y.jsxs)(te,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},children:[(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,Y.jsx)(dt.Provider,{value:u,children:t}):null]})]})}function gt(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${_t(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function _t(e){return e.charAt(0).toLowerCase()+e.slice(1)}function vt({kind:e,number:t,className:n}){let r=Z(e,t),i=h(r.status),a=e===`PR`&&r.conflicting===!0,o=a?m:i;if(!o)return null;let s=y(`size-2.5`,Ye[o.tone]);return(0,Y.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...a?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:y(`inline-flex items-center`,n),children:a?(0,Y.jsx)(D,{className:y(`shrink-0`,s),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:r.status,className:s})})}function yt({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,Y.jsx)(k,{"data-slot":`status-dot`,"data-tone":`pending`,className:y(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=Ze[e];return n?(0,Y.jsx)(n,{className:y(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{le as A,L as B,Le as C,ze as D,K as E,de as F,se as I,ce as L,_e as M,ue as N,De as O,fe as P,F as R,Re as S,Ne as T,ie as V,W as _,He as a,V as b,Z as c,Te as d,z as f,Be as g,J as h,Ue as i,ae as j,R as k,Oe as l,Fe as m,vt as n,Ge as o,q as p,ft as r,Ke as s,lt as t,ke as u,Ee as v,Ae as w,U as x,B as y,oe as z};
@@ -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{B as r,Bt as i,H as a,In as o,It as s,Lt as c,Pn as l,Qt as u,Rt as d,U as f,Ut as p,W as m,Xn as h,Yt as g,_r as ee,bt as _,d as v,in as te,on as y,vr as b,yr as x,zt as S}from"./queries-Byfl3YoC.js";import{Bt as C,Fi as ne,Ti as re,Vt as ie,a as w,ai as ae,ea as oe,ft as T,ri as E,rt as se,wn as D,xr as ce}from"./project-scope-context-BWHk0niI.js";import{C as le,E as O,S as ue,_ as de,h as fe,i as pe,n as me,p as he,t as k,w as ge,x as _e}from"./reference-chip-rDOAte2y.js";import{o as A,s as j}from"./dist-CCX8mhHc.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 M}from"./design-icons-QbNMZniQ.js";import{t as N}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-WJ8dhdTo.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 P}from"./button-BV_AiLj2.js";import{a as F,i as I,l as L,n as R,p as z,r as B,t as V}from"./dropdown-menu-NJZfnQCU.js";import{n as Le,r as Re,t as ze}from"./popover-BQolmvDR.js";import{a as Be,i as Ve,o as He,r as Ue,s as We,t as Ge}from"./dialog-DKr-j9S6.js";import{c as Ke,s as qe,t as H}from"./project-router-TP6DSj1S.js";import{t as U}from"./status-dot-Bn3O77El.js";import{t as Je}from"./format-BU7D3IfE.js";import{a as Ye}from"./agent-accounts-CSU96w_T.js";import{$t as Xe,Dn as W,Er as Ze,Fn as Qe,G as $e,Jn as et,K as G,W as tt,Wn as nt,a as rt,an as it,bn as K,dn as at,en as ot,er as st,h as ct,hn as lt,i as ut,in as dt,ir as q,ln as ft,m as pt,mr as mt,nn as ht,nr as gt,on as _t,pr as vt,rn as yt,tn as bt,tr as xt,vr as St,yn as Ct}from"./index-D0RESQCN.js";import{t as wt}from"./textarea-BGp28xFr.js";import{t as Tt}from"./markdown-CcQNTOHx.js";import{t as Et}from"./task-file-scope-BfJ7TDbf.js";import{t as J}from"./tab-link-BeONvGY1.js";var Dt=N(`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`}]]),Ot=N(`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`}]]),kt=N(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),At=N(`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 jt(e){let t=te();return x({mutationFn:t=>se(b(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>ee()),onError:e=>w(e.message,{tone:`danger`})})}var Mt={archive:{full:`Archive task`,compact:`Archive`},unarchive:{full:`Unarchive`,compact:`Unarchive`}};function Nt(e){return Mt[e.archived?`unarchive`:`archive`].full}function Pt(e){return Mt[e.archived?`unarchive`:`archive`].compact}function Ft({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(Xe,{open:t,onOpenChange:n,children:(0,X.jsxs)(ht,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(it,{children:[(0,X.jsx)(_t,{children:`Archive task?`}),(0,X.jsxs)(yt,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:o(e),children:o(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(dt,{children:[(0,X.jsx)(bt,{children:`Cancel`}),(0,X.jsx)(ot,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function It({run:e,className:t,compact:n=!1}){let[r,i]=(0,Y.useState)(!1),a=jt(e.id),o=Nt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(P,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":o,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:a.isPending,className:A(`gap-[7px] px-3`,t),onClick:()=>e.archived?a.mutate(!1):i(!0),children:[e.archived?(0,X.jsx)(Ze,{"aria-hidden":`true`}):(0,X.jsx)(Oe,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:n?Pt(e):o})]}),(0,X.jsx)(Ft,{run:e,open:r,onOpenChange:i,onConfirm:()=>{a.mutate(!0),i(!1)}})]})}function Lt({phone:e}){return e?(0,X.jsx)(Ee,{"aria-hidden":`true`}):null}function Rt({run:e,action:t,prUrl:n,patch:r,phone:i}){let a=t.phase===`blocked`;return{key:`completion`,heading:a?`Completion blocked`:`Completion pending`,reason:t.message||(a?`Completion needs attention.`:`Checking completion actions.`),pending:!a,actions:(0,X.jsxs)(X.Fragment,{children:[n&&j(n)?(0,X.jsx)(P,{variant:`outline`,asChild:!0,children:(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:[`Open PR`,(0,X.jsx)(Lt,{phone:i})]})}):null,e.autoMergePr?(0,X.jsx)(P,{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 zt({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)(P,{variant:`outline`,asChild:!0,children:(0,X.jsx)(H,{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&&j(t.pullRequestUrl)?(0,X.jsx)(P,{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)(Lt,{phone:r})]})}):null,n.archive?(0,X.jsx)(It,{run:e,compact:r}):null]})}}function Bt({heading:e,reason:t,className:n,hideHeading:r}){return(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:A(`text-sm [overflow-wrap:anywhere]`,n),children:[r?(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 Vt({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)(Bt,{heading:e.heading,reason:e.reason}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions})]},e.key))})}function Ht({blocks:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useId)(),[i]=e;if(!i)return null;let a=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":r,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:[i.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:i.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:[`· `,i.reason]}),a>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-muted-foreground`,children:[`+`,a]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[`and `,a,` more`]})]}):null,(0,X.jsx)(ke,{"aria-hidden":`true`,className:A(`size-4 shrink-0 text-muted-foreground`,t&&`rotate-180`)})]}),(0,X.jsx)(`div`,{id:r,className:A(t&&`grid gap-2 px-4 pb-3`),children:e.map((e,n)=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Bt,{heading:e.heading,reason:e.reason,className:A(!t&&`sr-only`),hideHeading:n===0}),t?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions}):null]},e.key))})]})}function Ut({run:e}){let t=S(e.id),n=xt(),r=K(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?Rt({run:e,action:o,prUrl:s,patch:t,phone:c}):void 0,a?zt({run:e,blocker:a,flags:r,phone:c}):void 0].filter(e=>e!==void 0);return n?(0,X.jsx)(Vt,{blocks:l}):(0,X.jsx)(Ht,{blocks:l})}var Wt=[`running`,`queued`,`waiting`];function Gt(e,{queuePosition:t,now:n=new Date}){let r=re(e),i=Qe(e,r).label,a=t===void 0?i:`${i} #${t}`,o=Wt.includes(e.status)?qt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Kt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function qt(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:Je(n,t)}}async function Z(e,t){try{await navigator.clipboard.writeText(e),w(t)}catch{w(`Run manually: ${e}`)}}function Jt(e){let t=a(),n=v(),r=(0,Y.useMemo)(()=>O(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>he(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Yt(e){return x({mutationFn:()=>ie(e.id),onError:e=>{if(e instanceof D&&e.command){Z(e.command,`No terminal found — command copied to clipboard.`);return}w(e.message,{tone:`danger`})}})}function Q(e,t){let n=d(),r=m(),i=_(),a=x({mutationFn:t=>C(e.id,t),onError:e=>w(e.message,{tone:`danger`})}),o=Ye(),s=h(e),c=o.runnersOn(e=>t&&s.sessionId!==void 0&&e===s.backend?s.profileId??`default`:o.repoAccount?.[e]).runners,l=e=>!r.isSuccess||!i.isSuccess||c.includes(e??`claude`);return{canResumeHere:t&&l(lt(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=je(e.id);return t===void 0||i.isSuccess&&l(t)}).map(t=>({target:t,...at(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function Xt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=_().data,s=Ct(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)(P,{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)(P,{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)(P,{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)(M,{}),`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)(P,{variant:`outline`,onClick:()=>void Z(s,`Command copied to clipboard.`),children:[(0,X.jsx)(M,{}),`Copy resume command`]})]}):null]})}function Zt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Q(e,t),o=Ct(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)(I,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(Ie,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Z(s,`Worktree path copied`),children:[(0,X.jsx)(M,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,X.jsxs)(P,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,onClick:()=>void Z(o,`Command copied to clipboard.`),children:[(0,X.jsx)(M,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function Qt({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)(I,{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)(P,{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)(Xt,{run:e,canResume:t,onResume:n})})]})}function $t({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)(M,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function en({run:e}){let t=a(),n=v(),r=r=>n===void 0?void 0:ue(n,e.id,r,t),i=(0,Y.useMemo)(()=>O(e,t),[e,t]),s=[],c=[],l=i.filter(e=>e.kind===`PR`);for(let t of l)s.push((0,X.jsx)(k,{reference:t,to:r(t),taskTitle:o(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(ft,{run:e,prNumber:t.number})},de(t)));let u=ge(e);u&&j(u)&&!l.some(e=>e.url===u)&&s.push((0,X.jsx)(k,{reference:{kind:`PR`,url:u},taskTitle:o(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let d=i.filter(e=>e.kind===`Issue`);for(let t of d)c.push((0,X.jsx)(k,{reference:t,to:r(t),taskTitle:o(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},de(t)));let f=_e(e,t);if(f&&j(f)&&!d.some(e=>e.url===f)){let t=fe(f);c.push((0,X.jsx)(k,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:f},to:t?r({kind:`Issue`,number:Number(t),url:f}):void 0,taskTitle:o(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return s.length===0&&c.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,s],[`Issue`,`Issues`,c]].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 tn(){let e=qe(),t=f();return tt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var $=e=>e.map(e=>`${e.name}: ${$e(e.url)}`).join(`
2
- `);function nn(e){let t=et(),n=tn(),r=n.length>0,i=c(e.id),[a,o]=(0,Y.useState)(null),s=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)(sn,{mode:a,targets:n,pending:i.isPending,onOpenChange:e=>!e&&o(null),onSubmit:e=>i.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{o(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||s),notifying:s,reachable:r,targets:n,pending:i.isPending,open:o,stop:l,dialog:u}}function rn({run:e}){let t=nn(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)(V,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(P,{variant:`outline`,"data-slot":`notifying-chip`,className:`gap-1.5`,"aria-label":r?`Notifying ${G(i)} — webhook actions`:`Notifying — webhook actions`,title:r?$(i):void 0,children:[(0,X.jsx)(U,{tone:`success`}),(0,X.jsx)(`span`,{children:`Notifying`}),(0,X.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,X.jsxs)(B,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[r?(0,X.jsx)(F,{"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)(I,{className:`min-h-11`,onSelect:()=>t.open(`note`),children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,X.jsxs)(I,{variant:`destructive`,className:`min-h-11`,disabled:t.pending,onSelect:t.stop,children:[(0,X.jsx)(Dt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,X.jsxs)(P,{variant:`outline`,"data-action":`handoff`,className:`max-md:px-0`,"aria-label":`Hand off to webhook`,onClick:()=>t.open(`handoff`),children:[(0,X.jsx)(vt,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),t.dialog]})}function an({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)(L,{}),(0,X.jsx)(F,{"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 · ${G(r)}`:`Webhook`}),t?(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsx)(I,{"data-action":`handoff-note`,className:`min-h-11`,onSelect:()=>e.open(`note`),children:`Send a note…`}):null,(0,X.jsx)(I,{"data-action":`handoff-stop`,variant:`destructive`,className:`min-h-11`,disabled:e.pending,onSelect:e.stop,children:`Stop notifying`})]}):(0,X.jsx)(I,{"data-action":`handoff`,className:`min-h-11`,onSelect:()=>e.open(`handoff`),children:`Hand off to webhook…`})]})}function on({run:e}){let t=et(),n=tn();return e.notify!==!0||t===`absent`?null:(0,X.jsx)(q,{"data-slot":`notifying-status`,role:`img`,"aria-label":n.length>0?`Notifying ${G(n)}`:`Notifying`,title:n.length>0?$(n):void 0,className:`shrink-0 px-2 py-px leading-4`,children:(0,X.jsx)(vt,{"aria-hidden":`true`,className:`size-3 text-success`})})}function sn({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=G(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)(wt,{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)(P,{type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),(0,X.jsxs)(P,{type:`submit`,variant:`contrast`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,X.jsx)(vt,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function cn({id:e}){return(0,X.jsxs)(H,{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 ln({id:e}){let t=p(e),n=t.data?o(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)(H,{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)(P,{variant:`outline`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var un=3,dn=(e,t)=>e.kind===t.kind&&e.number===t.number;function fn(e,t,n=un){let r=t?e.findIndex(e=>dn(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 pn=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function mn({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)(me,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function hn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function gn({servers:e,icon:t=!1}){let n=pt();if(n===null)return null;let r=n.agentLive===!0,i=e[0],a=e.length+ +!!r,o=a===1?i?{port:i.port}:{agent:!0}:{};return t?(0,X.jsxs)(P,{variant:`ghost`,size:`icon`,"data-slot":`preview-toggle`,"data-entries":a,"aria-pressed":n.open,"aria-label":hn(e,r),className:A(`relative`,a>0?`text-foreground`:`text-soft-foreground`),onClick:()=>n.openPane(o),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),n.live?(0,X.jsx)(U,{tone:`success`,"aria-hidden":`true`,"data-slot":`preview-live-dot`,className:`absolute top-2 right-2`}):null]}):(0,X.jsxs)(P,{variant:`outline`,"data-slot":`preview-toggle`,"aria-pressed":n.open,onClick:()=>n.openPane(o),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),hn(e,r),n.live?(0,X.jsx)(U,{tone:`success`,"aria-label":`Preview is live`}):null]})}function _n({tab:e}){let t=ct();return!t?.available||e!==`session`&&e!==`changes`?null:(0,X.jsxs)(P,{variant:`outline`,"data-slot":`split-view-toggle`,className:A(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)(kt,{"aria-hidden":`true`}),`Split view`]})}function vn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function yn({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)(cn,{id:n}):(0,X.jsx)(ln,{id:n})}function bn({isDesktop:e,desktopActivitySlot:t,attention:n,statusLine:r,hostOffline:i}){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)(q,{dot:n.tone,shape:n.shape,pulse:n.pulse&&!i,children:Kt(r)})})}function xn(e,t,n){return e.worktreePath&&t?(0,X.jsx)(gn,{servers:e.previewServers??[],icon:n}):null}function Sn(e,t,n){return n&&!e.archiveBlocker&&t.archive?(0,X.jsx)(It,{run:e}):null}function Cn({offline:e,className:t}){return e?(0,X.jsx)(q,{"data-slot":`host-not-live-pill`,dot:`neutral`,shape:`ring`,className:t,children:`Not live`}):null}function wn({archived:e,className:t}){return e?(0,X.jsx)(q,{"data-slot":`run-archived-pill`,dot:W.tone,shape:W.shape,className:t,children:W.label}):null}function Tn({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 En({run:e,statusLine:t,activityTrigger:n,hostOffline:r}){let{attention:i}=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)(q,{"data-slot":`mobile-run-status`,dot:i.tone,shape:i.shape,pulse:i.pulse&&!r,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)(Cn,{offline:r,className:`shrink-0 px-2 py-px text-xs leading-4`}),(0,X.jsx)(wn,{archived:e.archived,className:`shrink-0 px-2 py-px text-xs leading-4`}),(0,X.jsx)(on,{run:e})]})})}function Dn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=s.current;if(!e||o){l(!1);return}let t=()=>l(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)}},[o,r,i,e.diffStat?.files]);let u=n?`${n.kind}#${n.number}`:null;return(0,Y.useEffect)(()=>{!u||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[u,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,X.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,"data-overflow-end":c||void 0,className:A(`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]`,a?`mt-0`:`mt-3`),children:[(0,X.jsx)(J,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,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:a,children:`Commits`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,X.jsx)(J,{to:pn(e.id,t),active:n!==null&&dn(t,n),replace:a,children:(0,X.jsx)(mn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,X.jsxs)(V,{children:[(0,X.jsxs)(z,{"data-slot":`run-tabs-more`,"aria-label":`${i.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:[`+`,i.length]}),(0,X.jsx)(B,{align:`end`,children:i.map(t=>(0,X.jsx)(I,{asChild:!0,children:(0,X.jsx)(H,{to:pn(e.id,t),replace:a,children:(0,X.jsx)(mn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function On({run:e,tab:t=`session`,onMarkedUnread:n,desktopActivitySlot:i,mobileActivitySlot:a}){let o=re(e),s=K(e),[c,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=kn(e,n),h=An(e),g=(0,Y.useRef)(null),ee=u(),_=r(),v=Gt(e,{queuePosition:e.status===`queued`?l(ee.data??[]).get(e.id):void 0}),te=gt(),y=xt(),b=te!==null&&!y?te:null,x=b!==null,{referenceProjectId:S,repoBase:C,requests:ne}=Jt(e),ie=(0,Y.useMemo)(()=>le(e,C),[e,C]),w=typeof t==`object`?t:null,{inline:ae,overflow:oe}=fn(ie,w),T=nt(_.data),E=ce(),se=xn(e,T,!1),D=(0,X.jsx)(Nn,{run:e,actions:m,triggerRef:g,onRename:x?h.editor.begin:void 0,onOpenChooser:()=>p(!0),onToggleNotes:()=>d(e=>!e)}),O=Sn(e,s,y);return(0,X.jsx)(pe,{projectId:S,repoBase:C,requests:ne,children:(0,X.jsxs)(`header`,{"data-slot":`run-header`,"data-sticky":t===`session`||void 0,className:A(`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)(Tn,{run:e}),(0,X.jsx)(Ut,{run:e}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(yn,{run:e}),b?(0,X.jsxs)(st,{slot:b,children:[(0,X.jsx)(Mn,{run:e,title:h,returnFocus:g,status:(0,X.jsx)(En,{run:e,statusLine:v,activityTrigger:a,hostOffline:E})}),xn(e,T,!0),(0,X.jsx)(yn,{run:e,compact:!0}),D]}):(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:vn(e.delegation)}),(0,X.jsx)(jn,{run:e}),(0,X.jsx)(bn,{isDesktop:y,desktopActivitySlot:i,attention:o,statusLine:v,hostOffline:E}),(0,X.jsx)(Cn,{offline:E,className:`max-md:hidden`}),(0,X.jsx)(wn,{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:[O,(0,X.jsx)(_n,{tab:t}),se,(0,X.jsx)(rn,{run:e}),D]})]}),(0,X.jsx)(Dn,{run:e,tab:t,activeItem:w,inlineItemTabs:ae,overflowItemTabs:oe,phoneBar:x,isDesktop:y}),c?(0,X.jsx)(In,{runId:e.id,onClose:()=>d(!1)}):null,f?(0,X.jsx)(Qt,{run:e,canResume:K(e).terminal,onResume:()=>m.terminal.mutate(),onClose:()=>p(!1)}):null]}),(0,X.jsx)(Fn,{run:e,actions:m})]})})}function kn(e,t){let n=oe(),r=Ke(),[a,o]=(0,Y.useState)(null),c=()=>n.invalidateQueries({queryKey:y.runs.all}),l=e=>w(e.message,{tone:`danger`}),u=i(),d={isPending:u.isPending,mutate:()=>u.mutate({id:e.id,pinned:!e.pinned})},f=s();return{pin:d,markUnread:{isPending:f.isPending,mutate:()=>{t?.(),f.mutate(e.id,{onError:l})}},delete:x({mutationFn:()=>T(e.id),onSuccess:()=>{c(),r(`/`)},onError:l}),terminal:Yt(e),confirming:a,setConfirming:o}}function An(e){let t=S(e.id),n=o(e);return{title:n,editor:rt(n,e=>t.mutate({title:e},{onError:e=>w(e.message,{tone:`danger`})}))}}function jn({run:e}){let{title:t,editor:n}=An(e);return n.editing?(0,X.jsx)(ut,{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)(mt,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Mn({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)(ut,{editor:n,className:`text-[16px] font-semibold`})})]})}function Nn({run:e,actions:t,triggerRef:n,onRename:r,onToggleNotes:i,onOpenChooser:a}){let o=K(e),s=Ct(e),c=xt(),l=jt(e.id),[u,d]=(0,Y.useState)(!1),f=S(e.id),p=(0,Y.useId)(),m=nn(e),h=(0,Y.useRef)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ft,{run:e,open:u,onOpenChange:d,onConfirm:()=>{l.mutate(!0),d(!1)}}),c?null:m.dialog,(0,X.jsxs)(V,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsx)(P,{ref:n,variant:`ghost`,size:`icon`,"aria-label":`Run actions`,children:(0,X.jsx)(ye,{"aria-hidden":`true`})})}),(0,X.jsxs)(B,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,onCloseAutoFocus:e=>{h.current&&(h.current=!1,e.preventDefault(),r?.())},children:[(0,X.jsx)(F,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),r?(0,X.jsxs)(I,{"data-action":`rename-task`,className:`min-h-11`,onSelect:()=>{h.current=!0},children:[(0,X.jsx)(mt,{"aria-hidden":`true`}),` Rename`]}):null,!c&&o.archive&&!e.archiveBlocker?(0,X.jsx)(I,{disabled:l.isPending,onSelect:()=>e.archived?l.mutate(!1):d(!0),children:Nt(e)}):null,(0,X.jsxs)(I,{onSelect:i,children:[(0,X.jsx)(St,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,X.jsx)(Qt,{run:e,canResume:o.terminal,onResume:()=>t.terminal.mutate(),onOpen:a}),s?(0,X.jsxs)(I,{onSelect:()=>void Z(s,`Command copied to clipboard.`),children:[(0,X.jsx)(M,{"aria-hidden":`true`}),` Copy resume command`]}):null,o.markUnread?(0,X.jsxs)(I,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,X.jsx)(Ot,{"aria-hidden":`true`}),` Mark unread`]}):null,o.pin?(0,X.jsxs)(R,{"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)(At,{"aria-hidden":`true`}):(0,X.jsx)(be,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,c?null:(0,X.jsx)(an,{handoff:m}),(0,X.jsx)(L,{}),(0,X.jsx)(F,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,X.jsx)(R,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:f.isPending,onCheckedChange:e=>f.mutate({archiveWhenDone:e},{onError:e=>w(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,X.jsx)(R,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:f.isPending,"aria-describedby":p,onCheckedChange:e=>f.mutate({autoMergePr:e},{onError:e=>w(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,X.jsx)(`p`,{id:p,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)(Pn,{run:e,patch:f}),o.deleteRun?(0,X.jsx)(L,{}):null,o.deleteRun?(0,X.jsxs)(I,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,X.jsx)(De,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})]})}function Pn({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)(L,{}),(0,X.jsx)(F,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,X.jsx)(R,{"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)(R,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:E(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 Fn({run:e,actions:t}){let n=t.confirming;return(0,X.jsx)(Xe,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,X.jsxs)(ht,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(it,{children:[(0,X.jsx)(_t,{className:`text-danger`,children:`Delete task permanently?`}),(0,X.jsx)(yt,{children:(0,X.jsxs)(X.Fragment,{children:[`Delete “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:o(e),children:o(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!ne(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,X.jsxs)(dt,{children:[(0,X.jsx)(bt,{children:`Cancel`}),(0,X.jsx)(ot,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function In({runId:e,onClose:t}){let n=g(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)(P,{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)(Et,{runId:e,children:(0,X.jsx)(Tt,{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)(P,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Z(n.data??``,`Notes copied`),children:`Copy notes`}),(0,X.jsx)(P,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{Yt as a,Zt as i,$t as n,Jt as o,en as r,Gt as s,On 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{$ as r,L as i,U as a,X as o,nt as s,rt as c}from"./queries-Byfl3YoC.js";import{Ci as l,Si as u,_i as d,a as f,vi as p,yi as m}from"./project-scope-context-BWHk0niI.js";import{m as h,n as g,r as _}from"./chunk-KS7C4IRE-BdLLx37K.js";import{d as v,u as y}from"./design-icons-QbNMZniQ.js";import{t as b}from"./plus-CxRU2X8C.js";import{t as x}from"./button-BV_AiLj2.js";import{n as ee,r as te,t as ne}from"./collapsible-D5i3hm2L.js";import{t as S}from"./switch-B9OfOEzC.js";import{t as C}from"./badge-DAnkqD7i.js";import{n as w,s as T,t as E}from"./project-router-TP6DSj1S.js";import{o as D,u as re}from"./page-shell-BdjH5hyc.js";import{G as ie,Jn as O,ar as ae,bt as k,lr as A,vt as oe,wn as se,yt as j}from"./index-D0RESQCN.js";import{t as ce}from"./textarea-BGp28xFr.js";import{n as le}from"./save-cue-CpHgT93o.js";import{n as M}from"./settings-field-AyinSFR_.js";import{t as ue}from"./project-location-8EYHMbCE.js";import{n as N,r as de,t as fe}from"./settings-save-bar-CroXxZIi.js";import{n as pe,t as me}from"./saved-draft-BwzBc-_Y.js";import{t as he}from"./archive-on-merge-field-DR-KA2nj.js";import{a as ge,i as _e,n as P,t as F}from"./projects-section-CaKm84OL.js";var I=e(t(),1),L={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},R=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),z={name:``,description:``,url:``,token:``,tasks:!0,triggers:u,agent:!1};function B(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??u,agent:e.agent}}var V=e=>l.filter(t=>e.includes(t));function ve(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...R(e.triggers,u)?{}:{triggers:V(e.triggers)},agent:e.agent}}function ye(e){return e.name.trim()!==``||e.description.trim()!==``||e.url.trim()!==``||e.token!==``||e.tasks!==z.tasks||e.agent!==z.agent||!R(e.triggers,z.triggers)}function be(e,t){let n={},r=e.name.trim(),i=e.description.trim(),a=e.url.trim();return r!==t.name&&(n.name=r),i!==(t.description??``)&&(n.description=i),a!==t.url&&(n.url=a),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),R(e.triggers,t.triggers??u)||(n.triggers=V(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var H=n(),U=`flex flex-col gap-1 text-[13px]`,W=`text-xs text-muted-foreground`;function G({draft:e,onChange:t,tokenSet:n}){let r=(0,I.useId)(),i=(0,I.useId)(),a=(0,I.useId)(),o=(0,I.useId)(),s=(0,I.useId)(),c=(0,I.useId)(),u=(0,I.useId)(),f=(0,I.useId)(),h=(0,I.useId)(),g=(0,I.useId)();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,H.jsxs)(`div`,{className:U,children:[(0,H.jsx)(`label`,{htmlFor:r,className:W,children:`Name`}),(0,H.jsx)(A,{id:r,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,H.jsxs)(`div`,{className:U,children:[(0,H.jsx)(`label`,{htmlFor:o,className:W,children:`URL`}),(0,H.jsx)(A,{id:o,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:m,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,H.jsxs)(`div`,{className:U,children:[(0,H.jsx)(`label`,{htmlFor:i,className:W,children:`Description`}),(0,H.jsx)(ce,{id:i,"data-slot":`webhook-description`,"aria-describedby":a,rows:2,maxLength:d,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,H.jsx)(`span`,{id:a,className:`text-xs text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,H.jsxs)(`div`,{className:U,children:[(0,H.jsx)(`label`,{htmlFor:s,className:W,children:`Token`}),(0,H.jsx)(A,{id:s,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:p,"aria-describedby":c,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,H.jsx)(`span`,{id:c,className:`text-xs text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,H.jsx)(S,{id:u,"aria-describedby":f,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,H.jsx)(`label`,{htmlFor:u,className:`font-medium`,children:`Task notifications`}),(0,H.jsx)(`span`,{id:f,className:`text-xs text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,H.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,H.jsx)(`legend`,{className:`pbe-1 text-xs text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,H.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:l.map(n=>(0,H.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:L[n].label}),(0,H.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:L[n].hint})]})]},n))}),(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,H.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,H.jsx)(S,{id:h,"aria-describedby":g,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,H.jsx)(`label`,{htmlFor:h,className:`font-medium`,children:`Let agents send reports`}),(0,H.jsx)(`span`,{id:g,className:`text-xs text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var K=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),xe=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function q({feedback:e}){return e?(0,H.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var J=`rounded-md border border-border bg-background`,Y=`flex flex-col gap-3 border-bs border-border p-3`;function Se({projectId:e,webhook:t,defaultOpen:n=!1}){let i=s(),a=o(),c=r(),[l,u]=(0,I.useState)(n),[d,p]=pe(B(t),me),[m,h]=(0,I.useState)(null),g=be(d,t),_=Object.keys(g).length>0,v=d.name.trim()!==``&&d.url.trim()!==``,b=i.isPending||a.isPending||c.isPending,S={projectId:e,webhookId:t.id},w=()=>(h(null),i.mutateAsync({...S,...g},{onSuccess:()=>p(e=>({...e,token:``})),onError:e=>h(K(e,`Save`))}));de({dirty:_,invalid:!v,busy:b,save:w,discard:()=>p(B(t))});let T=()=>c.mutate(S,{onSuccess:e=>h(xe(e)),onError:e=>h({tone:`danger`,text:e.message})});return(0,H.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:J,children:(0,H.jsxs)(ne,{open:l,onOpenChange:u,children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,H.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,H.jsx)(C,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,H.jsx)(C,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,H.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:ie(t.url)})]}),(0,H.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,H.jsx)(ee,{children:(0,H.jsxs)(`form`,{"data-slot":`webhook-form`,"data-reports-dirty":``,className:Y,onSubmit:e=>{e.preventDefault(),h(null),v&&_&&!b&&w().catch(()=>{})},children:[(0,H.jsx)(G,{draft:d,tokenSet:t.tokenSet,onChange:e=>p(t=>({...t,...e}))}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(x,{type:`button`,size:`sm`,variant:`outline`,"data-action":`webhook-test`,disabled:b||!v,onClick:()=>{h(null),_?w().then(T,()=>{}):T()},children:`Send test`}),t.tokenSet?(0,H.jsx)(x,{type:`button`,size:`sm`,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:b,onClick:()=>i.mutate({...S,token:``},{onSuccess:()=>f(`Webhook token cleared`),onError:e=>h({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,H.jsx)(x,{type:`button`,size:`sm`,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:b,onClick:()=>a.mutate(S,{onSuccess:()=>f(`${t.name} removed`),onError:e=>h({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,H.jsx)(q,{feedback:m}),(0,H.jsx)(fe,{})]})})]})})}function Ce({projectId:e,onCreated:t,onCancel:n}){let r=i(),[a,o]=(0,I.useState)(z),[s,c]=(0,I.useState)(null),l=a.name.trim()!==``&&a.url.trim()!==``;return se(ye(a)),(0,H.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:J,children:[(0,H.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,H.jsxs)(`form`,{"data-slot":`webhook-form`,"data-reports-dirty":``,"aria-label":`New webhook`,className:Y,onSubmit:n=>{n.preventDefault(),c(null),l&&r.mutate({projectId:e,...ve(a)},{onSuccess:({webhook:e})=>{f(`${e.name} created`),t(e)},onError:e=>c(K(e,`Create`))})},children:[(0,H.jsx)(G,{draft:a,tokenSet:!1,onChange:e=>o(t=>({...t,...e}))}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(x,{type:`submit`,size:`sm`,variant:`outline`,"data-action":`webhook-create`,disabled:r.isPending||!l,children:`Create`}),(0,H.jsx)(x,{type:`button`,size:`sm`,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,H.jsx)(q,{feedback:s})]})]})}function we({project:e}){let t=e.webhooks??[],[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(null),o=t.length>=16;return(0,H.jsx)(M,{wide:!0,title:`Webhooks`,hint:`A webhook gets a POST from Squawk. Tasks can send their status to it, and agents can send it reports.`,children:(0,H.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,H.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,H.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,H.jsx)(Se,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,H.jsx)(Ce,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,H.jsx)(b,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,H.jsxs)(`span`,{className:`text-xs text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function X(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Te(){let e=T(),t=a(),n=c(),r=O(),i=le();if(t.isPending)return(0,H.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,H.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let o=t.data,s=o?.projects.find(t=>t.id===e);return!o||!s?null:(0,H.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,H.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,H.jsx)(ue,{}),(0,H.jsx)(Z,{project:s}),(0,H.jsx)(M,{title:`Max parallel tasks`,saved:i.saved,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,H.jsx)(F,{project:s,workspaceMax:n.data.resources.maxParallel,onSaved:i.flash}):(0,H.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),r===`absent`?null:(0,H.jsx)(we,{project:s},s.id)]}),(0,H.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,H.jsx)(Ee,{project:s,projects:o.projects,bootProject:o.bootProject})})]})}function Z({project:e}){return(0,H.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Project`}),(0,H.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Branch`}),(0,H.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,H.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[P[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Added`}),(0,H.jsxs)(`dd`,{className:`mt-1`,children:[X(e.addedAt),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Last opened`}),(0,H.jsx)(`dd`,{className:`mt-1`,children:X(e.lastOpenedAt)})]})]})}function Ee({project:e,projects:t,bootProject:n}){let[r,i]=(0,I.useState)(null),a=ge(),o=h(),s=n!==null&&e.id===n,c=n??t.find(t=>t.id!==e.id&&t.status!==`missing`)?.id??t.find(t=>t.id!==e.id)?.id??null;return(0,H.jsxs)(M,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:s?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:s||a.isPending,onClick:()=>i(e),className:`text-danger`,children:[`Remove `,e.name]}),s?(0,H.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-xs text-soft-foreground`,children:`Squawk is serving this project — it re-registers itself at every start.`}):null]}),(0,H.jsx)(_e,{project:r,onOpenChange:e=>!e&&i(null),onConfirm:()=>{i(null),a.confirm(e,()=>void o(c===null?`/`:`/p/${encodeURIComponent(c)}`))}})]})}function De(e){return e===`global`?{Link:g,NavLink:_}:{Link:E,NavLink:w}}function Q({scope:e,title:t,mobileTitle:n,description:r}){let i=ae().name,a=e===`global`?`every project`:i??`this project`;return{headerSlot:`settings-main-header`,title:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`md:hidden`,children:n}),(0,H.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` `,(0,H.jsxs)(`span`,{"data-slot":`page-header-scope`,className:`font-normal text-soft-foreground`,children:[`· `,a]})]})]}),subtitle:r,hideSubtitleOnMobile:!0,headerExtra:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"data-slot":`settings-mobile-scope`,className:`mt-1 text-[13px] text-muted-foreground md:hidden`,children:e===`global`?`Applies to every project`:a}),e===`global`?(0,H.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}}function $({scope:e,activeId:t}){let{NavLink:n}=De(e),r=k(e);return(0,H.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,H.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,H.jsx)(y,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,H.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,H.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,H.jsx)(n,{to:j(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function Oe({section:e,scope:t}){let n=e.component,r=T(),i=Q({scope:t,title:e.title,description:e.description,mobileTitle:t===`global`?`Global settings`:`Project settings`});return(0,H.jsx)(e.id===`agent-config`?re:D,{route:t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,density:`full`,className:`settings-route`,header:i,children:(0,H.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,H.jsxs)(`div`,{"data-slot":`settings-mobile-section`,className:`flex flex-col gap-2 md:hidden`,children:[(0,H.jsx)($,{scope:t,activeId:e.id}),e.description?(0,H.jsx)(`p`,{"data-slot":`settings-mobile-section-subtitle`,className:`px-1 text-[13px] leading-normal text-muted-foreground`,children:e.description}):null]}),(0,H.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,H.jsx)(`h2`,{className:`settings-panel-title sr-only`,children:e.title}),(0,H.jsx)(N,{children:(0,H.jsx)(n,{})},`${r??``}:${e.id}`)]})]})})}function ke(){let e=Q({scope:`project`,title:`General`,mobileTitle:`Project settings`}),t=T();return(0,H.jsx)(D,{route:`settings`,density:`full`,className:`settings-route`,header:e,children:(0,H.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,H.jsx)($,{scope:`project`,activeId:null}),(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:(0,H.jsxs)(N,{children:[(0,H.jsx)(Te,{}),(0,H.jsx)(`section`,{className:`rounded-lg border border-card-edge bg-card p-5 shadow-card`,children:(0,H.jsx)(he,{})}),(0,H.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-card-edge bg-card px-5 pt-5 text-base font-semibold shadow-card md:hidden`,children:`Other project settings`}),(0,H.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:k(`project`).map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(E,{to:j(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-card-edge bg-card p-4 shadow-card transition-colors hover:bg-card-2`,children:[(0,H.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,H.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,H.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]}),(0,H.jsx)(v,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,H.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, preferences, host resources and the project registry live in`,` `,(0,H.jsx)(g,{to:oe,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]},t??``)})]})})}export{ke as SettingsIndexRoute,Oe as SettingsSectionRoute};
@@ -1,5 +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{B as r,Gn as i,In as a,S as o,Tt as s,Ut as c,Wt as l,Zt as u,on as d,yr as f}from"./queries-Byfl3YoC.js";import{Kt as p,Ni as m,Ot as h,Vt as g,Wt as _,a as v,ea as y,st as b,ut as ee,wn as x,zt as S}from"./project-scope-context-BWHk0niI.js";import{g as C}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as w}from"./dist-CCX8mhHc.js";import{M as T,u as E,w as D}from"./design-icons-QbNMZniQ.js";import{t as te}from"./run-header-BREol2Ej.js";import{i as O,n as ne,r as k}from"./git-toolbar-CAAZ5T8F.js";import{t as A}from"./button-BV_AiLj2.js";import{a as j,i as M,o as N,r as P,s as F,t as I}from"./dialog-DKr-j9S6.js";import{f as re,l as ie,m as ae}from"./page-shell-BdjH5hyc.js";import{t as L}from"./centered-state-N8vWM_Hw.js";import{D as oe,E as se,Vn as ce,gn as le,rt as ue}from"./index-D0RESQCN.js";import{t as R}from"./textarea-BGp28xFr.js";import{t as z}from"./markdown-BBDDg-4t.js";import{a as B,i as V,o as H,t as U}from"./unified-diff-JD9Q6oCe.js";import{n as de,t as fe}from"./review-notes-drafts-BncrXliY.js";import{t as pe}from"./diff-BPw0S-BU.js";import{t as me}from"./code-workbench-B0GIezrD.js";import{t as he}from"./file-text-nGpo7MVd.js";import{i as ge,n as W,r as _e}from"./selected-file-CfBWFB6p.js";var G=e(t(),1),K=`no worktree — this task ran directly in the repo working tree`;function q(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${K}`)}function J(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${K}`)}function ve(e){let t=e=>({id:`create-pr`,label:`Draft PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Draft PR unavailable — ${K}`):e.forge===null?t(`Draft PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?m(e.run)?t(`Draft PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):i(e.run)?t(`Draft PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Draft PR`,enabled:!0}:t(`Draft PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function ye(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:q(e),n=e.prUrl?[q(e),J(e)]:[J(e),ve(e)],r=[];if(e.localHandoff&&e.cliHandoff!==!1){let t=e.worktreeUnavailable?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — ${K}`}:e.hasSession?i(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,primaryVariant:e.run.status===`review`?`outline`:`primary`,secondary:n,menu:r}}function be(e,t){let[n=``,...r]=t.trim().split(`
2
- `),i=[n,...r.map(e=>e.trim()===``?``:` ${e.trimEnd()}`)].join(`
3
- `);return`- \`${xe(e)}\` — ${i}`}function xe({path:e,side:t,line:n}){let r=typeof n==`number`||n.start===n.end?String(typeof n==`number`?n:n.start):`${n.start}-${n.end}`;return t===`old`?`${e} (old ${r})`:`${e}:${r}`}function Se(e,t,n){let r=fe(e).notes;de(e,{open:!0,notes:`${r}${r===``||r.endsWith(`
4
- `)?``:`
5
- `}${be(t,n)}`})}var Y=n();function Ce({run:e,open:t,onOpenChange:n}){let r=y(),[i,o]=(0,G.useState)(``),s=a(e),c=(0,G.useRef)(s);c.current=s,(0,G.useEffect)(()=>{t&&o(c.current)},[t]);let l=f({mutationFn:t=>b(e.id,t),onSuccess:t=>{v(`Committed ${ce(t.sha)}`),n(!1),r.invalidateQueries({queryKey:d.runs.changes(e.id)}),r.invalidateQueries({queryKey:d.runs.all})},onError:e=>v(e.message,{tone:`danger`})}),u=()=>{let e=i.trim();e.length===0||l.isPending||l.mutate(e)};return(0,Y.jsx)(I,{open:t,onOpenChange:n,children:(0,Y.jsxs)(P,{"data-slot":`commit-dialog`,children:[(0,Y.jsxs)(N,{children:[(0,Y.jsx)(F,{children:`Commit changes`}),(0,Y.jsxs)(M,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Y.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Y.jsx)(R,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{ue(e)&&(e.preventDefault(),u())}}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(A,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Y.jsx)(A,{"data-slot":`commit-confirm`,disabled:i.trim().length===0||l.isPending,onClick:u,children:l.isPending?`Committing…`:`Commit`})]})]})})}function X(){let{id:e}=C(),t=c(e);return t.isPending?(0,Y.jsx)(oe,{tab:`changes`}):t.isError?(0,Y.jsx)(se,{tab:`changes`,error:t.error}):(0,Y.jsx)(we,{run:t.data},t.data.id)}function we({run:e}){let t=r(),n=o(),a=l(e.id,i(e)),s=ae(),[c,u]=(0,G.useState)(`unified`),[p,m]=(0,G.useState)(!0),[h,b]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),w=y(),T=()=>w.invalidateQueries({queryKey:d.runs.all}),E=e=>v(e.message,{tone:`danger`}),D=f({mutationFn:()=>_(e.id),onSuccess:e=>v(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:E}),O=f({mutationFn:()=>ee(e.id),onSuccess:e=>{v(`Draft PR created — ${e.url}`),T()},onError:E}),k=f({mutationFn:()=>g(e.id),onError:e=>{if(e instanceof x&&e.command){navigator.clipboard.writeText(e.command).then(()=>v(`No terminal found — command copied to clipboard.`)).catch(()=>v(`Run manually: ${e.command}`));return}E(e)}}),A=$(a),j=Q(e,A),M=ye({run:e,cliHandoff:e.cliHandoff,hasWorktree:!!e.worktreePath&&!A,worktreeUnavailable:!!e.worktreeReclaimedAt||j.workspaceDeleted,branch:e.branch,changedFiles:a.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:le(e)!==void 0,prUrl:e.pullRequestUrl}),N=e=>{switch(e){case`commit`:C(!0);break;case`push`:D.mutate();break;case`create-pr`:O.mutate();break;case`open-terminal`:k.mutate();break;case`view-pr`:break}},P=j.available?j.files:a.data?.files??[],F=j.available?j.stat:a.data?.stat,I=(0,G.useMemo)(()=>P.some(z),[P]),L=s?c:`unified`;return(0,Y.jsxs)(ie,{route:`task-changes`,density:re(P.length),flushPadding:!0,children:[(0,Y.jsx)(te,{run:e,tab:`changes`}),(0,Y.jsx)(ne,{bar:M,healthReady:t.data!==void 0,branch:e.branch,stat:F,mode:L,wrap:p,preview:h,onModeChange:u,onWrapChange:m,onPreviewChange:I?b:void 0,onAction:N}),(0,Y.jsx)(Z,{run:e,mode:L,wrap:p,preview:h}),(0,Y.jsx)(Ce,{run:e,open:S,onOpenChange:C})]})}function Z({run:e,mode:t=`unified`,wrap:n=!0,preview:a=!1,revealRef:o}){let s=r(),c=l(e.id,i(e)),u=f({mutationFn:t=>S(e.id,t),onError:e=>v(e.message,{tone:`danger`})}),d=$(c),p=Q(e,d),m=p.available?p.files:c.data?.files??[],h=p.available?p.files:c.data?.files,g=(0,G.useMemo)(()=>k(m),[m]),_=ge(e.id),y=_e(e.id,`changes`,h);return(0,G.useEffect)(()=>{if(o)return o.current=t=>m.some(e=>e.path===t)?(W(e.id,t),y.reveal(t),!0):!1,()=>{o.current=null}},[o,m,e.id,y]),(0,Y.jsxs)(Y.Fragment,{children:[c.data?.repointedHead?(0,Y.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Y.jsx)(`code`,{children:c.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Y.jsx)(`code`,{children:c.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,p.available&&p.observedAt?(0,Y.jsx)(B,{observedAt:p.observedAt,headSha:p.headSha,truncated:p.truncated,worktreeRemoved:p.worktreeRemoved,variant:`bar`}):null,(0,Y.jsx)(Te,{changes:c,changesRefused:d,stored:p,fileCount:m.length,children:(0,Y.jsx)(Ee,{runId:e.id,files:m,tree:g,selected:_,selectFile:t=>{W(e.id,t),y.reveal(t)},diffRef:y,effectiveMode:t,effectiveWrap:n,preview:a,stored:p.available,localHandoff:s.data?.capabilities.localHandoff,onOpenInApp:u.mutate,onNote:e.status===`review`?(t,n)=>Se(e.id,t,n):void 0})})]})}function Q(e,t){let n=s(e),r=u(e.id,{includeDiff:!0,enabled:t,version:n}),i=t?r.data:void 0,a=i?.diff.state===`available`?i.diff.patch:void 0,o=a!==void 0,c=(0,G.useMemo)(()=>a?V(a):[],[a]),l=(0,G.useMemo)(()=>o&&c.length>0?U(c):void 0,[o,c]);return{pending:t&&r.isPending,available:o,observedAt:i?.observedAt,headSha:i?.head.sha,truncated:i?.diff.state===`available`?i.diff.truncated||!!i.diff.patchTruncated:!1,worktreeRemoved:i?H(i):!1,workspaceDeleted:i?.workspace.state===`deleted`,files:c,stat:l}}function $(e){return e.isError&&e.error instanceof x&&e.error.status===409}function Te({changes:e,changesRefused:t,stored:n,fileCount:r,children:i}){return e.isPending||n.pending?(0,Y.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):n.available?r===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(D,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes recorded in stored snapshot`,subtitle:`The worktree matched its base branch when this snapshot was saved.`}):i:e.isError?(0,Y.jsx)(L,{icon:t?(0,Y.jsx)(D,{size:16}):(0,Y.jsx)(T,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):r===0?(0,Y.jsx)(L,{icon:(0,Y.jsx)(D,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):i}function Ee({runId:e,files:t,tree:n,selected:r,selectFile:i,diffRef:a,effectiveMode:o,effectiveWrap:s,preview:c,stored:l=!1,localHandoff:u,onOpenInApp:d,onNote:f}){let[m,g]=(0,G.useState)(!1);return(0,Y.jsx)(me,{className:`px-4 pb-9 pt-0 [--diff-sticky-top:0px] md:px-9`,treeSlot:`changes-tree-pane`,treeClassName:`rounded-xl border border-border bg-card md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)] md:overflow-y-auto md:overscroll-contain md:p-3.5`,tree:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`changes-tree-toggle`,"aria-expanded":m,onClick:()=>g(e=>!e),className:`flex min-h-11 w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-xs font-semibold text-foreground md:hidden`,children:[(0,Y.jsxs)(`span`,{children:[`Changed files`,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]}),(0,Y.jsx)(E,{size:16,"aria-hidden":`true`,className:w(`size-4 shrink-0 text-muted-foreground motion-safe:transition-transform`,m&&`rotate-180`)})]}),(0,Y.jsx)(`h2`,{className:`mb-3 hidden border-b border-border pb-3 text-xs font-semibold md:block`,children:`Changed files`}),(0,Y.jsx)(`div`,{className:w(m?`border-t border-border px-3.5 py-3 md:border-t-0 md:p-0`:`hidden md:block`),children:(0,Y.jsx)(O,{root:n,selected:r,onSelect:e=>{i(e),g(!1)}})})]}),children:(0,Y.jsx)(pe,{files:t,viewRef:a,mode:o,wrap:s,preview:c,loadFileText:l?void 0:t=>he(()=>h(e,t)),imageSrc:l?void 0:t=>p(e,t),onOpenInApp:!l&&u&&d?e=>d(e):void 0,onNote:l?void 0:f,totals:!1,className:`min-w-0 flex-1`})})}export{Z as ChangesPane,X as TaskChangesRoute};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Gn as t,Gt as n,Kt as r,Ut as i,br as a,on as o}from"./queries-Byfl3YoC.js";import{Tt as s,wn as c,wt as l}from"./project-scope-context-BWHk0niI.js";import{g as u}from"./chunk-KS7C4IRE-BdLLx37K.js";import{C as d,M as f}from"./design-icons-QbNMZniQ.js";import{t as p}from"./run-header-BREol2Ej.js";import{t as m}from"./project-router-TP6DSj1S.js";import{f as h,l as g,m as _}from"./page-shell-BdjH5hyc.js";import{t as v}from"./centered-state-N8vWM_Hw.js";import{Bn as y,D as b,E as x}from"./index-D0RESQCN.js";import{t as S}from"./change-counts-BLLRvt46.js";import{t as C}from"./code-workbench-B0GIezrD.js";import{t as w}from"./file-text-nGpo7MVd.js";import{i as T,r as E,t as D}from"./commit-list-zMKEapLK.js";import{i as O,n as k,r as A}from"./selected-file-CfBWFB6p.js";var j=e();function M(){let{id:e}=u(),t=i(e);return t.isPending?(0,j.jsx)(b,{tab:`changes`}):t.isError?(0,j.jsx)(x,{tab:`changes`,error:t.error}):(0,j.jsx)(N,{run:t.data})}function N({run:e}){let{sha:n}=u(),i=r(e.id,t(e)),a=_(),o=n??i.data?.commits[0]?.sha,s=n!==void 0&&(!a||i.isError||i.data?.commits.length===0);return(0,j.jsxs)(g,{route:`task-commits`,density:h(i.data?.commits.length??0),flushPadding:!0,children:[(0,j.jsx)(p,{run:e,tab:`commits`}),s?(0,j.jsx)(F,{runId:e.id,sha:n}):i.isPending?(0,j.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading commits…`}):i.isError?(0,j.jsx)(v,{icon:(0,j.jsx)(f,{size:16}),tone:i.error instanceof c&&i.error.status===409?`neutral`:`danger`,heading:`h2`,title:i.error instanceof c&&i.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:i.error.message}):i.data.commits.length===0?(0,j.jsx)(v,{icon:(0,j.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,j.jsx)(P,{run:e,commits:i.data.commits,selectedSha:o})]})}function P({run:e,commits:t,selectedSha:r}){let i=n(e.id,r),a=L(e.id,t),o=A(e.id,`commit:${r??``}`,i.data?.files),c=O(e.id);return(0,j.jsx)(C,{className:`px-4 py-5 md:px-9`,treeSlot:`task-commits-pane`,tree:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(D,{slot:`task-commits`,selectedSha:r,heading:(0,j.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[t.length,` `,t.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:t.map(t=>({...t,href:`/tasks/${e.id}/commits/${t.sha}`,stat:a.get(t.sha)}))}),r&&i.data&&i.data.files.length>0?(0,j.jsx)(R,{runId:e.id,sha:r,files:i.data.files,selected:c,onPick:t=>{k(e.id,t),o.reveal(t)}}):null]}),children:r?(0,j.jsx)(T,{commit:i,sha:r,slot:`task-commit-preview`,heading:`h3`,diffRef:o,loadFileText:t=>w(()=>s(e.id,r,t))}):null})}function F({runId:e,sha:t}){let r=n(e,t);return(0,j.jsx)(E,{commit:r,sha:t,diffRef:A(e,`commit:${t}`,r.data?.files),backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,loadFileText:n=>w(()=>s(e,t,n))})}var I=12;function L(e,t){let n=t.length<=I,r=a({queries:t.map(t=>({queryKey:o.runs.commit(e,t.sha),queryFn:({signal:n})=>l(e,t.sha,{signal:n}),enabled:n,retry:!1}))}),i=new Map;return r.forEach((e,n)=>{let r=t[n]?.sha;r&&e.data?.stat&&i.set(r,e.data.stat)}),i}function R({runId:e,sha:t,files:n,selected:r,onPick:i}){return(0,j.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-4 rounded-xl border border-border bg-card p-4`,children:[(0,j.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,j.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[n.length,` `,n.length===1?`file`:`files`,` in`,` `,(0,j.jsx)(y,{sha:t,variant:`inline`,className:`text-[13px] font-medium`})]}),(0,j.jsx)(m,{to:`/tasks/${e}/changes`,className:`text-xs text-muted-foreground hover:text-foreground`,children:`All task changes ›`})]}),(0,j.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,"data-slot":`task-commit-file`,title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,"aria-current":e.path===r?`true`:void 0,onClick:()=>i(e.path),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground hover:bg-muted hover:text-foreground aria-[current=true]:bg-muted aria-[current=true]:text-foreground`,children:[(0,j.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:e.path}),(0,j.jsx)(S,{adds:e.adds,dels:e.dels,className:`font-mono text-xs`})]})},e.path))})]})}export{M as TaskCommitsRoute};