@hearsay-tools/squawk 0.19.0-pr4622.9211 → 0.19.0-pr4622.9213

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 (91) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/delegation/routes.d.ts +78 -78
  3. package/dist/features/hosts/routes.d.ts +64 -64
  4. package/dist/features/reports/routes.d.ts +2 -2
  5. package/dist/features/webhooks/routes.d.ts +38 -38
  6. package/dist/server/activity-routes.d.ts +23 -23
  7. package/dist/server/models-routes.d.ts +12 -12
  8. package/dist/server/projects-routes.d.ts +41 -41
  9. package/dist/server/providers-routes.d.ts +58 -58
  10. package/dist/server/runners-routes.d.ts +10 -10
  11. package/dist/server/runs-routes.d.ts +347 -347
  12. package/dist/server/workspace-live-routes.d.ts +5 -5
  13. package/dist/server/workspace-routes.d.ts +85 -85
  14. package/package.json +4 -4
  15. package/web/dist/assets/{accounts-section-CKWqAxEQ.js → accounts-section-BwVLJgxK.js} +1 -1
  16. package/web/dist/assets/{activity-motion-BlhXAVnS.js → activity-motion-tBH9QmZu.js} +1 -1
  17. package/web/dist/assets/{activity-route-BfsOrdeD.js → activity-route-CkXs29ji.js} +1 -1
  18. package/web/dist/assets/{agent-accounts-DKK4W3xn.js → agent-accounts-DQ_JY8H9.js} +1 -1
  19. package/web/dist/assets/{agent-config-section-BY92FMFf.js → agent-config-section-Bii12by6.js} +2 -2
  20. package/web/dist/assets/{agent-defaults-section-DGYwfnYh.js → agent-defaults-section-BpiqyCUf.js} +1 -1
  21. package/web/dist/assets/{appearance-BGjaVf7D.js → appearance-B_765RRk.js} +1 -1
  22. package/web/dist/assets/{archive-on-merge-field-BrS2zm1g.js → archive-on-merge-field-B6O9ruku.js} +1 -1
  23. package/web/dist/assets/{ask-card-Dc1pCn2B.js → ask-card-Cd0Xc7Uq.js} +2 -2
  24. package/web/dist/assets/{automations-route-B1B7zQgr.js → automations-route-CcVVZs26.js} +2 -2
  25. package/web/dist/assets/{commit-list-BaoYb5Dt.js → commit-list-Dcd0WekD.js} +1 -1
  26. package/web/dist/assets/{diff-CGZaTysl.js → diff-B_cIEbs-.js} +2 -2
  27. package/web/dist/assets/{diff-controls-DulaH3EF.js → diff-controls-BTGIDnSs.js} +1 -1
  28. package/web/dist/assets/{diff-view-DCCWqI57.js → diff-view-J684vGFE.js} +1 -1
  29. package/web/dist/assets/{discard-changes-dialog-BXaM9RmZ.js → discard-changes-dialog-BtnFyMRT.js} +1 -1
  30. package/web/dist/assets/{file-preview-BvtY-4m2.js → file-preview-B3jXfVP7.js} +1 -1
  31. package/web/dist/assets/{folder-browser-BztgyA2p.js → folder-browser-sYsHX_an.js} +1 -1
  32. package/web/dist/assets/{git-toolbar-bhQ7aTtR.js → git-toolbar-SKqi4XfU.js} +1 -1
  33. package/web/dist/assets/github-T6wolZwH.js +1 -0
  34. package/web/dist/assets/{global-activity-route-FJwugmwm.js → global-activity-route-Dx-kvhpz.js} +1 -1
  35. package/web/dist/assets/hosts-DeyANWdw.js +1 -0
  36. package/web/dist/assets/index-6oRe52sM.js +21 -0
  37. package/web/dist/assets/label-BXbOoPSF.js +1 -0
  38. package/web/dist/assets/{markdown-WuLAJnyd.js → markdown-TRVPj3Mg.js} +1 -1
  39. package/web/dist/assets/{open-in-menu-CYVvplCT.js → open-in-menu-g5K4vTnb.js} +1 -1
  40. package/web/dist/assets/{option-select-7AnGvvB1.js → option-select-B76TaZGm.js} +1 -1
  41. package/web/dist/assets/{preferences-section-BcGAVrXN.js → preferences-section-DZRKsK2E.js} +1 -1
  42. package/web/dist/assets/{preview-pane-connected-CNSFmeOm.js → preview-pane-connected-CM10_MPC.js} +1 -1
  43. package/web/dist/assets/{project-location-CevhmYtx.js → project-location-F5rU1iQp.js} +1 -1
  44. package/web/dist/assets/projects-section-DvYKR18b.js +1 -0
  45. package/web/dist/assets/{prompt-templates-section-CBvPHVqL.js → prompt-templates-section-DFiGQ_kP.js} +2 -2
  46. package/web/dist/assets/queries-DQVUxiSU.js +1 -0
  47. package/web/dist/assets/{read-state-D9a4i8-k.js → read-state-DlkdVJHO.js} +1 -1
  48. package/web/dist/assets/{reference-chip-CW8i_sq3.js → reference-chip-DTWd5NlK.js} +1 -1
  49. package/web/dist/assets/{remote-settings-notice-BR81Cf35.js → remote-settings-notice-4jnKyzkr.js} +1 -1
  50. package/web/dist/assets/{repo-git-D2lw4Jb0.js → repo-git-bpVnYJKi.js} +1 -1
  51. package/web/dist/assets/{report-reader-BDPP4dVK.js → report-reader-DMyNCIiX.js} +1 -1
  52. package/web/dist/assets/{report-selection-CJ-q2Dc5.js → report-selection-BJgUwTp3.js} +1 -1
  53. package/web/dist/assets/{reports-Ber7rhF2.js → reports-CBzt0Dmc.js} +1 -1
  54. package/web/dist/assets/{resources-section-DfPp8Jln.js → resources-section-DrFTKHSn.js} +1 -1
  55. package/web/dist/assets/{review-notes-drafts-DFiWzQLc.js → review-notes-drafts-N0GgOh1J.js} +1 -1
  56. package/web/dist/assets/{review-panel-BZY9n7NK.js → review-panel-BhyjEDJC.js} +1 -1
  57. package/web/dist/assets/{review-strip-DsmIhl6m.js → review-strip-DoWuOvcF.js} +1 -1
  58. package/web/dist/assets/{run-detail-refresh-u-eY7R4u.js → run-detail-refresh-Bx9zlPFP.js} +1 -1
  59. package/web/dist/assets/{run-diff-6l-f4FRx.js → run-diff-BqvMg-mp.js} +1 -1
  60. package/web/dist/assets/{run-header-CZkXDDXM.js → run-header-Bg2x1hvz.js} +2 -2
  61. package/web/dist/assets/{select-BXM-MFR0.js → select-Cbi8vDBU.js} +1 -1
  62. package/web/dist/assets/{session-context-section-JsdhWEPi.js → session-context-section-BnezEi_b.js} +1 -1
  63. package/web/dist/assets/{settings-agent-picker-DcPaMYPH.js → settings-agent-picker-DCmAHz6j.js} +1 -1
  64. package/web/dist/assets/{settings-save-bar-D0m7WuMo.js → settings-save-bar-De7cR5EO.js} +1 -1
  65. package/web/dist/assets/{settings-shell-DQmyZ9hT.js → settings-shell-kQCF-IMK.js} +1 -1
  66. package/web/dist/assets/{sidebar-section-Bs-cg8z3.js → sidebar-section-BZHg8W-H.js} +1 -1
  67. package/web/dist/assets/{skills-B3Isk2OO.js → skills-DUOE73c3.js} +1 -1
  68. package/web/dist/assets/{task-changes-DOjyd1uO.js → task-changes-fRMZxCzG.js} +2 -2
  69. package/web/dist/assets/{task-commits-B-0XCAhO.js → task-commits-Cenv0zsB.js} +1 -1
  70. package/web/dist/assets/{task-file-scope-jCHWm0DC.js → task-file-scope-K1Ban5eN.js} +1 -1
  71. package/web/dist/assets/{task-files-Dhui8MYu.js → task-files-EU03WHnV.js} +1 -1
  72. package/web/dist/assets/{task-github-item-BLQQTXu-.js → task-github-item-Dhte1Ixh.js} +1 -1
  73. package/web/dist/assets/{task-groups-D4siwI6y.js → task-groups-DcQL5SKa.js} +1 -1
  74. package/web/dist/assets/task-thread-DDMomGRh.js +2 -0
  75. package/web/dist/assets/{thread-state-B8eN7DGY.js → thread-state-K3qTs1EO.js} +1 -1
  76. package/web/dist/assets/{use-finish-run-DEFzV087.js → use-finish-run-C8c9NAvg.js} +1 -1
  77. package/web/dist/assets/{use-hand-to-agent-state-CEXvipNt.js → use-hand-to-agent-state-BIvAHKwY.js} +1 -1
  78. package/web/dist/assets/use-path-bases-DxT4eodL.js +1 -0
  79. package/web/dist/assets/{use-workspace-config-save-DmWYyw7u.js → use-workspace-config-save-D6M-r6_i.js} +1 -1
  80. package/web/dist/assets/{workflows-DQviiLA5.js → workflows-jSPeMWLl.js} +2 -2
  81. package/web/dist/assets/{workspace-tools-CYG6A_wz.js → workspace-tools-DmZ9LMQc.js} +1 -1
  82. package/web/dist/assets/{worktrees-section-GOAfXLaQ.js → worktrees-section-CsXzXEwX.js} +4 -4
  83. package/web/dist/index.html +12 -12
  84. package/web/dist/assets/github-ByGLDkz7.js +0 -1
  85. package/web/dist/assets/hosts-D9Mbe3-s.js +0 -1
  86. package/web/dist/assets/index-C_yV_XCP.js +0 -21
  87. package/web/dist/assets/label-B7NZNRTj.js +0 -1
  88. package/web/dist/assets/projects-section-BQamIjAJ.js +0 -1
  89. package/web/dist/assets/queries-CAsaqjt8.js +0 -1
  90. package/web/dist/assets/task-thread-Qla6wJW_.js +0 -2
  91. package/web/dist/assets/use-path-bases-De5S6oTw.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ht as r,Vt as i,an as a,cn as o,dn as s,fn as c,hn as l,ln as u,mn as d,on as f,pn as p,sn as m,un as h,wn as g,yt as _}from"./queries-CAsaqjt8.js";import{f as v,h as y,m as b,u as x}from"./host-context-iTMFRMT5.js";import{Fn as S,Ji as C,Nn as w,ar as T,ji as ee,or as E,rr as D,tr as te}from"./toaster-Dglox5F-.js";import{i as O,r as k}from"./cez-idle-C0drOeLs.js";import{o as A}from"./dist-CCX8mhHc.js";import{n as j,t as M}from"./hosts-D9Mbe3-s.js";import{n as ne,r as N,t as re}from"./run-detail-refresh-u-eY7R4u.js";import{h as P}from"./es2015-BHonSvOU.js";var ie=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return T({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&E(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&D()}close(){this.readyState=2,this.release()}},F=e(t(),1);function I(e,t){if(x()||t)return[];let n=[f(e).reconcile()];e.getQueryState(M.hosts)&&n.push(e.invalidateQueries({queryKey:M.hosts,exact:!0}));let r=e.getQueryState(M.hostsProjects);return r&&j(r.data,r.status===`error`)&&n.push(e.invalidateQueries({queryKey:M.hostsProjects,exact:!0})),n}function ae(e,t,n){if(!x())for(let r of u)e.addEventListener(r,e=>{let i=d(r,e.data);i&&(i.type===`host-run-summary`||i.type===`host-run-deleted`?n.run(i):i.type===`host-usage`?n.usage(i.hostId,i.project,i.usage):(i.stateChanged&&t.invalidateQueries({queryKey:M.hosts,exact:!0}),(i.stateChanged||i.indexChanged)&&t.invalidateQueries({queryKey:M.hostsProjects,exact:!0}),i.indexChanged&&n.reconcileHosts(i.hostIds)))})}var L=n(),R=`/workspace/events?runs=summary`,z=2,B=3e3,oe=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],se=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],V=new Set;function ce(e){return V.add(e),()=>{V.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var le=1e3,G=new WeakMap;function K(e){let t=i.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},le)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let o=[i.runs.all,r.runsIndex,r.projects,i.health,i.worktrees,i.repoBranches,r.providerStatus],s=x()||n?[]:[M.hosts,M.hostsProjects,a],c=()=>{for(let t of o)e.cancelQueries({queryKey:t});for(let t of s)e.cancelQueries({queryKey:t,exact:!0})};return t?.addEventListener(`abort`,c,{once:!0}),O(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:i.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),m(e).reconcile(),...I(e,n),e.invalidateQueries({queryKey:r.projects}),U(e,i.health),e.invalidateQueries({queryKey:i.worktrees}),e.invalidateQueries({queryKey:i.repoBranches}),e.invalidateQueries({queryKey:r.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,c))}function J(e){return b()??Y(e)}function Y(e){let t=e.getQueryData(r.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(i.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function ue(e,t){return[g({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function de(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},a=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),o=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},c,l,u=(i=!1)=>{l!==void 0&&clearTimeout(l),l=void 0,c!==void 0&&cancelAnimationFrame(c),c=void 0;let a=[];for(let{key:r,baseList:i,baseQuery:c,baseUpdateCount:l,runs:u}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==c||t?.state.dataUpdateCount!==l||t?.state.data!==i){a.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}o(r,a),e.setQueryData(r,e=>{let t=e;for(let e of u.values())t=s(t,e);return t})}if(t.clear(),!i)for(let e of a)r(e);return a},d=t=>{let n=[ue(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(i.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,a){let f=d(i);if(a.type===`run-summary`&&a.summary.archived&&f.every(t=>!e.getQueryData(t)?.find(e=>e.id===a.summary.id)?.archived)&&a.type===`run-summary`){for(let r of f){let i=JSON.stringify(r),o=n.get(i);o?.phase===`fetching`&&(o.dirty=!0);let s=t.get(i);if(!s){let n=e.getQueryCache().find({queryKey:r,exact:!0});s={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,s)}s.runs.set(a.summary.id,a.summary)}l===void 0&&(l=setTimeout(()=>{u()},50),typeof requestAnimationFrame==`function`&&(c=requestAnimationFrame(()=>{u()})));return}let p=u(!0);for(let t of f)o(t,p),a.type===`run-summary`?e.setQueryData(t,e=>s(e,a.summary)):e.setQueryData(t,e=>h(e,a.id));for(let e of p)r(e)},flush:u,cancel(){a(),n.clear()}}}var fe=400;function pe(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},fe))};return{onSummary(e,n){let a=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,o=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,s=t.get(e.id);if(t.set(e.id,{shape:n,...a===void 0?{}:{parentRunId:a},...o===void 0?{}:{supervisorRunId:o}}),s?.shape!==n){r(i.runs.relationships(e.id),!0);for(let e of[a,o])e!==void 0&&r(i.runs.relationships(e),!0)}},onDeleted(n){let a=t.get(n);t.delete(n),e.removeQueries({queryKey:i.runs.relationships(n)}),a?.supervisorRunId!==void 0&&r(i.runs.relationships(a.supervisorRunId),!0),a?.parentRunId===void 0?r([...i.runs.all,`relationships`],!1):r(i.runs.relationships(a.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function me(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function he(e,t,n,r,a){switch(n.type){case`run-summary`:{let t=n.summary;if(me(e,t),a.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;N(e,i.runs.detail(n)),r.refreshParent(n)}let o=i.runs.changes(t.id);e.getQueryData(o)!==void 0&&e.invalidateQueries({queryKey:o}),e.invalidateQueries({queryKey:i.worktrees}),K(e);return}case`run-deleted`:a.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:i.runs.detail(n.id)}),e.removeQueries({queryKey:i.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:i.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function ge(e,t,n,r){if(n!==y()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;N(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function Z(e,t=v(R)){let n=C();(0,F.useEffect)(()=>{let a=ie;if(typeof a!=`function`)return;let o=null,s=m(n),c=x()?null:f(n),u=()=>{let e=o?.requestReady;return typeof e==`function`&&e.call(o)};s.setUnknownGenerationHandler(u),c?.setUnknownGenerationHandler(u);let d=ne(n),h=re(n),g={fetcher:h,refreshParent:d.refresh},_=p(),v=de(n),y=pe(n),b=!1,C,T=!1,E=!1,D=!1,A=!1,N=()=>{D=!0,A=!1;let e=r.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(E||!A){D=!1;return}N()})},P=()=>{E||C!==void 0||(C=setTimeout(()=>{C=void 0,E||F()},B))},F=()=>{o?.close(),o=new a(t,{withCredentials:!0}),o.addEventListener(`open`,()=>{b=!0,_.reset(),s.detach(),c?.detach(),k(!1),T&&(v.flush(),q(n)),T||(O(()=>W(n)),n.cancelQueries({queryKey:i.health}).then(()=>{E||n.invalidateQueries({queryKey:i.health})}),s.reconcile()),T=!0});for(let t of oe)o.addEventListener(t,r=>{let i=l(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=_.ready(i.event.seq);s.ready(i.event.generation,i.event.seq),c?.ready(i.event.generation),e&&(v.flush(),q(n));return}let a=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&_.frame(i.event.seq);i.event.type===`ping`&&b&&(b=!1,O(()=>W(n)),k(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?s.run(i.project,i.event,a):i.event.type===`usage`&&s.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(v.onEvent(i.project,i.event),ge(n,g,i.project,i.event)),(i.project===null||i.project===J(n))&&he(n,e,i.event,g,y),a&&(v.flush(),q(n))});c&&ae(o,n,c);for(let e of se)o.addEventListener(e,t=>{let i;try{i=JSON.parse(t.data)}catch{return}if(e===`project-ready`)s.reconcile({hold:!0});else if(e!==`checkout-progress`&&e!==`automation-change`){n.invalidateQueries({queryKey:r.projects});let e=n.getQueryState(M.hostsProjects);e&&j(e.data,e.status===`error`)&&n.invalidateQueries({queryKey:M.hostsProjects,exact:!0})}if(e===`project-added`){let e=i?.project?.id;typeof e==`string`&&e!==``&&s.restoreProject(e),s.reconcile({hold:!0})}if(e===`project-removed`){let e=i?.id;typeof e==`string`&&e!==``&&s.dropProject(e)}for(let t of[...V])t(e,i)});o.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=ee.safeParse(t);r.success&&(n.cancelQueries({queryKey:i.health}),n.setQueryData(i.health,r.data))}),o.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let i=S(t);if(!i)return;let a=r.providerStatus,o=w(n.getQueryData(a),i);if(o!==void 0){n.setQueryData(a,o);return}if(D){A=!0;return}N()}),o.addEventListener(`error`,()=>{k(!1),s.detach(),c?.detach(),o?.readyState===z&&P()})},I=()=>{document.visibilityState===`visible`&&(v.flush(),s.flush(),c?.flush(),(!o||o.readyState===z)&&(clearTimeout(C),C=void 0,F()))},L=()=>{clearTimeout(C),C=void 0,v.flush()};document.addEventListener(`visibilitychange`,I),window.addEventListener(`pagehide`,L);let R=te((e,t)=>(v.flush(),q(n,e,t)));return F(),()=>{R(),E=!0,k(!1),clearTimeout(C),v.flush(),v.cancel(),s.stop(),c?.stop(),d.cancel(),h.cancel(),s.setUnknownGenerationHandler(void 0),c?.setUnknownGenerationHandler(void 0),y.cancel(),document.removeEventListener(`visibilitychange`,I),window.removeEventListener(`pagehide`,L),o?.close(),o=null}},[n,e,t])}var Q=(0,F.createContext)(null);function _e({children:e}){let[t]=(0,F.useState)(c);return Z(t),_(),(0,L.jsx)(Q.Provider,{value:t,children:e})}function ve(e){let t=(0,F.useContext)(Q),n=t?t.get:be;return(0,F.useSyncExternalStore)(t?t.subscribe:ye,()=>e?n()[e]:void 0,()=>void 0)}var ye=()=>()=>void 0,be=()=>o,xe=`Label`,$=F.forwardRef((e,t)=>(0,L.jsx)(P.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=xe;var Se=$;function Ce({className:e,...t}){return(0,L.jsx)(Se,{"data-slot":`label`,className:A(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{ve as i,_e as n,ce as r,Ce as t};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Dt as i,En as a,Ft as o,Ht as s,Nt as c,Rt as l,xt as u,zt as d}from"./queries-CAsaqjt8.js";import{Ji as f,n as p,un as m}from"./toaster-Dglox5F-.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as ee}from"./popover-BQolmvDR.js";import{t as S}from"./centered-state-N8vWM_Hw.js";import{$t as C,Rn as w,an as te,en as T,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-C_yV_XCP.js";import{t as M}from"./option-select-7AnGvvB1.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-De5S6oTw.js";import{r as R}from"./settings-save-bar-D0m7WuMo.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=i();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(C,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(te,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(w,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(T,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=u();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:o,footer:c,refreshProjects:l=!1}){let u=f(),d=a({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(s.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:s.fsBrowseRoot}):l&&u.invalidateQueries({queryKey:s.projects})}}),[p,h]=z(t),g=p.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{h(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${o}-root`,value:p,disabled:d.isPending,placeholder:i,onChange:e=>{h(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:c}):(0,H.jsxs)(`p`,{"data-slot":`projects-${o}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>l(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(w,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(w,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=c(),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),[l,u]=(0,V.useState)(-1),f=(0,V.useRef)(null),m=e.tags??[],h=d(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},C=e=>{y(m.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(ee,{open:_,onOpenChange:s,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&l>=0?`${w}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),s(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(l>=0?h[l]??i:i);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),f.current?.focus()},onMouseEnter:()=>u(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=c(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{h as n,n as r,p as i}from"./host-context-iTMFRMT5.js";import{$ as a,$n as o,$t as s,A as c,An as l,Ar as u,Bi as d,Br as f,C as p,Cn as m,Cr as h,Ct as ee,D as g,Dn as _,Dr as v,Dt as y,E as b,En as x,Er as te,Et as ne,F as S,Fr as re,G as ie,Gi as ae,Hi as oe,Ht as se,Ii as C,Ir as ce,It as w,J as le,Ji as T,Jt as ue,K as de,Kt as fe,L as pe,Li as E,Mn as me,Mr as he,Mt as ge,N as _e,Nr as ve,Nt as ye,O as be,Ot as xe,Pi as Se,Pn as Ce,Pr as we,Pt as Te,Q as Ee,Qi as De,Qn as Oe,Qt as ke,Ri as Ae,Rr as je,S as Me,Sn as Ne,St as Pe,Tn as Fe,Tr as Ie,Ui as Le,Vi as Re,Vr as ze,Vt as Be,Wi as Ve,Wt as He,X as Ue,Xn as We,Xt as Ge,Y as Ke,Yi as qe,Yt as Je,Zi as Ye,Zt as Xe,_n as Ze,_t as Qe,a as $e,an as et,ar as tt,b as nt,bn as rt,bt as it,ca as D,ci as at,cn as ot,ct as st,da as ct,en as lt,et as ut,fn as dt,gn as ft,gt as pt,h as mt,hn as ht,in as gt,ir as _t,jn as vt,jr as yt,k as bt,kn as xt,kt as St,ln as Ct,m as wt,ma as Tt,mn as Et,n as Dt,nn as Ot,oa as kt,on as At,pn as jt,pt as Mt,q as Nt,qt as Pt,ra as Ft,sn as It,ta as Lt,tn as Rt,ua as zt,v as Bt,vt as Vt,wn as Ht,wt as Ut,x as Wt,xn as Gt,xt as Kt,y as qt,yn as Jt,yt as Yt,zi as Xt,zr as Zt}from"./toaster-Dglox5F-.js";import{A as Qt,B as O,F as k,H as A,I as j,N as M,P as N,W as P,Z as F,a as $t,j as I,z as L}from"./live-protocol-CNUmr-VT.js";import{c as en}from"./dist-CCX8mhHc.js";import{t as tn}from"./host-storage-Cr_NKfWy.js";function nn(e,t){return e??t}function rn(e,t){let n=nn(e,t);return n===`1`||n===`true`}function an(e,t,n){return e?.trim()||nn(t,n)||``}var on=class extends Ye{#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||sn(),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=De({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),F.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function sn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var cn=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),zt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Lt(t.mutationKey)!==Lt(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??sn();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){F.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 ln(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function un(e,t,n){let r=e.slice(0);return r[t]=n,r}var dn=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,F.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||!zt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ln(e,n).forEach(e=>{e.destroy()}),ln(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=D(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 qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=un(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)&&F.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},R=e(t(),1);function z({queries:e,...t},n){let r=T(n),i=ae(),a=Ve(),o=R.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ae(e);let t=r.getQueryCache().get(e.queryHash);Re(e,a,t)}),Le(a);let[s]=R.useState(()=>new dn(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(e=>f?s.subscribe(F.batchCalls(e)):kt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),R.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>d(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&d(n,e)?Xt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&oe({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function B(e,t){let n=T(t),[r]=R.useState(()=>new cn(n,e));R.useEffect(()=>{r.setOptions(e)},[r,e]);let i=R.useSyncExternalStore(R.useCallback(e=>r.subscribe(F.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=R.useCallback((e,t)=>{r.mutate(e,t).catch(kt)},[r]);if(i.error&&ct(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function V(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 H(e,t={}){return{...V(t),runId:e}}function fn(){return rn(void 0,void 0)}function U(e){return!fn()&&e}async function pn(e){return l(await _.api.v1.health.$get({},x(e)),`/health`)}async function mn(e){return vt(await _.api.v1.hosts.$get({},x(e)),`/hosts`,we)}async function hn(e){return vt(await _.api.v1.hosts.projects.$get({},x(e)),`/hosts/projects`,re)}async function gn(e){return vt(await _.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},x(e)),`/hosts/runs-index`,ce)}async function _n(e){return l(await _.api.v1.workspace[`ui-state`].$get({},x(e)),`/workspace/ui-state`)}async function vn(e,t={}){return l(await _.api.v1.workspace[`ui-state`].$put({json:e},{init:{...en({keepalive:t.keepalive})}}),`/workspace/ui-state`)}O({runs:j(`summary`).optional()});var yn=P().min(1),bn=L().int().positive(),xn=O({project:yn,seq:bn,run:ze,relationships:P().min(1)}),Sn=O({project:yn,seq:bn,id:P().min(1)}),Cn=O({generation:P().min(1),seq:L().int().nonnegative()}),wn=O({project:yn,usage:A(P(),je)});O({runs:M(f),referenceStatuses:Zt,perProjectLimit:L(),truncated:M(P()),generation:P().min(1),eventSeq:L().int().nonnegative()});function Tn(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=xn.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=Sn.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=wn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=Cn.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var En=[te,Ie,v,h];function Dn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case te:{let e=yt.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 Ie:{let e=u.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 v:{let e=he.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case h:{let e=ve.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function On(){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 kn(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 An(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var jn=Object.freeze({});function Mn(){let e=jn,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 Nn(e){return e.type===`run`?e.run.id:e.id}function Pn(e,t){return{...e,runs:t}}function Fn(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var In=new WeakMap,Ln=new WeakMap;function Rn(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 In.set(e,n),Ln.set(e,r),{positions:n,liveUsage:r}}var zn=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=In.get(e),r=Ln.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=Rn(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=Rn(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&&Ln.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,In.set(this.runs,this.positions),Ln.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}},Bn=e=>e.projectId,Vn=(e,t)=>`${e}\u0000${t}`,Hn=e=>Vn(e.hostId,e.projectId);function Un(e,t,n){let r=new zn(e.runs,Bn),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=Zn(i,e.project,e.usage,r);else{let t=qn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function Wn(e,t,n){let r=new zn(e.runs,Hn),i=e.runs,a=new Set,o=!1;for(let s of t){if(s.type===`usage`){i=Xn(i,Vn(s.hostId,s.project),s.usage,r);continue}let{hostId:t,project:c}=s.change,l=e.hosts.find(e=>e.id===t);if(!l||!l.loaded){a.add(t);continue}let u=n?.(t,c);s.change.type===`run`&&u===!1&&(o=!0);let d=Kn(i,s.change,{scope:Vn(t,c),id:Nn(s.change),inScope:e=>e.hostId===t&&e.projectId===c,truncated:l.truncated.includes(c),perProjectLimit:l.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:c,...e})},r);i=d.runs,d.reconcile&&a.add(t)}return{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:o}}function Gn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kn(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return a?{runs:r.remove(i),reconcile:n.truncated&&a.archived}:{runs:e,reconcile:!1};let{run:o}=t;if(o.delegation?.role===`worker`)return a?{runs:r.remove(i),reconcile:!1}:{runs:e,reconcile:!1};if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=D(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&Fn(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return Yn(e,s,n.inScope,r);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&Fn(c,n.inScope)>n.perProjectLimit}}function qn(e,t,n,r){let{project:i}=t,a=Kn(e.runs,t,{scope:i,id:Nn(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>Gn(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Pn(e,a.runs),reconcile:a.reconcile}}function Jn(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 Yn(e,t,n,r){let i=Jn(e,n),a=i!==void 0&&t.createdAt>i;return t.archived&&!a?{runs:e,reconcile:!1}:{runs:r.insert(t),reconcile:t.archived||i===void 0||t.createdAt<i}}function Xn(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=D(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 Zn(e,t,n,r){let i=Xn(e.runs,t,n,r);return i===e.runs?e:Pn(e,i)}function Qn(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 $n(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function er(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 tr(e){e.stream=void 0}function nr(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Nn(t)]):JSON.stringify([e,t.project,Nn(t)])}function rr(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=nr(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var ir=1e3;function ar(e,t=ir){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 or(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function sr(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function cr(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 lr(e,t,n){if(!sr(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=Un(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 ur(e,t,n){if(!sr(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=Wn(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 dr(e,t,n){if(e.length===0)return t;let r=In.get(e)??Rn(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:D(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function fr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Bn),r=D(e.referenceStatuses,t.referenceStatuses),i=D(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 pr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Hn),r=D(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 mr(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 hr(e,t,n){if(n.size===0)return e;let r=new Map(t.hosts.map(e=>[e.id,e])),i=e.hosts.map(e=>n.has(e.id)?r.get(e.id)??e:e),a=e.runs.filter(e=>!n.has(e.hostId)),o=t.runs.filter(e=>n.has(e.hostId));return{...e,hosts:i,runs:mr(a,o)}}function gr(e,t){if(t.size===0)return e;let n=e.hosts.filter(e=>!t.has(e.id)),r=e.runs.filter(e=>!t.has(e.hostId));return n.length===e.hosts.length&&r.length===e.runs.length?e:{...e,hosts:n,runs:r}}function _r(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=Wn(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);return{index:{runs:mr(e.runs.filter(e=>e.hostId!==n),o.index.runs.filter(e=>e.hostId===n)),hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var vr=[`workspace`,`runs-index`],W=[`main`,`hosts`,`runs-index`],yr=[`workspace`,`projects`],br=[`main`,`hosts`,`projects`],xr=6e4,Sr=100,Cr=new WeakMap,wr=new WeakMap;function Tr(e){let t=Cr.get(e);return t||(t=Ir(e),Cr.set(e,t)),t}function Er(e){let t=wr.get(e);return t||(t=Br(e),wr.set(e,t)),t}function Dr(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Tr(t).merge(e)}function Or(e){let t=e.getQueryData(yr)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function kr(e){let t=e.getQueryData(br)?.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 Ar(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 jr(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 Mr(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 Nr(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,Sr),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Pr(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 Fr(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 Ir(e){let t=$n(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(vr),c=Pr(()=>Fr(e,vr)),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=Or(e),{index:o,reconcile:l}=Un(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=Nr(u),f=t=>{d.markWrite(),e.setQueryData(vr,t)};return{ready(e,n){er(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){tr(t)},run(e,i,a=!1){if(r.has(e))return;let o=jr(e,i);if(!rr(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),or(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=Qn(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=lr(t,n,Or(e));for(let e of r)a.index=Qn(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Ar(i,n,t.stream)??fr(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var Lr=[1e3,2e3,4e3,8e3,15e3],Rr=6e4;function zr(e,t){e.setQueryData(W,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 Br(e,t=e=>gn({hostId:e}),n=Lr,r=Rr){let i=$n(),a=On(),o=new Map,s=new Map,c=new Map,l=new Set,u=new Set,d=[],f=!1,p,m=!1,h=!1,ee=!1,g,_,v=new Set,y=()=>e.getQueryData(W),b=()=>e.getQueryCache().find({queryKey:W,exact:!0}),x=()=>{ee||(ee=!0,e.invalidateQueries({queryKey:br,exact:!0}).finally(()=>{ee=!1}))},te=e=>{let t=c.get(e);t!==void 0&&(clearTimeout(t),c.delete(e))},ne=()=>{for(let e of c.values())clearTimeout(e);c.clear(),s.clear()},S=Pr(()=>b()?(h=!0,Fr(e,W)):Promise.resolve()),re=()=>{if(!f){if(f=!0,p?.()){m=!0;return}S.reconcile({hold:!0})}},ie=t=>{if(zr(e,t),(b()?.getObserversCount()??0)===0)return;let i=s.get(t)??0,a=n[i]??r;s.set(t,i+1),te(t),c.set(t,setTimeout(()=>{c.delete(t),C([t])},a))},ae=(t,n)=>{let r=y();if(!r)return!1;if(n.generation!==r.generation||i.stream!==void 0&&i.stream!==n.generation)return S.reconcile(),!0;let a=o.get(t)??r.eventSeq;if(n.eventSeq<a)return C([t],{hold:!0}),!1;let c=_r(r,n,t,i,kr(e));if(c.fullReconcile)return S.reconcile(),!0;te(t),s.delete(t);let d=b()?.state.fetchStatus===`fetching`||S.isInFlight();c.index.hosts.some(e=>e.id===t)?(o.set(t,n.eventSeq),u.delete(t),d&&l.add(t)):(o.delete(t),l.delete(t),d&&u.add(t));let f=pr(r,c.index);return f!==r&&le(f),!1},oe=(t={})=>{let n=b();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:W,exact:!0,refetchType:`none`}),Promise.resolve();if(!y())return S.reconcile(t)},se=()=>{clearTimeout(g),g=void 0;let e=[...v];if(v.clear(),e.length===0)return Promise.resolve();let n=oe();if(n)return n;let r=(async()=>{for(let n of e)try{let e=await t(n);if(ae(n,e))break}catch{ie(n)}})().finally(()=>{_===r&&(_=void 0,v.size>0&&se())});return _=r,r},C=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=oe(t);if(n)return n;for(let t of e)v.add(t);return _||(t.hold?(g??=setTimeout(()=>{se()},400),Promise.resolve()):se())},ce=()=>{w.cancelPending();let t=d;d=[];let n=y();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=Wn(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=o.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),kr(e));r!==n&&le(r),a&&x(),i.length>0&&C(i,{hold:!0})},w=Nr(ce),le=t=>{w.markWrite(),e.setQueryData(W,t)},T=(e,t,n)=>{let r=new Set(e.map(e=>e.id));for(let e of[...o.keys()])r.has(e)||o.delete(e);for(let r of e){let e=n?o.get(r.id):void 0;o.set(r.id,e===void 0?t:Math.max(e,t))}},ue=(e,t,n)=>{let r=t!==void 0&&t.generation===n.generation,s=new Set,c=[],d=r?new Set(u):new Set;if(r)for(let t of e.hosts){if(d.has(t.id))continue;let e=o.get(t.id),r=l.has(t.id);e!==void 0&&(e>n.eventSeq||r&&e===n.eventSeq)&&s.add(t.id),r&&c.push(t.id)}else o.clear();l.clear(),u.clear(),ne();let f=gr(r&&s.size>0?hr(e,t,s):e,d);return T(f.hosts,n.eventSeq,r),(i.stream===n.generation||i.lastStream===n.generation)&&a.seed(n.eventSeq),{index:pr(t,f),resliceHosts:c,removedHosts:d}};return{ready(e){let t=i.lastStream;er(i,e),f=!1;let n=y(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,o=t===void 0&&(n!==void 0||b()?.state.fetchStatus===`fetching`),s=h&&S.isInFlight();h=!1,r?a.reset():o&&n&&a.seed(n.eventSeq),(r||m||o)&&!s?(m=!1,S.reconcile({hold:!0})):s&&(m=!1)},detach(){tr(i),a.reset(),h=!1},run(e){let t=a.frame(e.seq),n=Mr(e);if(!rr(i,n,t)){re();return}ar(i),d.push({type:`change`,change:n,generation:i.stream}),w.schedule(),t&&S.reconcile({hold:!0})},usage(e,t,n){if(i.stream===void 0){re();return}d.push({type:`usage`,hostId:e,project:t,usage:n,generation:i.stream}),w.schedule()},setUnknownGenerationHandler(e){p=e},merge(t){let n=y(),r=ur(i,t,kr(e)),a=Ar(n,t,i.stream),o=a?{index:a,resliceHosts:[],removedHosts:new Set}:ue(r.index,n,t);if(a&&(l.clear(),u.clear()),r.refreshProjects&&queueMicrotask(x),r.reconcile)queueMicrotask(()=>{S.reconcile({hold:!0})});else{let e=[...new Set([...r.reconcileHosts.filter(e=>!o.removedHosts.has(e)),...o.resliceHosts])];e.length>0&&queueMicrotask(()=>{C(e,{hold:!0})})}return o.index},reconcile:S.reconcile,reconcileHosts:C,reconcileFinite(){let t=y();if(!t)return S.reconcile();let n=e.getQueryData(br)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?S.reconcile():C(r)},flush:ce,stop(){w.cancelPending(),S.stop(),clearTimeout(g),g=void 0,ne(),l.clear(),u.clear(),v.clear(),d=[]}}}function Vr(e,t=!0,n=!1,r){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>ye(V({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function G(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Hr(e,t=!0,n){return E({...Ur(e,n),enabled:t})}var Ur=(e,t)=>({queryKey:Y.models(e,t),queryFn:({signal:n})=>me(e,{signal:n},t),staleTime:300*1e3});function Wr(e,t=!0){let n=z({queries:e.map(e=>({...Ur(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var Gr=I([`own`,`provider-spanning`]),Kr=O({suggested:M(O({id:P(),label:P(),desc:P()})),retired:M(P())}),qr=O({id:I([`settings`,`mcp`,`memory`]),label:P(),note:P().optional(),empty:P().optional(),showsUserMcp:j(!0).optional()}),Jr=O({label:P(),note:P().optional(),groups:M(qr)}),Yr=O({runners:M(O({id:Se,displayName:P(),modelListName:P(),modelIdScope:Gr,pickerLabel:P(),pickerDescription:P(),icon:P(),installHint:P(),loginCommand:P(),terminalLogin:N().optional(),browserLogin:N().optional(),managedInstall:j(!0).optional(),accountFolderExample:P().optional(),models:Kr,agentConfig:Jr}))}),Xr=[`workspace`,`runners`];async function Zr(e){return vt(await Ht.api.v1.runners.$get({},x(e)),`/runners`,Yr)}var Qr={queryKey:Xr,queryFn:({signal:e})=>Zr({signal:e}),staleTime:1/0};function $r(){return E(Qr)}function ei(e){return e?.runners??[]}function ti(e){return ei(e).map(e=>e.id)}function ni(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function ri(e){let t=$r();return{runner:t.isSuccess?ni(e,ti(t.data))??e:e,ready:!t.isPending}}function ii(e,t){return e?.runners.find(e=>e.id===t)}function ai(e,t){return ii(e,t)?.displayName??t}function oi(e,t){return ii(e,t)?.pickerLabel??t}function si(e,t){return ii(e,t)?.modelListName}function ci(e,t,r=!0,i){let a=ao(i,r),o=sa(),{runner:s,ready:c}=ri(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=E({queryKey:J.runnerSkills(s,l,u),queryFn:({signal:e})=>b(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 li={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`}},ui={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function di(e){return typeof e==`string`&&Object.hasOwn(li,e)}function fi(e){return e!==void 0&&di(e)?li[e]:void 0}var pi=`cez.reference-statuses.v1`,mi=`cez.reference-conflicts.v1`,K=new Map(bi()),hi=1e3,q=new Set(xi()),gi=r()??`__local__`;function _i(){let e=r()??`__local__`;if(gi!==e){gi=e,clearTimeout(Si),Si=void 0,K.clear();for(let[e,t]of bi())K.set(e,t);q.clear();for(let e of xi())q.add(e)}}function vi(e,t){if(_i(),K.get(e)!==t){for(K.delete(e),K.set(e,t);K.size>hi;){let e=K.keys().next().value;if(e===void 0)break;K.delete(e)}Ci()}}function yi(e,t){if(_i(),q.has(e)!==t){if(t)for(q.add(e);q.size>hi;){let e=q.values().next().value;if(e===void 0)break;q.delete(e)}else q.delete(e);Ci()}}function bi(){try{let e=globalThis.sessionStorage?.getItem(tn(pi));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`&&di(e[1])):[]}catch{return[]}}function xi(){try{let e=globalThis.sessionStorage?.getItem(tn(mi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Si;function Ci(){if(Si!==void 0)return;let e=tn(pi),t=tn(mi);Si=setTimeout(()=>{Si=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...K])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...q]))}catch{}},250)}var wi=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function Ti(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Ei(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 Di(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;vi(t,o),s!==void 0&&yi(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Oi(e,t,n){_i();let r=wi(t),i=K.get(r),a=q.has(r)?!0:void 0,o=n.data;if(o?.available){Di(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Ti(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Ti(i,a)});return}e.set(r,{state:`loading`,...Ti(i,a)})}function ki(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Ei(i))Oi(n,e,t)}),n}var 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],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:vr,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]};function Ai(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 ji(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 Mi(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 Ni(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 Pi(e,t){return tt({kind:`topic`,topic:e},{value:t})}function Fi(){let e=T();return E({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await It(!1,{signal:t});return Ce(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:U(!1),refetchOnWindowFocus:!0})}function Ii(){let e=T();return B({mutationFn:()=>It(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>Ce(r,e,t)),G(e)}})}function Li(){let e=T();return B({mutationFn:({provider:e,authFailureId:t})=>ft(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>Ce(r,e,t,n.authFailureId)),G(e,n.provider)}})}function Ri(e={}){return E({queryKey:Y.projects,queryFn:({signal:e})=>At({signal:e}),...e})}function zi(e,t=!1){return E({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Je(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Bi(){let e=T();return B({mutationFn:e=>dt(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Vi(){let e=T();return B({mutationFn:e=>Et(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 Hi(){let e=T();return B({mutationFn:e=>{let{id:t,...n}=e;return Gt(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?Ui(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 Ui(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?[]:Ni(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 Wi(e){let t=T();return B({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 Gi(){return Wi(e=>{let{projectId:t,...n}=e;return lt(t,n)})}function Ki(){return Wi(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function qi(){return Wi(({projectId:e,webhookId:t})=>ht(e,t))}function Ji(){return B({mutationFn:({projectId:e,webhookId:t})=>Jt(e,t),retry:!1})}function Yi(e){let t=T();return B({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`}),G(t)])},onError:()=>{t.invalidateQueries({queryKey:J.health}),t.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function Xi(){return Yi(e=>ke(e))}function Zi(){return Yi(e=>{let{id:t,...n}=e;return rt(t,n)})}function Qi(){return Yi(e=>jt(e))}function $i(){return Yi(e=>Ze(e))}function ea(e,t){return E({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>Rt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function ta(){let e=T();return B({mutationFn:({provider:e,profileId:t})=>Xe(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),G(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:J.health}),e.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function na(){let e=T();return B({mutationFn:e=>Rt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),G(e,t.status.provider)}})}function ra(){let e=T();return B({mutationFn:e=>Ge(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ia(){let e=T();return B({mutationFn:e=>s(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function aa({enabled:e}){return E({queryKey:Y.githubOwners,queryFn:({signal:e})=>gt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function oa(){let e=T();(0,R.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(J.health);n&&(Oe({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:i()}),t??=Pi(`health`,t=>{e.setQueryData(J.health,t)}))};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.(),_t()}},[e])}function sa(){return E({queryKey:J.health,queryFn:({signal:e})=>et({signal:e})})}function ca(e,t){let n=sa().data,r=Ri(t).data?.projects,i=$e(),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)?Ai(n?.repo?.remote):void 0}function la(e=!0){return E({queryKey:Y.uiState,queryFn:({signal:e})=>Ct({signal:e}),enabled:e})}function ua(){return E({queryKey:Y.config,queryFn:({signal:e})=>ot({signal:e})})}function da(){return E({queryKey:Y.agentProfiles,queryFn:({signal:e})=>Ot({signal:e})})}var fa=[`workspace`,`runs-index`],X=e=>[e.cacheScope,`runs`,`list`],Z=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:[`host`,e.hostId,e.projectId,`runs`,`detail`,e.runId],Q=e=>typeof e==`function`?e():e;function pa(e){let{seenAt:t,...n}=e;return n}function ma(e,t){let n=pa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function ha(e,t,n){return t?{...e,seenAt:n}:pa(e)}function ga(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 _a(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 va(e){let t=()=>{e.invalidateQueries({queryKey:fa})};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 s=o(),c=[a.projectId,a.cacheScope],l=s!==void 0&&c.some(e=>e===s||e==="default")?[s,`default`]:[],u=new Set([...c,...l,n()]);return Promise.all([...u].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?ha(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(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(Z(t)),l=e.getQueryData(W)?.runs.find(o);return e.setQueryData(Z(t),e=>e&&ha(e,n,a)),s(e=>ha(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(Z(t),e=>e&&ma(e,c)),l&&s(e=>ma(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(Z(t),e=>e?o(e):a),s(o)}}}async function s(n,r){let o=Q(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:X(Q(n))}),await e.cancelQueries({queryKey:Z(Q(n))});let s=e.getQueryData(X(Q(n))),c=e.getQueryData(Z(Q(n))),l=Q(n).runId,u=new Date().toISOString();return e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?ha(e,r,u):e)),e.setQueryData(Z(Q(n)),e=>e&&ha(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(X(Q(n)),s),c&&e.setQueryData(Z(Q(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?ma(e,t):e)),c&&e.setQueryData(Z(Q(n)),e=>e&&ma(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(X(Q(n)),e=>e?.map(o));let s={...Q(n),runId:r?l:a.id};e.setQueryData(Z(s),e=>e?o(e):a),t()}}}async function c(t,n){if(t.hostId!==void 0){let r=e.getQueryData(W),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?_a(i,o):[];return e.setQueryData(W,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(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ga(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:fa});let i=e.getQueryData(fa),a=n();return e.setQueryData(fa,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(fa,i)},settle(){r(`indexed`,t)}}}return{patchRead:s,patchIndex:c,invalidateAfter:r}}function $(){let e=T();return(0,R.useMemo)(()=>va(e),[e])}function ya(e,t){if(!$t(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),tt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ba(e,t,n,r){let i=T(),a=JSON.stringify(t),o=(0,R.useMemo)(()=>JSON.parse(a),[a]);(0,R.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=ya({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 xa(e,t=!1){return l(await Ht.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),xt(e,`/worker-destroy`))}function Sa(){return E({queryKey:J.openTargets,queryFn:({signal:e})=>Kt({signal:e}),staleTime:5*6e4})}function Ca(e=!0,t){return E({queryKey:t?J.runs.list(t):J.runs.list(),queryFn:({signal:e})=>ye(V(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function wa(e,t){return C({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 Ta(e){let t=e.trim();return E({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>fe(t,{signal:e}),enabled:t.length>=2,placeholderData:Ft,staleTime:1e4})}function Ea(e=!0,t=xr,n){let r=Tr(T());return ba(`/api/v1/workspace/runs-index`,Y.runsIndex,U(e?t:!1),Dr),E({queryKey:Y.runsIndex,queryFn:({signal:e})=>Te({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Da(e){let t=T();return B({mutationFn:({workerId:e,discardWork:t=!1})=>xa(e,t),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Oa(e,t={}){return E({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function ka(e){return E({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Pe(H(e),{signal:t}),enabled:!!e})}function Aa(e,t,n=!0,r){let i=r?.hostId;return E({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:[`host`,i,e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Pe(H(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 ja(e,t){return E({queryKey:t?[t,`runs`,`diff`,e??``]:J.runs.diff(e??``),queryFn:({signal:n})=>y(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function Ma(e,t=!1){return ba(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),U(t?4e3:!1)),E({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>ee(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Na(e,t){return E({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>xe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Pa(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>it(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fa(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Qe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ia(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Vt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function La(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Yt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ra(e,t=!1){return ba(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),U(t?5e3:!1)),E({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function za(e,t){return E({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ut(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Ba(e,t=!0){return E({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>St(H(e),{signal:t}),enabled:!!e&&t})}function Va(e,t,n,r){return E({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})=>St(H(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function Ha(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ua(e,t){let r=new Map;for(let t of e){let e=Ha(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=z({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Bt({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,R.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 Wa(e){let t=T();return B({mutationFn:t=>w(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ga(e){let t=T();return B({mutationFn:t=>Be(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ka(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=B({mutationFn:e=>ue(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,R.useCallback)(e=>({...H(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,R.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,R.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,R.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function qa(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return B({mutationFn:e=>ue(H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ja(e){let t=$();return B({mutationFn:({id:t,pinned:n})=>se(H(t,e),n),onError:e=>Dt(`Could not update pin. ${Fe(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??V(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ya(e,t,n){let r=$();return B({mutationFn:r=>Pt(H(e,{projectId:t,hostId:n}),r),onMutate:()=>V({projectId:t,hostId:n}),onSuccess:(e,t,n)=>r.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof m&&e.status===409&&n&&r.invalidateAfter(`send`,n)}})}function Xa(e,t,n){let r=$();return B({mutationFn:(r={})=>st(H(e,{projectId:t,hostId:n}),r),onMutate:()=>V({projectId:t,hostId:n}),onSuccess:(e,t,n)=>r.invalidateAfter(`continue`,n)})}function Za(e){let t=T();return B({mutationFn:({msgId:t,message:n})=>Mt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Qa(e){let t=T();return B({mutationFn:t=>He(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function $a(){return E({queryKey:J.workflows,queryFn:({signal:e})=>bt({signal:e})})}function eo(e){return E({queryKey:e?[e,`repo`]:J.repo,queryFn:({signal:t})=>nt({signal:t},e)})}function to(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function no(){return E({queryKey:J.repoBranches,queryFn:({signal:e})=>Wt({signal:e})})}function ro(){return E({queryKey:J.repoChanges,queryFn:({signal:e})=>Me({signal:e}),retry:!1})}function io(e){return E({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>p(e,{signal:t}),enabled:!!e,retry:!1})}function ao(e,t=!0){return E({queryKey:e?[e,`config`]:J.config,queryFn:({signal:t})=>qt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function oo(){return E({queryKey:J.worktrees,queryFn:({signal:e})=>c({signal:e})})}function so(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>c({signal:t},e),staleTime:0})}function co(e,t=!0,n=!1){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>be({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:We(e.sidebarLimits)},enabled:t})}function lo(e=!0,t){return co(t??n(),e)}function uo(){return E({queryKey:J.agentConfig,queryFn:({signal:e})=>wt({signal:e})})}function fo(e){return E({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>mt(e,{signal:t}),enabled:e!==null})}function po(){return E({queryKey:J.sessionContext,queryFn:({signal:e})=>g({signal:e})})}function mo(e,t,n=``){return E({queryKey:J.sessionContextPreview(e,t,n),queryFn:({signal:n})=>_e({content:e,role:t},{signal:n}),placeholderData:Ft,staleTime:0,retry:!1})}function ho(){let e=T();return B({onMutate:()=>({fileKey:J.sessionContext}),mutationFn:e=>pe(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function go(e){let t=T(),n=J.agentConfig,r=J.agentConfigFile(e);return B({mutationFn:t=>S(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var _o=I([`passing`,`failing`,`pending`]).nullable(),vo=O({kind:I([`issue`,`pr`]),number:L(),title:P(),author:P(),createdAt:P(),labels:M(P()),body:P().optional(),url:P(),comments:L(),assignees:M(P()).optional(),projectIds:M(P()).optional(),isDraft:N().optional(),additions:L().optional(),deletions:L().optional(),checks:_o.optional()});k(`available`,[O({available:j(!0),item:vo.nullable(),labelColors:A(P(),P()).optional()}),O({available:j(!1),reason:P()})]),O({kind:I([`issue`,`pr`]),number:Qt().int().positive().safe()});var yo=O({id:P(),title:P(),url:P()});O({available:N(),reason:P().optional(),repo:P().optional(),syncedAt:P().optional(),issues:M(vo),prs:M(vo),labelColors:A(P(),P()).optional(),viewerLogin:P().optional(),projects:M(yo).optional(),projectsReason:P().optional(),projectsState:I([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:P().optional(),issuesTotal:L().int().nonnegative().optional(),prsTotal:L().int().nonnegative().optional(),issuesNextCursor:P().nullable().optional(),prsNextCursor:P().nullable().optional(),commentsDeferred:j(!0).optional()});var bo=P().min(1).max(2e3).optional();O({limit:P().optional(),refresh:P().optional(),issuesCursor:bo,prsCursor:bo,issuesDone:j(`1`).optional(),prsDone:j(`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`})}),O({kind:I([`issue`,`pr`]),numbers:P().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:j(`1`).optional()}),k(`available`,[O({available:j(!0),counts:A(L(),L().int().nonnegative())}),O({available:j(!1),reason:P()})]),k(`available`,[O({available:j(!0),checks:A(L(),_o)}),O({available:j(!1),reason:P()})]),O({kind:I([`issue`,`pr`]),q:P().trim().min(1).max(256),limit:Qt().int().positive().max(50).optional()}),O({available:N(),projectsReason:P().optional(),reason:P().optional(),items:M(vo),truncated:N().optional(),labelColors:A(P(),P()).optional()});var xo=L().nullable();k(`available`,[O({available:j(!0),prs:A(L(),at),issues:A(L(),at),conflicts:M(L()).optional(),recheckAfterMs:xo}),O({available:j(!1),reason:P(),recheckAfterMs:xo})]);var So=O({id:L(),author:P(),avatarUrl:P().optional(),createdAt:P(),body:P(),kind:I([`comment`,`review`]),reviewState:I([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:P()}),Co=I([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),wo=O({id:P(),kind:Co,actor:P(),avatarUrl:P().optional(),createdAt:P(),url:P().optional(),sha:P().optional(),message:P().optional(),checks:_o.optional(),label:O({name:P(),color:P().optional()}).optional(),subject:P().optional(),refNumber:L().optional(),refTitle:P().optional(),refIsPr:N().optional()});O({available:N(),reason:P().optional(),comments:M(So),truncated:N().optional(),events:M(wo).optional(),detail:O({body:P(),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional()}).optional()});var To=I([`merge`,`squash`,`rebase`]),Eo=O({name:P(),state:I([`passing`,`failing`,`pending`,`unknown`]),required:N().nullable(),url:P().optional()}),Do=O({number:L(),title:P(),url:P(),state:I([`open`,`closed`,`merged`]),isDraft:N(),headRef:P(),baseRef:P(),headSha:P(),mergeable:I([`mergeable`,`conflicting`,`unknown`]),reviewDecision:I([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:M(Eo),methods:M(To),defaultMethod:To.nullable(),eligibility:I([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:M(O({code:P(),message:P()})),canMerge:N(),canOverride:N()});k(`available`,[O({available:j(!0),mergeState:Do}),O({available:j(!1),reason:P()})]),O({merged:j(!0),number:L(),url:P(),method:To,mergeCommitSha:P().optional()});var Oo=O({path:P(),previousPath:P().optional(),status:I([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:L(),deletions:L(),patch:P().optional(),patchUnavailableReason:I([`binary`,`too-large`,`not-provided`]).optional(),truncated:N().optional()});k(`available`,[O({available:j(!0),number:L(),headSha:P(),files:M(Oo),additions:L(),deletions:L(),truncated:N(),reason:P().optional()}),O({available:j(!1),reason:P()})]),O({generation:P().uuid()}),k(`state`,[O({generation:P().uuid(),state:j(`ready`),projects:M(yo),membership:A(P(),M(P()))}),O({generation:P().uuid(),state:j(`unavailable`),reason:P()})]);function ko(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 Ao(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function jo(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Mo(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){jo(t.issues,a,r),jo(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:p,...m}=t;return{...m,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 No=e=>e.map(e=>e.number).join(`,`);function Po(e,t){let n=e[0];if(e.length>1&&n&&(No(n.issues)!==No(t.issues)||No(n.prs)!==No(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 Fo=class extends Error{};function Io(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ie({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Fo(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>ko(e),retry:(e,t)=>!(t instanceof Fo)&&!(t instanceof m&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Lo(e=50,t=!0){let r=T(),i=J.githubPages(e),a=J.githubPagesHead(e);ba(`/api/v1/p/${n()}/github?limit=${e}`,a,U(t?6e4:!1));let o=C({...Io(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=E({queryKey:a,queryFn:({signal:t})=>ie({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,R.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=Po(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=z({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,R.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,R.useMemo)(()=>Mo(o.data?.pages??[]),[o.data])}}function Ro(e,t=50,n=!0){let r=C({...Io([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,R.useMemo)(()=>Mo(r.data?.pages??[]),[r.data])}}function zo(e,t,n=!0){let r=z({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>Nt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,R.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 Bo(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ut(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Vo(e,t=!0){return E({queryKey:J.githubChecks(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Ho(e,t,n=!0){return E({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>ut(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Uo=100;function Wo(e){return[...e].sort((e,t)=>t-e).slice(0,Uo).sort((e,t)=>e-t)}function Go(){let e=$e(),t=sa();return e.projectId??t.data?.bootProject??void 0}function Ko(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))vi(wi({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))vi(wi({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var qo=5*6e4;function Jo(e){return e?e.recheckAfterMs:qo}function Yo(e,t=!0){let n=(0,R.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:Wo(e.prs),issues:Wo(e.issues)}))},[e.map(wi).sort().join(`|`)]),r=z({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=>Jo(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>U(t&&!fn()?Jo(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=T(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:Jo(r[t]?.data)??!1}]:[]));(0,R.useEffect)(()=>{if(!t||fn())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 ya({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,R.useMemo)(()=>ki(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,R.useCallback)(e=>{let t=wi(e),n=s.get(t);if(n)return n;let r=K.get(t);return{state:`idle`,...r?{status:r}:{},...q.has(t)?{conflicting:!0}:{}}},[s])}function Xo(e,t,n=!0){return E({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zo(e,t,n=!0){return E({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>Ke(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Qo(e){return E({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>Ue(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Na as $,ri as $t,oo as A,$i as At,Ka as B,Ai as Bt,no as C,fn as Cn,na as Ct,mo as D,z as Dn,Vi as Dt,po as E,B as En,Qi as Et,Ua as F,ua as Ft,Ja as G,ci as Gt,Wa as H,Y as Ht,Xa as I,la as It,ka as J,ei as Jt,Aa as K,ni as Kt,Da as L,Pi as Lt,Fa as M,Zi as Mt,Ia as N,Hi as Nt,lo as O,on as On,qi as Ot,La as P,Ki as Pt,ja as Q,oi as Qt,Za as R,ji as Rt,eo as S,U as Sn,Fi as St,io as T,H as Tn,Bi as Tt,Sa as U,ui as Ut,qa as V,J as Vt,Ga as W,fi as Wt,za as X,ti as Xt,Ma as Y,ii as Yt,Ra as Z,si as Zt,to as _,mn as _n,aa as _t,Zo as a,W as an,Ya as at,go as b,_n as bn,ca as bt,Ho as c,jn as cn,$ as ct,Go as d,kn as dn,ra as dt,$r as en,Ba as et,Yo as f,Mn as fn,ta as ft,ao as g,pn as gn,zi as gt,fo as h,Tn as hn,Gi as ht,Xo as i,Vr as in,Ta as it,wa as j,Ji as jt,$a as k,an as kn,Li as kt,Ro as l,En as ln,ea as lt,uo as m,Dn as mn,ia as mt,Vo as n,Wr as nn,Ca as nt,Lo as o,Er as on,Va as ot,Ao as p,On as pn,Xi as pt,Qa as q,ai as qt,zo as r,Hr as rn,Ea as rt,Qo as s,Tr as sn,ya as st,Ko as t,G as tn,Oa as tt,Bo as u,An as un,da as ut,co as v,hn as vn,sa as vt,ro as w,V as wn,Ii as wt,ho as x,vn as xn,Ri as xt,so as y,gn as yn,oa as yt,Pa as z,Mi as zt};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{B as i,Cn as a,En as o,J as s,L as c,R as l,Tn as u,Vt as d,W as f,at as p,bt as m,ct as h,en as g,g as _,nt as v,q as y,qt as b,rn as x,tt as S,ut as C,vt as w,wn as T}from"./queries-CAsaqjt8.js";import{Ci as E,Cn as D,Di as O,Gr as k,Ji as A,Li as ee,Mi as j,Ni as M,Nt as N,Oi as P,Si as F,Ti as te,Wr as I,at as L,ct as R,dt as z,ki as B,n as V,ot as H,vr as U,wi as ne,yi as re}from"./toaster-Dglox5F-.js";import{g as W,n as ie,p as ae}from"./chunk-KS7C4IRE-BdLLx37K.js";import{O as oe,_ as se,d as ce,i as le,o as ue,t as de,w as fe,x as pe}from"./reference-chip-CW8i_sq3.js";import{o as G,s as me}from"./dist-CCX8mhHc.js";import{A as he,B as ge,V as K,_ as _e,b as ve,c as ye,ct as be,d as xe,ft as Se,g as Ce,h as we,j as Te,m as Ee,n as De,o as Oe,ot as ke,p as Ae,u as je}from"./design-icons-QbNMZniQ.js";import{t as Me}from"./createLucideIcon-BHp8sXmF.js";import{A as Ne,C as Pe,D as Fe,E as Ie,F as Le,I as Re,L as ze,M as Be,N as Ve,O as He,P as Ue,R as We,S as Ge,T as Ke,_ as qe,a as Je,b as Ye,c as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,j as nt,k as rt,l as it,m as at,n as ot,o as st,p as ct,r as lt,s as ut,t as dt,u as ft,v as pt,w as mt,x as ht,y as gt,z as _t}from"./ask-card-Dc1pCn2B.js";import{a as vt,i as yt,n as bt,o as xt,r as St,s as Ct,t as wt}from"./run-header-CZkXDDXM.js";import{t as Tt}from"./eye-B8okNWXU.js";import{t as Et}from"./loader-circle-CPBhhDbB.js";import{a as Dt}from"./tool-display-CTbToGmi.js";import{t as Ot}from"./search-x-I9Q8pgUa.js";import{t as kt}from"./preview-B5bPk6HT.js";import{t as q}from"./button-BV_AiLj2.js";import{n as At,r as jt,t as Mt}from"./collapsible-D5i3hm2L.js";import{a as Nt,i as Pt,o as Ft,r as It,t as Lt}from"./popover-BQolmvDR.js";import{s as Rt,t as zt}from"./project-router-CPgPVoBJ.js";import"./attention-CFW302LY.js";import{A as Bt,C as Vt,D as Ht,T as Ut,f as Wt,j as Gt,k as Kt,m as J,w as qt}from"./task-groups-D4siwI6y.js";import"./read-state-D9a4i8-k.js";import{t as Y}from"./status-dot-DuorWA5M.js";import{c as Jt,i as Yt,l as Xt,o as Zt,r as Qt,s as $t,t as en}from"./report-selection-CJ-q2Dc5.js";import{l as tn,m as nn}from"./page-shell-BdjH5hyc.js";import{i as rn,t as an}from"./agent-accounts-DKK4W3xn.js";import{t as on}from"./centered-state-N8vWM_Hw.js";import{An as sn,B as cn,Fn as ln,I as un,L as dn,Nn as fn,Q as pn,R as mn,Sn as hn,Tn as gn,Un as _n,Vn as vn,Wn as yn,X as bn,Z as xn,_n as Sn,b as Cn,bn as wn,c as Tn,ir as En,l as Dn,m as On,mn as kn,n as An,nt as jn,o as Mn,pn as Nn,r as Pn,tt as Fn,un as In,v as Ln,vn as Rn,w as zn,yn as Bn,z as Vn}from"./index-C_yV_XCP.js";import{t as Hn}from"./markdown-WuLAJnyd.js";import{t as Un}from"./task-file-scope-jCHWm0DC.js";import{t as Wn}from"./run-diff-6l-f4FRx.js";import{n as Gn,t as Kn}from"./use-finish-run-DEFzV087.js";import{i as qn}from"./automation-format-jKMOXcHS.js";import{a as Jn,i as Yn,n as Xn,o as Zn,r as Qn,t as $n}from"./thread-state-B8eN7DGY.js";var er=Me(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),X=e(t(),1),Z=r();function tr(e,t,n,r,i,a,o,s,c){let l=Gt(e,kn(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=mn(t,o,a,[p,f?.[t]]),h=cn(p,t,o,f,a),g=dn(h,a),_=r?``:c??d??``,v=Vn(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function nr(e,t,n,r){let i=Kt(e.steps),a=Gt(e,kn(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function rr(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function ir(e,t,n,r){return!!t&&(r!==Bt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function ar({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`Runner default`,effortLabel:n.find(e=>e.value===r)?.label??`Runner default`}}function or(e){let t=h(),n=wn(e).continueRun,r=_(),[i,a]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,d]=(0,X.useState)(null),f=`${e.id}:${Gt(e,kn(e))?.id??``}`,[p,m]=(0,X.useState)(f);p!==f&&(m(f),a(null),c(null),d(null));let v=Gn(e,i),{runners:y,canContinue:S,currentRunner:C,runner:T}=v,{sessionStep:E,workerStep:O,account:k}=nr(e,T,T!==C,rn().repoAccount),A=w(),ee=A.data?.capabilities?.localHandoff!==!1,j=g(),M=x(T,n&&!A.isPending&&!j.isPending,ee?k:null),N=r.data?.modelsLocked===!0,P=T!==C,F=tr(e,T,P,N,r.data,M.data,j.data,s,l),{models:te,model:I,effortOptions:L,effort:z}=F,{modelLabel:B,effortLabel:V}=ar(F),H=o({mutationFn:({text:t,images:n})=>S?R(u(e.id),rr(t,n,v.runnerOverride,N,P,s,l,F)):Promise.reject(Error(v.reason??`Connect an agent provider to continue.`)),onMutate:()=>u(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof D&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),U=e.delegation?.role===`worker`,ne=nn();return{skillRunner:T,skillAccount:k,available:n,canContinue:S,startsNewConversation:ir(e,E,O,T),reason:v.reason,providerPending:v.providerPending,pills:(0,Z.jsx)(sr,{compact:!ne||e.status===`review`,summary:`${b(j.data,T)} · ${B} · ${V}`,children:(0,Z.jsxs)(xn,{children:[!U&&(y.length>1||v.signedOut.length>0)?(0,Z.jsx)(pn,{icon:(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:y,signedOut:v.signedOut,value:T,onPick:e=>{e!==T&&(a(e),c(null))}}):(0,Z.jsx)(bn,{icon:(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:U?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:T,value:T,onPick:()=>{},options:[{value:T,label:T}]}),(0,Z.jsx)(bn,{icon:(0,Z.jsx)(ve,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:B,value:I,readOnly:N,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{c(e);let t=dn(e,M.data);z!==``&&Vn(z,t)===``&&d(``)},options:te.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:un(T,j.data,M)}),(0,Z.jsx)(bn,{icon:(0,Z.jsx)(he,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:V,value:z,readOnly:N,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>d(e),options:L.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},f),continueWith:(e,t)=>H.mutateAsync({text:e,images:t})}}function sr({compact:e,summary:t,children:n}){let[r,i]=(0,X.useState)(!1),a=jn(),[o,s]=(0,X.useState)(a);a!==o&&(s(a),a&&i(!1));let c=(0,X.useRef)(null),l=e&&!r;return(0,X.useEffect)(()=>{r&&(c.current?.querySelector(`button:not([disabled])`)??c.current)?.focus()},[r]),(0,Z.jsx)(`div`,{ref:c,"data-slot":`follow-up-engine`,"data-folded":l||void 0,tabIndex:l?void 0:-1,className:l?`min-w-0`:`session-engine-controls outline-hidden`,children:l?(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`follow-up-engine-summary`,"aria-expanded":!1,"aria-label":`Agent settings: ${t}`,title:`Change the runner, model or effort`,onClick:()=>i(!0),className:`inline-flex min-h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground transition-colors outline-hidden hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(je,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var cr=120,lr=e=>e!==`pending`&&e!==`running`,ur=e=>e.kind===`tool`&&e.toolKind===`task`,dr=e=>ur(e)&&e.parentItemId===void 0,fr=e=>Ve(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function pr(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function mr(e){if(e.kind===`tool`)return hr(e.title);if(e.kind===`hook`)return hr(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
2
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return hr(n)}}}function hr(e){return e.length>cr?`${e.slice(0,cr-1).trimEnd()}…`:e}function gr(e,t=!1,n=e){let r=br(e,e=>e.items.some(dr));if(r===-1)return[];let i=e=>!t&&!lr(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(dr);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(dr)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>_r(r,wr(n,e,r.id),t))}function _r(e,t,n){let r={id:e.id,title:Be(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=pr(e);i!==void 0&&(r.agentType=i),n&&!lr(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=mr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function vr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function yr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function br(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function xr(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&dr(e));if(a!==void 0)return _r(a,wr(r,e,t),n)}}function Sr(e,t){return br(e,e=>e.items.some(e=>e.id===t&&dr(e)))}function Cr(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)fr(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function wr(e,t,n){let r=Sr(t,n);if(r===-1)return[];let i=Cr(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of Cr(e,n,Math.max(Sr(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:Tr(t,e))}return[...s.values()].sort(Er).map(({entry:e})=>e)}function Tr(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function Er(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function Dr(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?nt(e.children).flatMap(n=>Dr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>Dr(e,t)):[]}function Or(e){return e.flatMap((e,t)=>e.content.kind===`block`?Dr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function kr(e,t,n,r){let i=(0,X.useContext)(en),{projectId:a}=W(),o=(0,X.useMemo)(()=>Or(t),[t]);(0,X.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=ze(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=Re(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function Ar(e){let t=A();return o({mutationFn:t=>z(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:d.runs.all})}})}var jr=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),Mr=()=>navigator.onLine;function Nr({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,Z.jsx)(Fr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,Z.jsx)(Pr,{permission:e,runId:t},e.requestId)}function Pr({permission:e,runId:t}){let n=Ar(t),r=(0,X.useSyncExternalStore)(jr,Mr,()=>!1),i=(0,X.useRef)(!1),[a,o]=(0,X.useState)(`pending`),[s,c]=(0,X.useState)(),[l,u]=(0,X.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof D&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,Z.jsx)(Fr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Fr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,X.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,Z.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-card-edge bg-card shadow-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,Z.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,Z.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,Z.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`block`,disabled:s,"aria-pressed":e.optionId===t.id,className:`min-w-0 py-2 [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,Z.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}var Ir=(0,X.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Lr(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function Rr(e,t,n=[]){let r={};for(let e of n)r[e.id]=J(e);for(let e of t??[])r[e.id]=J(e);return r[e.id]=J(e),r}function zr(e,t){return t?.[e]??`Task`}function Br(e,t,n){return t?n?.[e]??`peer task`:zr(e,n)}function Vr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function Hr(e){return e?.relationship===`peer`}function Ur(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Wr(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;case`deleted`:return`Recipient deleted`}}function Gr(e){if(e.outcome)return Wr(e.outcome.status);if(e.delivery===`not-delivered`)return Kr(`not-delivered`)}function Kr(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function qr(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?Hr(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${gn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Jr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:zr(e,n),linkable:!0}):(0,Z.jsx)(Yr,{id:e,children:r})}function Yr({id:e,children:t}){let n=s(e);return n.data?t({title:J(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof D&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Xr={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},Zr=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function Qr({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,Z.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,Z.jsx)($r,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function $r({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Vr(e.messages[0]??{senderRunId:e.senderRunId},t),a=Hr(e.messages[0]),o=Xr[a?`peer`:i],s=ci(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),c=i===`outbound`?`SENT to`:`RECEIVED from`,l=`${c} ${s.map(e=>Br(e,a,n)).join(`, `)}`,u=e.messages[0],d=u?.createdAt??u?.recordedAt;return(0,Z.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-relationship":a?`peer`:`family`,"data-kind":e.kind,className:G(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes),children:[(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`p`,{className:G(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,Z.jsx)(`span`,{children:c}),s.map((e,t)=>(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,Z.jsx)(Jr,{id:e,peer:a,taskTitles:n,children:t=>(0,Z.jsx)(ii,{view:t,to:`/tasks/${e}`,label:`${c} ${t.title}`})})]},e))]}),a?(0,Z.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,Z.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:Ur(e.kind)}),e.messages.length===1&&u?(0,Z.jsx)(ti,{message:u}):null]}),(0,Z.jsx)(ei,{at:d,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-xs text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,Z.jsx)(ri,{batch:e},`${t}:${u?.messageId??e.id}`),[...new Set(e.messages.map(e=>qr(e,r?.[e.recipientRunId])))].map(e=>e?(0,Z.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,Z.jsx)(ni,{messages:e.messages,peer:a,runId:t,taskTitles:n}):null,e.messages.length===1&&u?(0,Z.jsx)(ai,{message:u,runId:t,taskTitles:n}):null,(0,Z.jsx)(oi,{batch:e,heading:l})]})}function ei({at:e,className:t,children:n}){return e===void 0||qe(e)===void 0?null:(0,Z.jsxs)(`span`,{className:t,children:[n,(0,Z.jsx)(et,{ts:e})]})}function ti({message:e}){let t=Gr(e),n=Kr(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,Z.jsxs)(Z.Fragment,{children:[t?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function ni({messages:e,peer:t,runId:n,taskTitles:r}){return(0,Z.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Gr(e),a=e.createdAt??e.recordedAt;return(0,Z.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Jr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,Z.jsx)(ii,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,Z.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Kr(e.delivery)===i?null:(0,Z.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Kr(e.delivery)}),(0,Z.jsx)(ai,{message:e,runId:n,taskTitles:r}),(0,Z.jsx)(ei,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function ri({batch:e}){let t=Ne(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,X.useState)(()=>t?.get(n)??!1),a=(0,Z.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,Z.jsx)(Hn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,Z.jsxs)(Mt,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,Z.jsxs)(jt,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,Z.jsx)(At,{children:a})]})}function ii({view:e,to:t,label:n}){return e.linkable?(0,Z.jsx)(zt,{className:Zr,to:t,"aria-label":n,children:e.title}):(0,Z.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function ai({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,X.useContext)(Ir),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,Z.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Vr(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:G(Zr,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,Z.jsx)(Jr,{id:i,peer:Hr(e.message),taskTitles:n,children:e=>(0,Z.jsxs)(Z.Fragment,{children:[`View `,c,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function oi({batch:e,heading:t}){return(0,Z.jsxs)(Mt,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,Z.jsxs)(jt,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,Z.jsx)(At,{children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-xs text-muted-foreground`,children:[(0,Z.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>si(e)).map((e,t)=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,Z.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function si(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...Hr(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Kr(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function ci(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var li=e(n(),1),ui=`pending-ask`;function di(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function fi(e,t){if(e.dataset.askMode===`reply`){let n=(t??e.closest(`[data-slot="thread-dock"]`)??document).querySelector(`[data-slot="thread-composer-slot"]:not([hidden]) textarea:not(:disabled)`);if(n)return n}return di(e)}function pi(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?fi(t,e):null}function mi(e,t){let n=`${ui}:${e}`;return r=>{if(!t())return!1;let i=[...r.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);if(i)return pi(i);let a=[...r.querySelectorAll(`[data-slot="ask-card"][data-pinned="true"]`)].find(t=>t.dataset.askId===e);return a?fi(a,r):null}}function hi(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function gi({onGoToQuestion:e}){return(0,Z.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}function _i(){let e=(0,X.useRef)(null);return(0,X.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.closest(`[data-slot="main"]`),r=t.querySelector(`[data-slot="run-header"]`),i=t.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),a=r.getBoundingClientRect(),o=getComputedStyle(document.documentElement),s=document.documentElement.style.getPropertyValue(`--kb`)||(typeof o.getPropertyValue==`function`?o.getPropertyValue(`--kb`):``),c=Number.parseFloat(s)||0;n.clientHeight>0&&n.clientHeight<420?t.dataset.compactViewport=`true`:delete t.dataset.compactViewport,c>0||Nt(window)?t.dataset.keyboardOpen=`true`:delete t.dataset.keyboardOpen,r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-a.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${vi(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),delete t.dataset.compactViewport,delete t.dataset.keyboardOpen,r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function vi(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var yi={viewKey:void 0,generation:0},bi=600,xi=24;function Si(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:o=[]}=t,s=(0,X.useRef)(o);s.current=o;let c=(0,X.useRef)(e);c.current=e;let l=(0,X.useRef)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),m=(0,X.useRef)(!0),h=(0,X.useRef)(!0),g=(0,X.useRef)(0),_=(0,X.useRef)(0),v=(0,X.useRef)(new Set),y=(0,X.useCallback)(e=>{for(let t of[...v.current])t(e)},[]),b=(0,X.useCallback)(e=>(v.current.add(e),()=>{v.current.delete(e)}),[]),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(e=>{let t=l.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,X.useCallback)(()=>{let e=l.current;if(!e)return;let t=h.current?s.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=h.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?vi(r):0;n?T(e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top-i-12):t>=0&&w.current?w.current.scrollToIndex(t,{align:`start`,offset:-i-12}):T(e.scrollHeight-e.clientHeight)},[T]),D=(0,X.useCallback)(()=>{if(l.current){if(C.current!==e){C.current=e,h.current=!0;let t=mt(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=Ge(e)?.rowKeys?{viewKey:e,top:t.top}:null):(m.current=!0,x.current=null,S.current=null)}x.current===null?m.current&&E():T(x.current)}},[e,T,E]),O=(0,X.useCallback)(e=>S.current?.viewKey===e,[]),k=(0,X.useCallback)(e=>{let t=S.current;return!t||!O(e)||e!==c.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),A=(0,X.useCallback)(e=>{d(e),e&&(l.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="thread-transcript"], [data-slot="main"]`),D())},[n,D]),ee=(0,X.useCallback)(()=>{m.current&&E()},[E]),j=(0,X.useRef)(!1),M=(0,X.useRef)(0),N=(0,X.useRef)(!1),P=(0,X.useRef)(void 0),F=(0,X.useRef)(!1),te=(0,X.useRef)(!1),I=(0,X.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),L=(0,X.useRef)(null),R=(0,X.useRef)(0);(0,X.useEffect)(()=>{if(!a())return;let e=e=>{x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let z=(0,X.useCallback)(()=>{let e=L.current,t=l.current;if(!e||!t)return;L.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:s.current.indexOf(e.anchor.key),a=w.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):T(Fe(t.scrollTop,r,e.anchor,I(t),n))},[I,T]),B=(0,X.useCallback)(()=>{let e=l.current;if(!e||!r||j.current)return;x.current=null,S.current=null,m.current=!1,j.current=!0;let t=M.current+1;M.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,o=gt(a,I(e)),u=o===void 0?-1:s.current.indexOf(o.key),d=c.current,f=R.current;r().then(()=>{c.current===d&&R.current===f&&(L.current={beforeHeight:n,beforeTop:i,anchor:o,anchorIndex:u})},()=>{}).finally(()=>{M.current===t&&(j.current=!1)})},[I,r]);(0,X.useEffect)(()=>()=>clearTimeout(P.current),[]);let V=(0,X.useRef)(null),H=(0,X.useRef)(0),U=(0,X.useCallback)(()=>n===`document`?++yi.generation:++H.current,[n]),ne=(0,X.useCallback)((e,t)=>n===`document`?yi.viewKey===e&&yi.generation===t:c.current===e&&H.current===t,[n]);(0,X.useEffect)(()=>()=>V.current?.disconnect(),[e,u]);let re=(0,X.useCallback)((t,n,r,i)=>{let a=l.current;if(!a||!u)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0,p(!0),U(),V.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=a.querySelector(`[data-slot="run-header"]`),c=s&&getComputedStyle(s).position===`sticky`?vi(s):0,d=(e,t)=>{let r=a.getBoundingClientRect(),o=t.getBoundingClientRect(),s=w.current;if(s&&i===void 0){let t=o.top-e.getBoundingClientRect().top;c+t+o.height>r.height&&s.scrollToIndex(n,{align:`start`,offset:t-c-12})}else(o.top<r.top+c||o.bottom>r.bottom)&&T(a.scrollTop+o.top-r.top-c-12)},f=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e?e.tabIndex=-1:d(e,t),t.focus({preventScroll:!0}),document.activeElement===t?(V.current?.disconnect(),!0):!1},h=w.current;if(i!==void 0)T(i);else if(h)h.scrollToIndex(n,{align:`start`,...c>0?{offset:-c}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-c)}f()||(V.current=new MutationObserver(()=>{f()}),V.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Ie(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,U]),W=(0,X.useCallback)(t=>{let n=U(),r=c.current;V.current?.disconnect();let a=l.current;if(!a)return;x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),Ie(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},s=a.closest(`[data-slot="main"]`)??a.closest(`[data-route="task-thread"]`)??a,u=()=>ne(r,n),d=()=>{let e=t?.(s);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!u()||d())return;V.current?.disconnect();let e=new MutationObserver(()=>{u()?d()&&e.disconnect():e.disconnect()});V.current=e,e.observe(s,{childList:!0,subtree:!0})})})})},[i,e,E,U,ne,y]),ie=o.at(-1),ae=o.length;return(0,X.useLayoutEffect)(()=>{R.current+=1,L.current=null,j.current=!1,n===`document`?yi.viewKey!==e&&(yi.viewKey=e,yi.generation+=1):H.current+=1},[e,n]),(0,X.useLayoutEffect)(()=>{let e=L.current;e?(e.anchor===void 0?-1:s.current.indexOf(e.anchor.key))>e.anchorIndex?z():L.current=null:m.current&&E()},[ie,ae,z,E]),(0,X.useLayoutEffect)(()=>{!l.current||!u||D()},[u,D]),(0,X.useEffect)(()=>{let t=l.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,c,d=()=>{h.current&&!Ye(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),c=e},v=()=>{U(),V.current?.disconnect(),x.current=null,S.current=null,R.current+=1,L.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,R.current+=1,L.current=null,g.current=Date.now()},C=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){v();let e=!N.current;N.current=!0,clearTimeout(P.current),P.current=setTimeout(()=>{N.current=!1},180),e&&ht(t)&&B()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&ht(t)&&B()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),b())},D=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,te.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(h.current=!1,x.current=null,S.current=null,Ye(t,80)||(v(),b()))},k=()=>{i=!1},A=e=>{F.current=!1,r=e.touches[0]?.clientY??null},ee=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),v(),!F.current&&ht(t)&&(F.current=!0,B())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},j=e=>{if(e===0||!i&&Date.now()-_.current>=bi)return;let n=e<0?`up`:`down`;!i&&n!==c||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=xi&&(0,li.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},M=()=>{let n=m.current;j(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!te.current&&t.scrollTop<a&&ht(t)&&(te.current=!0,B()),a=t.scrollTop;let r=Ye(t,80);r&&x.current===null&&(m.current||Date.now()-g.current<2e3)&&(m.current=!0),!n&&m.current&&y({direction:`tail`}),p(!r),x.current===null&&!O(e)&&Ie(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,M,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,A,{passive:!0}),t.addEventListener(`touchmove`,ee,{passive:!0}),t.addEventListener(`pointerdown`,D,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,w);let I;if(typeof ResizeObserver<`u`){I=new ResizeObserver(()=>{let e=x.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;T(Math.min(e,n)),n>=e&&(x.current=null)}else m.current&&E()}),I.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&I.observe(r),i&&I.observe(i)}return()=>{t.removeEventListener(`scroll`,M),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,A),t.removeEventListener(`touchmove`,ee),t.removeEventListener(`pointerdown`,D),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,w),I?.disconnect()}},[e,u,B,T,E,O,U,y]),{attachContent:A,scrollElRef:l,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:W,jumpToRow:re,loadOlder:B,restickIfStuck:ee,subscribeReaderScroll:b}}function Ci({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,Z.jsx)(wi,{runId:e,rows:t,controls:r}):(0,Z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function wi({runId:e,rows:t,controls:n}){return(0,Z.jsx)(Ti,{runId:e,rows:t,controls:n},e)}function Ti({runId:e,rows:t,controls:n}){let r=(0,X.useRef)(null),i=(0,X.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,X.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,X.useState)(()=>Ge(e)),[l,u]=(0,X.useState)(()=>({cache:Pe(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,X.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,X.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,X.useRef)(t.length);f.current=t.length;let p=(0,X.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,X.useRef)(null),h=(0,X.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||Ke(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,X.useState)(0);return(0,X.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,Z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,Z.jsx)(Mn,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},children:t.map(e=>(0,Z.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))},l.generation)})}function Ei({onJump:e,pendingQuestions:t=0}){return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,onClick:()=>e(),className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center justify-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-sm hover:text-foreground max-md:size-11 max-md:p-0`,children:[(0,Z.jsx)(De,{"aria-hidden":!0,className:`size-3.5 max-md:size-4`}),(0,Z.jsx)(`span`,{className:`max-md:sr-only`,children:hi(t)})]})}function Di(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function Oi(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Di(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function ki(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var Ai=new WeakMap;function ji(e,t){let n=Ai.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(Ai.set(e,t),t)}function Mi(e,t){if(t!=null)return e.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===t&&!e.resolved)}function Ni(e,t,n=t,r,i){let a=Mi(n,r),o=i?.pinPendingAskInTranscript!==!1,s=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),c=new Set,l=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),u=[];e.task&&u.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])u.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let d=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===d?Fi(n.items):n.items;u.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:ji(n.items,Oi(e,t.filter(t=>!e.task||!Jn(t,`opening`)).map(e=>e.kind===`ask`&&l.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?ki(e,r,a):e.kind===`permission`?(c.add(e.requestId),s.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let f=[...s.values()].filter(e=>e.status===`pending`&&!c.has(e.requestId));return f.length>0&&u.push({id:`pending-permissions`,entries:f,inDaySequence:!1}),a!==void 0&&o&&u.push({id:ui,entries:[{...a,placement:`pinned`}],inDaySequence:!1}),u}var Pi=`changes ready for review`;function Fi(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(Pi)))}function Ii(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function Li(e,t){return[{id:`agent:${e}`,entries:t}]}function Ri(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function zi(e,t){let n=[],r;for(let t of e){let e=Ri(t),i=pt(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of nt(t.entries))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Bi({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,X.useMemo)(()=>zi(n,e),[n,e]),p=Si(`${e}:${t}`,{surface:r}),m=c??p;kr(e,f,m,r);let h=(0,X.useMemo)(()=>{let e=new Map;f.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,X.useMemo)(()=>f.map(t=>({key:t.key,node:Vi(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??He(``,g.length),v=g.length===0?i??null:(0,Z.jsx)(Ci,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,Z.jsx)(Un,{runId:e,children:(0,Z.jsx)(rt,{runId:e,children:(0,Z.jsx)(Ir.Provider,{value:h,children:r===`panel`?(0,Z.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,Z.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:v}),m.pillVisible?(0,Z.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,Z.jsx)(Ei,{onJump:m.jumpToLatest})}):null]}):v})})})}function Vi(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,Z.jsx)(Hi,{message:e.content.message,actions:t});case`day-separator`:return(0,Z.jsx)(at,{ts:e.content.ts});case`turn-time`:return(0,Z.jsx)($e,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,Z.jsx)(Ui,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return qi(e.content)}}function Hi({message:e,actions:t}){return(0,Z.jsx)(Ze,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,Z.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,Z.jsx)(We,{ask:e.ask})}):void 0})}function Ui({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,Z.jsx)(Ue.Provider,{value:`${t}:${e.entry.id}`,children:(0,Z.jsx)(Gi,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,Z.jsx)(it,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,Z.jsx)(Wi,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,Z.jsx)(tt,{group:e,scope:t});case`streak`:return(0,Z.jsx)(ft,{count:e.count,children:e.blocks.map(e=>(0,Z.jsx)(Ui,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,Z.jsx)(Qr,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return qi(e)}}function Wi({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return nt(e).map(e=>(0,Z.jsx)(Ui,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Gi({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,Z.jsx)(lt,{text:e.text,ts:e.ts}):(0,Z.jsx)(Ze,{text:e.text,ts:e.ts});case`reasoning`:return(0,Z.jsx)(Xe,{text:e.text});case`tool`:return(0,Z.jsx)(it,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,Z.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`,e.delivery?` · ${Kr(e.delivery)}`:``]}),(0,Z.jsx)(ct,{note:e})]}):(0,Z.jsx)(ct,{note:e});case`conversation`:return(0,Z.jsx)(Qr,{runId:i,taskTitles:a,recipientBackends:o,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,Z.jsx)(st,{image:e});case`ask`:return n===void 0?(0,Z.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`permission`:return r?r(e):(0,Z.jsx)(Nr,{permission:e,runId:i});case`provider-auth-required`:return(0,Z.jsx)(ut,{incident:e});case`preview-server`:return(0,Z.jsx)(Ki,{entry:e});case`hook`:return(0,Z.jsx)(Je,{item:e,cacheKey:`${t}:${e.id}`});default:return qi(e)}}function Ki({entry:e}){let t=On(),n=yn(w().data);return(0,Z.jsx)(Zn,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function qi(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Ji({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,onBeforeOpenReport:o,onRestoreAgentFocus:s,taskTitles:c,recipientBackends:l}){let u=(0,X.useContext)(en),d=(0,X.useRef)(void 0),f=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{d.current?.()},[u,e]),(0,Z.jsx)(Yt,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,Z.jsx)(Zt,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{f.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,Z.jsx)(Le.Provider,{value:e=>{let t=r?.id,n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);d.current?.(),d.current=u?.registerOpener(e,()=>{if(t&&s){s(t);return}n?.focus({preventScroll:!0})}),f.current=!0,o?.(),a()},children:(0,Z.jsx)(Yi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:c,recipientBackends:l})})})})}function Yi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Jt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,Z.jsxs)(Xt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,Z.jsxs)($t,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(Xi,{status:r.status}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,Z.jsx)(Bi,{runId:e,viewId:`agent:${r.id}`,sections:Li(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,empty:(0,Z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function Xi({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,Z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:G(`rounded-full px-2 py-0.5 text-xs font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function Zi(e){let t=A(),[n,r]=(0,X.useState)(),i=Vt(e);(0,X.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=o({mutationFn:async()=>{r(e.id);try{if(!(await H(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:d.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function Qi({agents:e,onSelect:t}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,Z.jsx)($i,{agent:e,onSelect:t},e.id))})}function $i({agent:e,onSelect:t}){let n=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ea,{status:e.status,stalled:e.stalled===!0}),(0,Z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,Z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:yr(e)}),(0,Z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,Z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,Z.jsx)(`button`,{type:`button`,"data-agent-id":e.id,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,Z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function ea({status:e,stalled:t=!1}){return t?(0,Z.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,Z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function ta(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function na({entries:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,Z.jsx)(ra,{entry:e},`${t}:${e.content}`))})}function ra({entry:e}){return(0,Z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:G(`flex min-h-5 min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 text-[13px] [&>svg]:mt-[3px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-disabled-foreground line-through`),children:[(0,Z.jsx)(ia,{status:e.status}),(0,Z.jsx)(`span`,{"data-slot":`plan-text`,className:`min-w-0 flex-1 basis-40 break-words`,children:e.content}),e.status===`in_progress`?(0,Z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function ia({status:e}){return e===`cancelled`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-disabled-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,Z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,Z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,Z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,Z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,Z.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,Z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function aa(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function oa(e,t){let n=aa(e);return n===`active`&&t===`waiting`?`paused`:n}function sa(e){return e===`active`?`running`:e}function ca(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function la({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=ca(e)*100;return(0,Z.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,Z.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":oa(n.status,t),className:`flex min-h-[22px] min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5 text-[13px] text-muted-foreground [&>svg]:mt-[3px]`,children:[(0,Z.jsx)(ua,{visual:oa(n.status,t)}),(0,Z.jsx)(`span`,{"data-slot":`step-name`,className:`min-w-0 flex-1 basis-32 break-words font-medium text-foreground`,children:n.name}),n.iterations>1?(0,Z.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,Z.jsxs)(`span`,{"data-slot":`step-meta`,className:`ml-auto max-w-full min-w-0 pl-2 text-right text-xs leading-5 break-words text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,Z.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function ua({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Z.jsx)(Ae,{"aria-hidden":!0,className:G(t,`text-success`)});case`active`:return(0,Z.jsx)(Et,{role:`status`,"aria-label":`Step running`,className:G(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Ee,{role:`img`,"aria-label":`Step paused`,className:G(t,da)});case`failed`:return(0,Z.jsx)(_e,{"aria-hidden":!0,className:G(t,`text-danger`)});case`pending`:return(0,Z.jsx)(we,{"aria-hidden":!0,className:G(t,`text-soft-foreground`)})}}var da=`stroke-pending [html.light_&]:stroke-pending-strong`,fa={done:`done`,failed:`failed`,cancelled:`cancelled`};function pa(e){let t=fa[e.status];return t?e.steps.map(e=>aa(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):ma(e)}function ma(e){let t=ha(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function ha(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>aa(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function ga(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function _a(e){return typeof e==`object`&&!!e&&!(0,X.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:o,onToggle:s,className:c,children:l}){let u=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,Z.jsx)(`span`,{className:G(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(_a(r)?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,Z.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,Z.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,Z.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),d=s!==void 0;return(0,Z.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":d&&o?`open`:`collapsed`,className:G(`min-w-0 border-t border-border first:border-t-0`,c),children:[d?(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:s,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[u,a,(0,Z.jsx)(je,{"aria-hidden":!0,className:G(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,o&&`rotate-180`)})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[u,a]}),d&&o?(0,Z.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:l}):null]})}function va(e){return P(e.delegation)}function ya(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function ba(e){let t=e.delegation,n=va(e),r=S(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=ya(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function xa(e){let t=S(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>qt(e.status))}function Sa({run:e,open:t,onToggle:n}){let r=S(e.id),i=v(),a=nn(),o=e.delegation,s=new Map(r.data?.workers.map(e=>[e.workerId,e])),c=ya(o,r.data),l=I(e)??k(e),u=l?Ca(e,l):void 0,d=e=>i.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),f=e=>{let t=d(e);return t?J(t):`worker ${e.slice(0,8)}`};return(0,Z.jsx)(Q,{slot:`workers`,icon:(0,Z.jsx)(Te,{className:`size-4`}),title:`Workers`,meta:wa({ids:c,workers:s,desktop:a,query:r}),aside:r.data?.capacity?(0,Z.jsx)(ja,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,Z.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,l?(0,Z.jsx)(Oa,{wait:l,dependencyLabel:u}):null,c.length>0?(0,Z.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:c.map(t=>{let n=s.get(t),i=d(t),a=n?Ea(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,Z.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,Z.jsxs)(zt,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Z.jsx)(Ta,{status:n?.status}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate`,children:i?J(i):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,Z.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,f(n.supervisorRunId)]}):null]}),(0,Z.jsx)(`span`,{className:G(`max-w-[45%] shrink-0 truncate text-xs`,Da(n?.status)),children:a}),(0,Z.jsx)(Oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,Z.jsx)(Na,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,Z.jsx)(La,{state:n.destroy}):null]},t)})}):va(e)&&r.isSuccess?(0,Z.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,Z.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,Z.jsx)(q,{variant:`outline`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function Ca(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return E(e)??F(n.role,t,`requestIds`in t&&te(n,t.requestIds))}function wa({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function Ta({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,Z.jsx)(Ae,{"aria-hidden":!0,className:G(t,`text-semantic-green`)}):e===`failed`?(0,Z.jsx)(_e,{"aria-hidden":!0,className:G(t,`text-semantic-red`)}):e===`cancelled`?(0,Z.jsx)(Ce,{"aria-hidden":!0,className:G(t,`text-soft-foreground`)}):e===`review`?(0,Z.jsx)(Tt,{"aria-hidden":!0,className:G(t,`text-semantic-info`)}):e===`waiting`?(0,Z.jsx)(Ee,{"aria-hidden":!0,className:G(t,`text-semantic-amber`)}):e===`running`?(0,Z.jsx)(Et,{role:`status`,"aria-label":`Worker running`,className:G(t,`animate-spin stroke-status-running motion-reduce:animate-none`)}):(0,Z.jsx)(we,{"aria-hidden":!0,className:G(t,`text-soft-foreground`)})}function Ea(e){return fn(e)}function Da(e){return e===`done`?`text-semantic-green`:e===`failed`?`text-semantic-red`:e===`review`?`text-semantic-info`:e===`waiting`?`text-semantic-amber`:`text-muted-foreground`}function Oa({wait:e,dependencyLabel:t}){return(0,Z.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?sn(`waiting-on-workers`,t):`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting for request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting for workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,Z.jsxs)(Z.Fragment,{children:[` `,`Deadline: `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function ka(e){return e.delegation?.role===`worker`&&k(e)?.phase===`wake-pending`}function Aa({run:e}){let t=k(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,Z.jsx)(Oa,{wait:t,dependencyLabel:F(`worker`,t)}):null}function ja({capacity:e}){return(0,Z.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Ma=new Set([`review`,`done`,`failed`,`cancelled`]);function Na({parentRunId:e,worker:t}){let n=c(e),[r,i]=(0,X.useState)(!1);if(!Ma.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof D?n.error.work:void 0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`break-words text-xs`,children:B(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,Z.jsx)(q,{variant:`danger-ghost`,size:`sm`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,Z.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>i(!1),children:`Cancel`})]}):(0,Z.jsx)(q,{variant:`outline`,size:`sm`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,Z.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${Fa(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,Z.jsx)(q,{variant:`danger-ghost`,size:`sm`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var Pa=(e,t,n)=>`${e} ${e===1?t:n}`;function Fa(e){return[...e.uncommittedFiles?[Pa(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Pa(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Ia(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function La({state:e}){if(!Ia(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,Z.jsx)(Ra,{at:t.nextAt});return(0,Z.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,Z.jsxs)(Z.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,Z.jsxs)(Z.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Ra({at:e}){let t=Qt(3e4);return(0,Z.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:qn(t,Date.parse(e))})}function za({items:e,lead:t=0,room:n,className:r}){let i=(0,X.useRef)(null),[a,o]=(0,X.useState)(-1/0);return(0,X.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let a=n?r.closest(n):null,s=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let i=n+Ba(a),s=getComputedStyle(r),c=Number.parseFloat(s.width),l=c>0?n/c:1,u=(Number.parseFloat(s.columnGap)||0)*l,d=Array.from(r.children,e=>e.getBoundingClientRect().width),f=e.map((e,t)=>({...e,width:d[t]??0})),p=-1/0,m=()=>f.reduce((e,t)=>e+t.width,0)+Math.max(0,f.length-1)*u+(f.length>0?t*l:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(m()<=i)break;p=t,f=f.filter(e=>e.priority>t)}o(e=>e===p?e:p)};if(s(),typeof ResizeObserver>`u`)return;let c=new ResizeObserver(s);c.observe(r);for(let e of r.children)c.observe(e);return a&&c.observe(a),()=>c.disconnect()},[e,t,n]),(0,Z.jsx)(`span`,{ref:i,"data-slot":`activity-summary`,className:G(`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,r),children:e.map(n=>{let r=n.priority<=a,i=n===e.find(e=>e.priority>a);return(0,Z.jsxs)(`span`,{"data-summary-item":n.id,"data-hidden":r,"aria-hidden":r||void 0,inert:r||void 0,style:i&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:[!i||t>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ba(e){let t=e?.firstElementChild;return!e||!t?0:Math.max(0,e.getBoundingClientRect().width-t.getBoundingClientRect().width)}function Va({run:e,references:t}){return(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,Z.jsx)(de,{reference:t,taskTitle:J(e),inert:!0},se(t)))})}function Ha(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?an(e.accounts,e.accountBackend)?`default`:void 0:e.known?an(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Ua(e){let t=g(),n=_(),r=C(),{accounts:i}=rn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,u=c?.backend??a,d=r.data?.profiles.find(e=>e.id===l&&e.provider===u),f=Ha({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:d,accounts:i,accountBackend:u}),p=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?b(t.data,a):j(e.removedRunner),...f?{account:f}:{},model:o,effort:s,...p?{identity:p}:{}}}var Wa=[`running`,`queued`,`waiting`];function Ga(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function $(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function Ka(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function qa(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Ja(e){let t=Ga(e.waits),n=Wa.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&qa(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Ga(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Ya(e){return Ja(e)!==void 0}function Xa(e){return(Ja(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Za({run:e}){let t=Ja(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,Z.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,Z.jsx)($a,{run:e,wait:t},t.id):t.kind===`worker`?(0,Z.jsx)(eo,{wait:t},t.id):t.kind===`process`?(0,Z.jsx)(oo,{run:e,wait:t},t.id):t.kind===`peer`?(0,Z.jsx)(to,{wait:t},t.id):t.kind===`subagent`?(0,Z.jsx)(no,{wait:t},t.id):t.kind===`plugin`?(0,Z.jsx)(ro,{run:e,wait:t},t.id):(0,Z.jsx)(io,{run:e,wait:t},t.id)),i?(0,Z.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,Z.jsx)($a,{run:e,wait:r,settled:!0}):null,a?(0,Z.jsx)(oo,{run:e,wait:a,settled:!0}):null]})}function Qa(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha?vn(r.headSha):`unknown`} → ${r?.observedHeadSha?vn(r.observedHeadSha):`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Ka(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function $a({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,a=n&&t.phase===`cancelled`,o=Qa(e,t,n),s=n?a?t.cancelledAt:r?.observedAt:t.deadline,c=$(s),l=`${t.repository}#${t.prNumber}`;return(0,Z.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,Z.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,Z.jsx)(`dd`,{children:o}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,Z.jsx)(`dd`,{className:`min-w-0`,children:me(t.prUrl)?(0,Z.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:l}):(0,Z.jsx)(`span`,{children:l})}),c?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?a?`Cancelled`:`Observed`:`Deadline`}),(0,Z.jsx)(`dd`,{children:(0,Z.jsx)(`time`,{dateTime:s,children:c})})]}):n?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,Z.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function eo({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,r,` `,i]}),a?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,Z.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function to({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`task`:`tasks`]}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function no({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=$(e.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,Z.jsxs)(`p`,{children:[`Check by`,` `,(0,Z.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,Z.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function ro({run:e,wait:t}){let n=t.phase===`open`?$(t.deadline):void 0;return(0,Z.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsx)(`p`,{children:t.phase===`resolved`?Ka(t.summary,e):t.summary}),n?(0,Z.jsxs)(`p`,{children:[`Deadline`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function io({run:e,wait:t}){let n=$(t.deadline);return(0,Z.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,Z.jsx)(`p`,{children:Ka(`Automatic check due`,e)}):n?(0,Z.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,Z.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,Z.jsx)(`p`,{children:t.note}):null]})}function ao(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function oo({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?ao(t):t.phase===`resolved`?Ka(ao(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?$(t.deadline):void 0;return(0,Z.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Z.jsx)(`p`,{children:r}),i?(0,Z.jsxs)(`p`,{children:[`Until`,` `,(0,Z.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var so=new Map,co=new Map;function lo(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=xt(e.run);return(0,Z.jsx)(le,{projectId:t,repoBase:n,requests:i,children:(0,Z.jsx)(uo,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!fe(e.run)||!!pe(e.run,n)})})}function uo({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,presentation:s=`card`,prNumbers:c,hasReferences:l,references:u}){let d=nn(),f=Ua(e),[p,m]=(0,X.useState)(()=>i?!1:so.get(e.id)??!1),h=Oo(o,p),g=s===`panel`||h.open,[_,v]=(0,X.useState)({}),y=po(e,t??n,n,r,c),b=vt(e),x=t=>_[t]??co.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);co.set(`${e.id}:${t}`,n),v(e=>({...e,[t]:n}))},C=e=>({open:x(e),onToggle:()=>S(e)}),w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,Z.jsx)(xo,{run:e,activity:y,...C(`status`)}),(0,Z.jsx)(So,{run:e,desktop:d,automations:y.automations,...C(`workflow`)}),(0,Z.jsx)(Co,{activity:y,desktop:d,onOpenWorker:a,...C(`subagents`)}),(0,Z.jsx)(wo,{run:e,...C(`workers`)}),(0,Z.jsx)(To,{activity:y,desktop:d,...C(`plan`)}),(0,Z.jsx)(Eo,{run:e,identity:f,activity:y,...C(`usage`)}),(0,Z.jsx)(Do,{run:e,references:u,conflicts:y.conflicts,hasReferences:l,onResume:()=>b.mutate(),...C(`workspace`)})]});return s===`panel`?(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-presentation":`panel`,"data-state":`open`,"aria-label":`Session activity`,className:`flex min-w-0 flex-col bg-card`,children:[(0,Z.jsxs)(`div`,{className:`sticky inset-bs-0 z-10 flex items-center gap-2 bg-card px-3.5 py-2.5 text-[13px]`,children:[(0,Z.jsx)(ge,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Session activity`}),y.cost?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums`,children:y.cost}):null]}),w]}):(0,Z.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:h.ref,"data-state":g?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,Z.jsx)(vo,{run:e,identity:f,activity:y,references:u,open:g,onToggle:()=>{so.set(e.id,!g),m(!g),h.chose(!g)}}),g?w:null]})}function fo(e,t,n,r){let i=w(),a=An(i.data),o=v(),s=Ct(e,{queuePosition:e.status===`queued`?Wt(o.data??[]).get(e.id):void 0}),c=!Ut(e)&&e.status!==`queued`,l=(0,X.useMemo)(()=>r?gr(n.turns,c,t.turns):[],[r,n.turns,c,t.turns]),u=$n(n)??[],d=ba(e),f=vr(l),p=ta(u);return{health:i,line:s,...mo(e,s,d,r?f:void 0,p),...ho(e,a),agents:l,agentCounts:f,planEntries:u,planCounts:p}}function po(e,t,n,r,i){let a=fo(e,t,n,r),o=ue(i);return{...a,conflicts:o,waitReferences:Xa(e),automations:_n(a.health.data)}}function mo(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`,glyph:o?(0,Z.jsx)(Ae,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function ho(e,t){return{cost:t.cost&&e.costUsd!==void 0?ce(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,Z.jsx)(Pn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function go(e){return e.allComplete?`text-semantic-green`:e.failed&&`text-semantic-red`}function _o(e){let t=pa(e),n=ha(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function vo({run:e,identity:t,activity:n,references:r,open:i,onToggle:a}){let{cost:o}=n,s=[...new Map([...r,...n.waitReferences].map(e=>[se(e),e])).values()];return(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-label":yo(e,t,n,s,i),onClick:a,className:G(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,i?`gap-2.5`:`gap-2`),children:[(0,Z.jsx)(ge,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),i?null:(0,Z.jsx)(bo,{run:e,identity:t,activity:n,summaryReferences:s}),i&&o?(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:o}):null,(0,Z.jsx)(je,{"aria-hidden":!0,className:G(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,i&&!o&&`ms-auto`,i&&`rotate-180`)})]})}function yo(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=_o(e)?.step,u=l?`; step ${l.name}, ${sa(oa(l.status,e.status))}`:``,d=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${u}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${d}`}function bo({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:i,cost:a,conflicts:o}=n,s=_o(e)?.step,c=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,children:a})}]:[],...r.length||o.length?[{id:`chips`,priority:0,content:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Va,{run:e,references:r}),o.length>0?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(be,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`run-activity-status`,title:i,className:G(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,go(n)),children:[n.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:i})]}),s?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-step`,className:G(`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,e.status===`waiting`&&`max-md:hidden`),children:[(0,Z.jsx)(Mo,{step:s,runStatus:e.status,decorative:!0}),(0,Z.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:s.name,className:`min-w-0 truncate`,children:s.name})]}):null,(0,Z.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,Z.jsx)(za,{items:c,lead:8})})]})}function xo({run:e,activity:t,open:n,onToggle:r}){let{line:i,waitReferences:a}=t,o=ka(e);return(0,Z.jsxs)(Q,{slot:`status-row`,icon:t.glyph,title:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:G(`truncate`,go(t)),children:t.statusText}),i.nextCheck?(0,Z.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,Z.jsx)(`time`,{dateTime:i.nextCheck.at,children:i.nextCheck.text})]}):null]}),summary:!n&&a.length>0?(0,Z.jsx)(za,{items:[{id:`chips`,priority:0,content:(0,Z.jsx)(Va,{run:e,references:a})}]}):void 0,open:n,onToggle:Ya(e)||o?r:void 0,children:[(0,Z.jsx)(Za,{run:e}),o?(0,Z.jsx)(Aa,{run:e}):null]})}function So({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=oe(e),o=_o(e);return!a&&!o?null:(0,Z.jsxs)(Q,{slot:`workflow`,icon:o?(0,Z.jsx)(Mo,{step:o.step,runStatus:e.status}):(0,Z.jsx)(Se,{className:`size-4`}),title:(0,Z.jsxs)(Z.Fragment,{children:[`Workflow`,a?(0,Z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:ga(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,Z.jsx)(la,{steps:o.steps,runStatus:e.status}):null,(0,Z.jsx)(jo,{run:e,available:n})]})}function Co({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,Z.jsx)(Q,{slot:`subagents`,icon:(0,Z.jsx)(ye,{className:`size-4`}),title:`Subagents`,meta:ga(o.done,o.total,t),open:r,onToggle:i,children:(0,Z.jsx)(Qi,{agents:a,onSelect:n})})}function wo({run:e,open:t,onToggle:n}){return va(e)?(0,Z.jsx)(Sa,{run:e,open:t,onToggle:n}):null}function To({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,Z.jsx)(Q,{slot:`plan`,icon:(0,Z.jsx)(K,{className:`size-4`}),title:`Plan`,meta:ga(a.done,a.total,t),open:n,onToggle:r,children:(0,Z.jsx)(na,{entries:i})})}function Eo({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,Z.jsx)(Q,{slot:`usage`,icon:(0,Z.jsx)(er,{className:`size-4`}),title:`Usage & agent`,summary:(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(za,{items:c})}),open:r,onToggle:i,children:(0,Z.jsx)(Ao,{run:e,tokens:o,cost:a})})}function Do({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||Bn(e)||Ia(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,Z.jsx)(Q,{slot:`workspace`,icon:(0,Z.jsx)(Te,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,Z.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,Z.jsx)(za,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,Z.jsx)(Va,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,Z.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,Z.jsx)(be,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,Z.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,Z.jsx)(La,{state:s}):null,(0,Z.jsx)(St,{run:e}),e.branch?(0,Z.jsx)(ko,{label:`Branch`,children:(0,Z.jsx)(bt,{branch:e.branch})}):null,e.worktreePath?(0,Z.jsx)(ko,{label:`Worktree`,children:(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,Z.jsx)(yt,{run:e,canResume:wn(e).terminal,onResume:i})]})})}function Oo(e,t){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(t);a.current=t;let o=(0,X.useRef)({active:!1,override:!1});return(0,X.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function ko({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function Ao({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Ua(e);return(0,Z.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,Z.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,Z.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,Z.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function jo({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,Z.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,Z.jsx)(zt,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:G(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,Z.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Mo({step:e,runStatus:t,decorative:n=!1}){let r=oa(e.status,t),i=`size-4 shrink-0`;switch(r){case`active`:return(0,Z.jsx)(Et,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:G(i,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,Z.jsx)(Ee,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:G(i,da)});case`failed`:return(0,Z.jsx)(_e,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:G(i,`text-danger`)});case`pending`:return(0,Z.jsx)(we,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:G(i,`text-soft-foreground`)});case`done`:return(0,Z.jsx)(Ae,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:G(i,`text-success`)})}}function No(e,t,n,r){let i=fo(e,t,n,r),a=va(e),o=S(e.id,{enabled:a}),s=(0,X.useMemo)(()=>{let t=e.delegation?.role===`root`?e.delegation.receipts.map(e=>e.workerId):[],n=o.data?.workers.map(e=>e.workerId)??[];return new Set([...t,...n]).size},[e.delegation,o.data?.workers]),c=pa(e),l=c.length>0?c[ha(e.currentStepId,c)]:void 0;return{statusText:i.statusText,glyph:i.glyph,allComplete:i.allComplete,failed:i.failed,activeStepName:l?.name,shownStepName:l&&oa(l.status,e.status)!==`done`?l.name:void 0,workerCount:s,agentCounts:i.agentCounts,cost:i.cost,nextCheckText:i.line.nextCheck?.text,line:i.line}}function Po(e,t){let n=[`Session activity: ${e.statusText}`];return e.nextCheckText&&n.push(`Next check ${e.nextCheckText}`),e.activeStepName&&n.push(`step ${e.activeStepName}`),e.workerCount>0&&n.push(`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`),e.agentCounts.total>0&&n.push(`${e.agentCounts.done}/${e.agentCounts.total} subagents`),e.cost&&n.push(`cost ${e.cost}`),t===`sidebar`&&n.push(`toggle activity sidebar`),n.join(`; `)}function Fo({props:e,align:t,sideOffset:n,collisionPadding:r=0,contentClassName:i,children:a}){let{run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u,open:d,onOpenChange:f,keepOpen:p=!1,onOpenAutoFocus:m}=e,h=e=>{p&&e.preventDefault()};return(0,Z.jsxs)(Lt,{open:d,onOpenChange:e=>{!e&&p||f(e)},children:[(0,Z.jsx)(Pt,{asChild:!0,children:a}),(0,Z.jsx)(It,{align:t,sideOffset:n,collisionPadding:r,"data-slot":`run-activity-popover`,className:i,onOpenAutoFocus:m,onInteractOutside:h,onPointerDownOutside:h,onFocusOutside:h,onEscapeKeyDown:h,children:(0,Z.jsx)(lo,{presentation:`panel`,run:o,thread:s,currentThread:c,currentComplete:l,onOpenWorker:u})})]})}function Io(e,t=!1){let n=t?`${e.workerCount}w`:`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`,r=`${e.agentCounts.done}/${e.agentCounts.total}${t?``:` agents`}`;return[...e.shownStepName?[{id:`step`,priority:0,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-step`,className:G(`truncate`,t?`max-w-[96px]`:`max-w-[140px]`),children:e.shownStepName})}]:[],...e.workerCount>0?[{id:`workers`,priority:3,content:(0,Z.jsx)(`span`,{"data-slot":`activity-workers-badge`,children:n})}]:[],...e.agentCounts.total>0?[{id:`subagents`,priority:2,content:(0,Z.jsx)(`span`,{"data-slot":`activity-subagents-badge`,children:r})}]:[],...e.cost?[{id:`cost`,priority:1,content:(0,Z.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`font-mono text-xs`,children:e.cost})}]:[]]}function Lo(e){let{run:t,thread:n,currentThread:r,currentComplete:i,mode:a,open:o,onOpenChange:s}=e,c=No(t,n,r,i),l=Po(c,a),u=c.allComplete?`text-semantic-green`:c.failed?`text-semantic-red`:`text-foreground`,d=(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger`,"data-activity-mode":a,"aria-expanded":o,"aria-label":l,onClick:a===`sidebar`?()=>s(!o):void 0,className:G(`inline-flex min-h-9 max-w-full items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-[12px] font-medium text-foreground shadow-xs transition-colors`,`pointer-hover:bg-muted/60 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,o&&`border-accent-strong/60`),children:[(0,Z.jsxs)(`span`,{"data-slot":`pill`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[c.glyph,(0,Z.jsx)(`span`,{"data-slot":`run-activity-status`,className:u,children:(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,children:c.statusText})})]}),(0,Z.jsx)(`span`,{className:`-ms-2 grid min-w-0 grid-cols-[minmax(0,max-content)]`,children:(0,Z.jsx)(za,{items:Io(c),lead:8,room:`[data-slot='run-status-slot']`})}),(0,Z.jsx)(je,{"aria-hidden":`true`,className:G(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,o&&`rotate-180`)})]});return(0,Z.jsx)(`span`,{"data-slot":`run-status-slot`,className:`hidden`,children:a===`sidebar`?d:(0,Z.jsx)(Fo,{props:e,align:`end`,sideOffset:6,contentClassName:`w-[380px] max-w-[calc(100vw-2rem)] max-h-[min(70dvh,540px)] overflow-y-auto overscroll-contain p-0`,children:d})})}var Ro=`[data-slot='mobile-status-room']`;function zo(e){let{run:t,thread:n,currentThread:r,currentComplete:i,open:a}=e,o=No(t,n,r,i),s=U(),c=Po(o,`popover`),{attention:l}=o.line;return(0,Z.jsx)(Fo,{props:e,align:`start`,sideOffset:10,collisionPadding:8,contentClassName:`w-[420px] max-w-[calc(100vw-1rem)] max-h-[min(65dvh,460px)] overflow-y-auto overscroll-contain p-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger-mobile`,"aria-expanded":a,"aria-label":c,className:G(`-mt-[18px] -mb-2 inline-flex h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md pt-[18px] pb-2 text-start md:hidden`,`focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-ring`),children:[(0,Z.jsx)(En,{"data-slot":`mobile-run-status`,dot:l.tone,shape:l.shape,pulse:l.pulse&&!s,className:`min-w-0 px-2 py-px text-xs leading-4`,children:(0,Z.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`truncate`,children:o.line.label})}),(0,Z.jsx)(`span`,{className:`-ms-1.5 grid min-w-0 shrink-[1000] grid-cols-[minmax(0,max-content)]`,children:(0,Z.jsx)(za,{items:Io(o,!0),lead:6,room:Ro,className:`h-[18px] gap-1.5 text-xs`})}),(0,Z.jsx)(je,{"aria-hidden":`true`,className:G(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,a&&`rotate-180`)})]})})}var Bo=2e3;function Vo(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Ho(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Uo(e,t){let n=A(),r=(0,X.useMemo)(()=>Vo(t),[t]),i=(0,X.useMemo)(()=>Ho(t),[t]),a=e?.id,o=e?.status;(0,X.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:d.runs.detail(a)}),n.invalidateQueries({queryKey:d.runs.list()})},Bo);return()=>clearTimeout(e)},[r,i,a,o,n])}function Wo(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Go({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,X.useState)(void 0),s=(0,X.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,X.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Ii(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Wo);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}var Ko=12;function qo({run:e}){let t=A(),n=o({mutationFn:()=>L(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:d.runs.detail(e.id)}),t.invalidateQueries({queryKey:d.runs.list()}),V(`This task will not resume itself`)},onError:e=>V(e.message,{tone:`danger`})});if(!O(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,Z.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Z.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Ko,`)`]}):(0,Z.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Z.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Z.jsx)(ie,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Jo(e){let t=e?.id,[n,r]=(0,X.useState)(void 0),i=!nn();return{phone:i,folded:i&&t!==void 0&&n===t,open:(0,X.useCallback)(()=>(0,li.flushSync)(()=>r(void 0)),[]),setFolded:(0,X.useCallback)(e=>{(0,li.flushSync)(()=>r(e?t:void 0))},[t])}}function Yo(e,t){if(e.phone)return{folded:e.folded,onFoldChange:n=>{e.setFolded(n),t.current?.querySelector(n?`[data-slot="ask-folded-row"]`:`[data-slot="ask-fold"]`)?.focus({preventScroll:!0})}}}function Xo({pinnedAskId:e,run:t,askModeState:n,replyPending:r,composerPending:i,folded:a}){let o=e!==void 0,s=Cn(t,o),c=n.askId===e?n.mode:`options`;return{hasPendingAsk:o,isReviewGate:s,askMode:c,decisionMode:o?`ask`:s?`review`:`composer`,unifiedReplyActive:o&&c===`reply`&&!a,composerHidden:s||o&&(c===`options`||a),optionDeliveryPending:o&&r&&!i}}function Zo(e){let{run:t,thread:n,pinnedAsk:r,pendingQuestions:i,scroll:a,onJump:o,onShowOrigin:s,sessionOpen:c,attention:l,queued:u,continuable:d,continueAction:f,stopAction:p,finishAction:m,needsAnswer:h,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,removedRunnerNotice:b,fold:x}=e,S=(0,X.useRef)(null),C=wn(t,xa(t)).cancel,[w,T]=(0,X.useState)({askId:r?.id,mode:`options`}),[E,D]=(0,X.useState)(!1),O=e=>T({askId:r?.id,mode:e}),{hasPendingAsk:k,isReviewGate:A,askMode:ee,decisionMode:j,unifiedReplyActive:M,composerHidden:N,optionDeliveryPending:P}=Xo({pinnedAskId:r?.id,run:t,askModeState:w,replyPending:_.isPending,composerPending:E,folded:x.folded});return(0,Z.jsxs)(`div`,{ref:S,"data-slot":`thread-dock`,"data-pending-ask":h||void 0,"data-decision-mode":j,className:G(`relative z-10 shrink-0 bg-background py-1.5 md:pt-2.5 md:pb-4`,A&&`py-0 md:pt-0 md:pb-0`),children:[a.pillVisible?(0,Z.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center max-md:justify-end`,children:(0,Z.jsx)(Ei,{pendingQuestions:i,onJump:()=>{i>0&&x.open(),o()}})}):null,(0,Z.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:G(`mx-auto flex w-full min-w-0 max-w-[var(--measure)] flex-col px-[14px] md:px-16`,M?`gap-0`:`gap-1.5 md:gap-2`),children:[A?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(qo,{run:t}),(0,Z.jsx)(Qo,{run:t,sessionOpen:c,attention:l,queued:u,continuable:d,startsNewConversation:f.startsNewConversation,removedRunnerNotice:b})]}),r===void 0?null:(0,Z.jsx)(dt,{ask:{...r,placement:`pinned`},run:t,surface:`decision-zone`,mode:ee,onModeChange:O,hideReplyBody:!0,delivery:_,onShowOrigin:s,onStop:C?p.stop:void 0,stopping:p.stopping,onFinish:Sn(t)?()=>m.mutateAsync():void 0,finishing:m.isPending,fold:Yo(x,S)},r.id),(0,Z.jsx)(`div`,{"data-slot":`thread-composer-slot`,hidden:N,className:G(`min-w-0 w-full`,N&&`hidden`,M&&`rounded-b-xl border border-t-0 border-accent-strong/30 bg-accent-strong/[0.04] p-2.5 [html:not(.light)_&]:bg-card`),children:(0,Z.jsx)(ts,{run:t,thread:n,canStop:C,hasPendingAsk:k,composerHidden:N,optionDeliveryPending:P,onComposerPendingChange:D,stopAction:p,finishAction:m,attention:l,needsAnswer:h,continuable:d,continueAction:f,queued:u,sendMessage:g,reply:_,providerBlocked:v,providerReason:y,sessionOpen:c})})]})]})}function Qo({run:e,sessionOpen:t,attention:n,queued:r,continuable:i,startsNewConversation:a,removedRunnerNotice:o}){if(e.status===`waiting`&&t)return(0,Z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:n.tone,shape:n.shape,pulse:n.pulse}),n.bucket===`permission`?`Choose an approval option above to continue`:n.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${ln(e,n).label} — you can send a message to resume`]});if(e.status===`running`){let t=Ct(e,{}),n=pa(e),r=n.length>0?n[ha(e.currentStepId,n)]:void 0;return(0,Z.jsxs)(`div`,{"data-slot":`running-hint`,className:`flex min-w-0 items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[t.label,r?` · ${r.name}`:``]})]})}return r?(0,Z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):o===void 0?i&&a?(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null:(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:o})}function $o(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function es(e,t){let{run:n,hasPendingAsk:r,optionDeliveryPending:i,continuable:a,continueAction:o,queued:s,sendMessage:c,reply:l,providerBlocked:u,providerReason:d,sessionOpen:f}=e,p=async(e,t)=>{let n=await l.send(e,t);if(n!==void 0)throw Error(n)};return r?{onSubmit:p,pendingLabel:l.mode===`resume`?`Continuing…`:`Sending…`,disabled:u||l.blockedBy!==void 0||i,disabledReason:u?d:i?`Sending your answer…`:l.reason,placeholder:t?`Reply`:`Reply — / for skills, @ for files…`}:{onSubmit:a?(e,t)=>o.continueWith(e,t??[]):s?(e,t)=>c.mutateAsync({text:e,images:t}):p,pendingLabel:a?`Continuing…`:`Sending…`,disabled:u||!f&&!s&&!a,disabledReason:u?d:`Session closed — no session to resume.`,placeholder:(t?rs:is)(n,s,a)}}function ts(e){let{run:t,thread:n,canStop:r,hasPendingAsk:i,composerHidden:a,onComposerPendingChange:o,stopAction:s,finishAction:c,attention:l,needsAnswer:u,continuable:d,continueAction:f,providerBlocked:p}=e,m=!nn(),h=es(e,m),g=!i&&d&&!u;return(0,Z.jsx)(Fn,{...$o(t,d,f),onPendingChange:o,onStop:r?s.stop:void 0,onFinish:Sn(t)?()=>c.mutateAsync().catch(()=>void 0):void 0,finishing:c.isPending,stopOnEmpty:!i&&ns(t,l,u),stopping:s.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:h.pendingLabel,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:!i&&d?f.pills:void 0,onSubmit:h.onSubmit,disabled:h.disabled,disabledReason:h.disabledReason,footerEnd:p&&!f.providerPending?(0,Z.jsx)(zt,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:g,emptySubmitVariant:t.status===`review`?`outline`:`primary`,emptySubmitLabel:g?`Continue`:void 0,placeholder:h.placeholder,autocompleteSkills:!0,phoneRest:m,quickReplies:!a,getMentionCandidates:()=>Qn(n)})}function ns(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function rs(e,t,n){return t?`Add to the prompt`:n?`Add a prompt…`:e.status===`waiting`?`Reply`:`Message the agent`}function is(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function as(){let{id:e}=W(),t=s(e),n=kt(e),r=t.data?.status,a=(0,X.useMemo)(()=>Xn(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),o=(0,X.useMemo)(()=>Xn(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),c=(0,X.useRef)(void 0),l=(0,X.useCallback)(e=>{c.current=e},[]),{mutate:u}=i();if((0,X.useEffect)(()=>{t.data&&c.current!==t.data.id&&Ht(t.data)&&u(t.data.id)},[u,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Uo(t.data,n.visibleEvents),t.isPending)return(0,Z.jsx)(zn,{});if(t.isError){let e=t.error instanceof D&&t.error.status===404;return(0,Z.jsx)(tn,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,Z.jsx)(on,{icon:e?(0,Z.jsx)(Ot,{}):(0,Z.jsx)(_t,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,Z.jsx)(q,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(zt,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,Z.jsx)(zn,{}):(0,Z.jsx)(ss,{run:t.data,thread:a,currentThread:o,history:n,onMarkedUnread:l})}var os=e=>({titles:Object.fromEntries(e.map(e=>[e.id,J(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function ss({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Rt();let a=ee({queryKey:d.runs.list(),queryFn:({signal:e})=>N(T(),{signal:e}),select:os}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=fs(r,n),u=re(e),f=Yn(e.status,e.error,t),h=Nn(e),g=!h&&e.status!==`queued`,_=e.status===`queued`,v=or(e),y=Zi(e),b=Kn(e.id),x=s||ne(e),{hasContinuation:S,continuable:C}=ps(h,_,v),{openAgentId:w,setOpenAgentId:E,activityMode:D,activityOpen:O,setActivityOpen:k,showActivitySidebar:A,closeActivityPopover:j}=us(e.id),P=(0,X.useRef)(void 0),F=(0,X.useCallback)(e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(t=>t.dataset.agentId===e);if(t){t.focus({preventScroll:!0});return}P.current=e,k(!0)},[k]),te=(0,X.useCallback)(e=>{let t=P.current;if(!t)return;P.current=void 0;let n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);n&&(e.preventDefault(),n.focus({preventScroll:!0}))},[]),{openAgent:I,openAgentChildren:L}=cs(w,n,t,g),R=p(e.id),z=In(e),{providerBlocked:B,providerReason:V}=ms(h,hn(e),S,v),H=ds(e,_),U=l?void 0:c??null,W=(0,X.useMemo)(()=>Mi(n,U),[n,U]),ie=W?.questions.length??0,oe=Jo(W),se=oe.open,ce=(0,X.useMemo)(()=>Ni(e,t,n,U,{pinPendingAskInTranscript:!1}),[e,t,n,U]),le=(0,X.useMemo)(()=>zi(ce,e.id),[ce,e.id]),{taskTitles:ue,recipientBackends:de}=ls(e,a.data),fe=(0,X.useCallback)(t=>(0,Z.jsx)(Nr,{permission:t,runId:e.id,sessionOpen:h}),[e.id,h]),G=C&&e.removedRunner!==void 0?M(e.removedRunner):void 0,me=pe(e,m()),{search:he}=ae(),ge=He(he,le.length),K=Si(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:le.map(({key:e})=>e)}),_e=Go({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:le,history:r,jumpToRow:K.jumpToRow}),ve=(0,X.useRef)(c);l||(ve.current=c);let ye=_i(),be=(0,X.useRef)({reveal:_e.reveal});be.current={reveal:_e.reveal};let xe=(0,X.useCallback)(()=>{se(),pi(ye.current??document.body)?.focus({preventScroll:!0})},[ye,se]),Se=(0,X.useCallback)(t=>t.placement===`origin`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.context?(0,Z.jsx)(ot,{text:t.context}):null,t.resolved?null:(0,Z.jsx)(gi,{onGoToQuestion:xe})]}):(0,Z.jsx)(dt,{ask:t,run:e,onShowOrigin:()=>be.current.reveal()}),[e,xe]);Ft(K.restickIfStuck);let Ce=r?.currentComplete??!0,we={run:e,thread:t,currentThread:n,currentComplete:Ce,onOpenWorker:E,mode:D,open:O,onOpenChange:k,keepOpen:w!==void 0,onOpenAutoFocus:te};return(0,Z.jsxs)(tn,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,fillHeight:!0,flushPadding:!0,rootRef:ye,rootProps:{"data-run-id":e.id},className:`overflow-clip`,children:[(0,Z.jsx)(wt,{run:e,onMarkedUnread:()=>i?.(e.id),desktopActivitySlot:(0,Z.jsx)(Lo,{...we}),mobileActivitySlot:(0,Z.jsx)(zo,{...we})}),(0,Z.jsxs)(`div`,{"data-slot":`thread-workspace`,children:[(0,Z.jsxs)(`div`,{"data-slot":`thread-main`,children:[(0,Z.jsx)(`div`,{"data-slot":`thread-transcript`,role:`region`,"aria-label":`Session transcript`,tabIndex:0,children:(0,Z.jsx)(hs,{run:e,thread:t,history:r,footer:f,issueUrl:me,sections:ce,renderAsk:Se,renderPermission:fe,messageActions:H,scroll:K,mode:ge,taskTitles:ue,recipientBackends:de})}),(0,Z.jsx)(Zo,{run:e,thread:t,pinnedAsk:W,pendingQuestions:ie,scroll:K,onJump:()=>{let e=ie>0?W?.id:void 0;K.jumpToLatest(e===void 0?void 0:mi(e,()=>ve.current===e))},onShowOrigin:()=>be.current.reveal(),sessionOpen:h,attention:u,queued:_,continuable:C,continueAction:v,stopAction:y,finishAction:b,needsAnswer:x,sendMessage:R,reply:z,providerBlocked:B,providerReason:V,removedRunnerNotice:G,fold:oe})]}),A?(0,Z.jsx)(`aside`,{"data-slot":`thread-activity-sidebar`,"aria-label":`Session activity`,children:(0,Z.jsx)(lo,{presentation:`panel`,run:e,thread:t,currentThread:n,currentComplete:Ce,onOpenWorker:E})}):null]}),(0,Z.jsx)(Ji,{runId:e.id,renderAsk:Se,renderPermission:fe,agent:I,entries:L,taskTitles:ue,recipientBackends:de,onBeforeOpenReport:j,onRestoreAgentFocus:F,onClose:()=>E(void 0)})]})}function cs(e,t,n,r){return{openAgent:(0,X.useMemo)(()=>e===void 0?void 0:xr(t.turns,e,r,n.turns),[t.turns,e,r,n.turns]),openAgentChildren:(0,X.useMemo)(()=>e===void 0?[]:wr(n.turns,t.turns,e),[n.turns,t.turns,e])}}function ls(e,t){let n=e.delegation?.role===`root`||e.delegation?.role===`worker`,r=S(e.id,{enabled:n});return{taskTitles:(0,X.useMemo)(()=>({...Rr(e,void 0,r.data?.titles),...t?.titles,[e.id]:J(e)}),[e,t,r.data]),recipientBackends:(0,X.useMemo)(()=>({...t?.backends,...Lr(e,void 0)}),[e,t])}}function us(e){let[t,n]=(0,X.useState)(void 0),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!0),[s,c]=(0,X.useState)(e);s!==e&&(c(e),n(void 0),i(!1));let l=On(),u=Dn()||l?.open===!0,d=Ln(`(min-width: 1600px)`,!1)&&!u?`sidebar`:`popover`;return{openAgentId:t,setOpenAgentId:n,activityMode:d,activityOpen:d===`sidebar`?a:r,setActivityOpen:d===`sidebar`?o:i,showActivitySidebar:d===`sidebar`&&a,closeActivityPopover:(0,X.useCallback)(()=>i(!1),[])}}function ds(e,t){let{mutateAsync:n}=f(e.id),{mutateAsync:r}=l(e.id),{mutateAsync:i}=y(e.id);return(0,X.useMemo)(()=>{if(!t)return;let a={task:{onEdit:async e=>{await n({task:e})},editLabel:`Edit the prompt`}};for(let t of e.queuedMessages??[])a[`queued:${t.id}`]={onEdit:e=>r({msgId:t.id,message:{text:e}}).then(()=>void 0),onRemove:()=>i(t.id).then(()=>void 0)};return a},[t,e.queuedMessages,n,r,i])}function fs(e,t){let n=e?Dt(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function ps(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function ms(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function hs({run:e,thread:t,history:n,footer:r,issueUrl:i,sections:a,renderAsk:o,renderPermission:s,messageActions:c,scroll:l,mode:u,taskTitles:d,recipientBackends:f}){let p=Tn()===`changes`;return(0,Z.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,Z.jsx)(gs,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:l.loadOlder}):null,(0,Z.jsx)(Bi,{runId:e.id,viewId:`main`,sections:a,mode:`document`,renderAsk:o,renderPermission:s,messageActions:c,scrollControls:l,renderMode:u,taskTitles:d,recipientBackends:f}),t.turns.length===0?e.status===`queued`?(0,Z.jsx)(_s,{run:e}):(0,Z.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,Z.jsx)(Qe,{}):null,r&&r.state===`closed`?(0,Z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:G(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[r.label,me(fe(e))?(0,Z.jsx)(`a`,{"data-slot":`pr-link`,href:fe(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,me(i)?(0,Z.jsx)(`a`,{"data-slot":`issue-link`,href:i,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`&&!p?(0,Z.jsx)(Wn,{runId:e.id}):null]})}function gs({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,Z.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,Z.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-xs text-soft-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,Z.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function _s({run:e}){let t=Rn(v().data??[],e.id);return(0,Z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,Z.jsx)(Y,{tone:`neutral`,shape:`ring`}),(0,Z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,Z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{as as TaskThreadRoute};
@@ -1 +0,0 @@
1
- import{Ft as e}from"./queries-CAsaqjt8.js";import{n as t}from"./project-location-CevhmYtx.js";function n(){return{home:e().data?.homeDir??null,root:t()}}export{n as t};