cezarion 0.19.0-dev.8714 → 0.19.0-dev.8724

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 (90) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/accounts-section-DDKrIQHV.js +1 -0
  3. package/web/dist/assets/activity-motion-BTEsjlIe.js +1 -0
  4. package/web/dist/assets/{activity-route-DQ2vQVUG.js → activity-route-nAfZdSHs.js} +1 -1
  5. package/web/dist/assets/agent-config-section-SeeFuvxb.js +7 -0
  6. package/web/dist/assets/agent-defaults-section-BfBT817S.js +1 -0
  7. package/web/dist/assets/{appearance-CxkUoLLY.js → appearance-BTm4Q_SI.js} +1 -1
  8. package/web/dist/assets/automations-route-CBTOewMF.js +2 -0
  9. package/web/dist/assets/{change-counts-CW7O8g5Y.js → change-counts-npLATh-3.js} +1 -1
  10. package/web/dist/assets/{commit-list-Ca61W21s.js → commit-list-DkFgC3zM.js} +1 -1
  11. package/web/dist/assets/{diff-controls-_6OoQImc.js → diff-controls-Bg2hEd-d.js} +1 -1
  12. package/web/dist/assets/{diff-B5yQN9UD.js → diff-is16ZW0n.js} +2 -2
  13. package/web/dist/assets/{diff-stat-U7DT4Ilj.js → diff-stat-C7KB1kDX.js} +1 -1
  14. package/web/dist/assets/{diff-view-DFiA3y5a.js → diff-view-Cr8XQJSx.js} +1 -1
  15. package/web/dist/assets/{file-preview-v5_F5k3C.js → file-preview-Bnls5OJY.js} +1 -1
  16. package/web/dist/assets/folder-browser-6stmlyVQ.js +1 -0
  17. package/web/dist/assets/git-toolbar-CNKKRUHu.js +1 -0
  18. package/web/dist/assets/github-BqFTLhmt.js +1 -0
  19. package/web/dist/assets/global-activity-route-CWe04LvJ.js +2 -0
  20. package/web/dist/assets/{image-preview-2S3PEy8S.js → image-preview-DCUeM8u3.js} +1 -1
  21. package/web/dist/assets/index-CZ2f_VDZ.js +21 -0
  22. package/web/dist/assets/index-DefVZIaB.css +1 -0
  23. package/web/dist/assets/{markdown-nyVMLqM-.js → markdown-BlP4Ruj9.js} +1 -1
  24. package/web/dist/assets/nav-row-styles-D5HpOmDZ.js +1 -0
  25. package/web/dist/assets/{notifications-section-oiF-HLRZ.js → notifications-section-D74r_7fK.js} +1 -1
  26. package/web/dist/assets/{popover-BPgUYFyu.js → popover-CZV6tz9i.js} +1 -1
  27. package/web/dist/assets/preview-pane-connected-Bmczg9HP.js +3 -0
  28. package/web/dist/assets/projects-section-nCxUoesH.js +1 -0
  29. package/web/dist/assets/prompt-templates-section-BrLXH68w.js +1 -0
  30. package/web/dist/assets/reference-chip-D_AkXXCW.js +1 -0
  31. package/web/dist/assets/{remote-settings-notice-KN0zBmre.js → remote-settings-notice-DgXTd6s8.js} +1 -1
  32. package/web/dist/assets/repo-git-kl6QizKC.js +1 -0
  33. package/web/dist/assets/{report-reader-CeBbC_Jy.js → report-reader-CGmbDHza.js} +1 -1
  34. package/web/dist/assets/{reports-B-hz_AlB.js → reports-CTFaCJWS.js} +1 -1
  35. package/web/dist/assets/{resources-section-BywQtsIL.js → resources-section-BhRQQrVy.js} +1 -1
  36. package/web/dist/assets/review-panel-DJN1QoGx.js +11 -0
  37. package/web/dist/assets/run-header-CRtXOTxt.js +2 -0
  38. package/web/dist/assets/{run-header-Ccnr9k0X.css → run-header-DfEfupCk.css} +1 -1
  39. package/web/dist/assets/{select-ETUx1MVz.js → select-BfLaIiyd.js} +1 -1
  40. package/web/dist/assets/{session-context-section-2B1lqgAc.js → session-context-section-CaPupOFU.js} +2 -2
  41. package/web/dist/assets/settings-agent-picker-CzE4qiW7.js +1 -0
  42. package/web/dist/assets/settings-shell-AMRJAsgc.css +1 -0
  43. package/web/dist/assets/settings-shell-CpEw1Yep.js +1 -0
  44. package/web/dist/assets/{sidebar-section-Bamq8P_D.js → sidebar-section-Ct0x6SOQ.js} +1 -1
  45. package/web/dist/assets/{skills-BIhWfWYY.js → skills-D2HTiFIT.js} +1 -1
  46. package/web/dist/assets/{tab-link-DE6t7XkG.js → tab-link-BMblA2WK.js} +1 -1
  47. package/web/dist/assets/{task-changes-CBuihPwR.js → task-changes-4SjmpLQN.js} +1 -1
  48. package/web/dist/assets/{task-commits-BKHSmTUJ.js → task-commits-C6CoCyG9.js} +1 -1
  49. package/web/dist/assets/task-file-scope-BkUJ30q2.js +1 -0
  50. package/web/dist/assets/task-files-CCX3HTxx.js +1 -0
  51. package/web/dist/assets/{task-github-item-BhIl0YRe.js → task-github-item-DWLVVmvv.js} +1 -1
  52. package/web/dist/assets/task-thread-EBqjZ5Vz.js +2 -0
  53. package/web/dist/assets/task-thread-PDeU-fL6.css +1 -0
  54. package/web/dist/assets/{thread-state-C8v4gnTh.js → thread-state-DU6OEOIL.js} +1 -1
  55. package/web/dist/assets/{use-hand-to-agent-state-Ch0ok71s.css → use-hand-to-agent-state-BHaqyTxa.css} +1 -1
  56. package/web/dist/assets/use-hand-to-agent-state-DUkm37P-.js +1 -0
  57. package/web/dist/assets/workflows-CGHzfqLC.js +7 -0
  58. package/web/dist/assets/{workflows-DsE0ExV6.css → workflows-FH3RBKvk.css} +1 -1
  59. package/web/dist/assets/workspace-tools-9mkf36oR.js +1 -0
  60. package/web/dist/assets/{worktrees-section-w7yDtBtW.js → worktrees-section-B91kPX6V.js} +4 -4
  61. package/web/dist/assets/{zoomable-image-CIQl1Wpe.js → zoomable-image-6RTKhLGE.js} +1 -1
  62. package/web/dist/index.html +7 -7
  63. package/web/dist/assets/accounts-section-CQAZjNMH.js +0 -1
  64. package/web/dist/assets/activity-motion-Cjk0Ozs9.js +0 -1
  65. package/web/dist/assets/agent-config-section-6tcXGdqh.js +0 -7
  66. package/web/dist/assets/agent-defaults-section-DHdrzX19.js +0 -1
  67. package/web/dist/assets/automations-route-BFaRgLxq.js +0 -2
  68. package/web/dist/assets/folder-browser-CZiaPNK7.js +0 -1
  69. package/web/dist/assets/git-toolbar-C33icZYQ.js +0 -1
  70. package/web/dist/assets/github-DAftYTLP.js +0 -1
  71. package/web/dist/assets/global-activity-route-Dc0oqViK.js +0 -2
  72. package/web/dist/assets/index-1TLdjVro.css +0 -1
  73. package/web/dist/assets/index-7M_Uae0m.js +0 -21
  74. package/web/dist/assets/nav-row-styles-DKeXbc4N.js +0 -1
  75. package/web/dist/assets/preview-pane-connected-DgRQbaVm.js +0 -3
  76. package/web/dist/assets/projects-section-DtL1VsXT.js +0 -1
  77. package/web/dist/assets/prompt-templates-section-qK5TH9GX.js +0 -1
  78. package/web/dist/assets/reference-chip-bAUYx-Fl.js +0 -1
  79. package/web/dist/assets/repo-git-BY2jC4L2.js +0 -1
  80. package/web/dist/assets/review-panel-DV9yD5Zl.js +0 -8
  81. package/web/dist/assets/run-header-CZjnjsNk.js +0 -2
  82. package/web/dist/assets/settings-agent-picker-BdoxLNMP.js +0 -1
  83. package/web/dist/assets/settings-shell-BIhAcEF4.js +0 -1
  84. package/web/dist/assets/settings-shell-CqiAPuLq.css +0 -1
  85. package/web/dist/assets/task-files-CAPgay7C.js +0 -1
  86. package/web/dist/assets/task-thread-DwqQN87Q.js +0 -2
  87. package/web/dist/assets/task-thread-DzADOhZd.css +0 -1
  88. package/web/dist/assets/use-hand-to-agent-state-P0PYtQDy.js +0 -1
  89. package/web/dist/assets/workflows-Cp5n5AnS.js +0 -7
  90. package/web/dist/assets/workspace-tools-CsubVxbO.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{t as r}from"./utils-DSMR_WLb.js";import{Ht as i,Rt as a,Wt as o,Xt as s,ct as c,dn as l,q as u,rn as d,un as f}from"./queries-ClkIgWFx.js";import{En as p,Fn as m,Hr as h,In as g,Ln as _,Mn as v,Ot as ee,Ur as te,Wr as y,Zr as b,bn as x,br as S,er as ne,hi as C,ii as re,kn as w,n as T,ti as ie,tt as ae,zn as oe}from"./toaster-C-xqAWVX.js";import{B as E,F as D,G as se,I as O,J as ce,N as k,P as le,S as ue,T as de,W as A,Y as fe,j,z as pe}from"./live-protocol-DMhTnCmf.js";import{n as M}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as me}from"./run-detail-refresh-Bo51TspT.js";import{ft as he,t as ge}from"./design-icons-CzEoMH9c.js";import{t as _e}from"./createLucideIcon-BHp8sXmF.js";import{a as ve,n as ye,r as be}from"./review-panel-DV9yD5Zl.js";import{t as xe}from"./arrow-right-Dh_Lx3um.js";import{t as Se}from"./arrow-up-right-DKGzsMqY.js";import{t as Ce}from"./bot-TkDIw4y-.js";import{t as we}from"./external-link-BE6y205O.js";import{t as Te}from"./info-DA1x_4bz.js";import{t as Ee}from"./message-square-B-MD-8rD.js";import{a as De,o as Oe,r as ke}from"./tool-display-B9NN44oU.js";import{t as N}from"./button-B7MKxYjT.js";import{i as Ae,r as je,t as Me}from"./popover-BPgUYFyu.js";import{t as P}from"./project-router-CT6gVIcC.js";import"./attention--Y0CyzCN.js";import{t as F}from"./status-dot-BRzVlF2X.js";import{c as Ne,i as Pe,l as Fe,o as Ie,r as Le,s as Re}from"./report-selection-D9xJZoKb.js";import"./page-shell-7pLJMOgh.js";import{$t as ze}from"./index-7M_Uae0m.js";import{t as Be}from"./textarea-vJt9undk.js";var Ve=_e(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),I=e(t(),1),L=n(),R=fe(),z=pe().int().nonnegative(),B=A().min(1),He=E({title:A().max(160),toolKind:j([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:j([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:R,endedAt:R.optional()}).strict(),Ue=j([`pass`,`fail`,`pending`,`skipping`,`cancel`]),We=E({checks:k(E({name:A().max(100),bucket:Ue}).strict()).max(100),counts:E({pass:z,fail:z,pending:z,skipping:z,cancel:z}).strict(),truncated:O(!0).optional()}).strict(),Ge=D(`kind`,[E({kind:O(`human`),since:R,detail:E({question:A().max(500).optional(),reason:j([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:pe().int().positive().optional()}).strict()}).strict(),E({kind:O(`usage-limit`),detail:E({resumeAt:A()}).strict()}).strict(),E({kind:O(`workers`),since:R,deadline:R.optional(),detail:E({owed:z,total:z,settled:z,replies:O(!0).optional(),mode:ue.optional(),recipientRunIds:k(B)}).strict()}).strict(),E({kind:O(`peers`),since:R,deadline:R,detail:E({peerRunIds:k(B)}).strict()}).strict(),E({kind:O(`subagents`),since:R,deadline:R,detail:E({running:z}).strict()}).strict(),E({kind:O(`pr`),since:R,deadline:R,detail:E({number:pe().int().positive(),target:ne,checks:We.shape.checks.optional(),counts:We.shape.counts.optional(),truncated:O(!0).optional()}).strict()}).strict(),E({kind:O(`process`),since:R,deadline:R,detail:E({pid:pe().int(),note:A().optional()}).strict()}).strict(),E({kind:O(`plugin`),since:R,deadline:R.optional(),detail:E({pluginKind:A().min(1).max(64),summary:A().max(256)}).strict()}).strict(),E({kind:O(`timer`),since:R,deadline:R,detail:E({wakeAt:R,note:A().optional()}).strict()}).strict()]),Ke={runId:B,title:A(),status:S,rung:j(p),runner:ie.optional(),model:A().optional(),currentStepId:A().optional(),createdAt:A().optional(),startedAt:A().optional(),finishedAt:A().optional(),wait:Ge.optional(),tool:He.optional(),rate:k(z).length(30),error:A().max(200).optional()},qe=E({...Ke,revision:z,collected:le()}).strict(),Je=E({...Ke,workers:k(qe)}).strict(),Ye=E({requestId:ce(),relationship:j([`family`,`peer`]),senderRunId:B,recipientRunId:B,text:A().max(500),senderTitle:A().optional(),recipientTitle:A().optional(),createdAt:R,deadline:R.optional()}).strict(),Xe=E({requestId:ce(),senderRunId:B,recipientRunId:B,status:de.shape.status,observedAt:R}).strict(),Ze=E({generatedAt:R,projects:k(E({projectId:A(),name:A(),loaded:le(),unavailable:E({status:se([O(404),O(409),O(503)]),error:A()}).strict().optional(),inReview:z,tasks:k(Je),requests:k(Ye),closed:k(Xe)}).strict())}).strict();E({project:se([O(`default`),A().regex(x)]).optional()});var Qe=5e3,$e=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],et=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,tt=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,nt=`the Squawk server answered /workspace/activity with an unexpected body`;function rt(e){let t=Ze.safeParse(e);if(!t.success)throw new m(200,nt);return t.data}async function it(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return rt(await oe(await g.api.v1.workspace.activity.$get({query:n},_(t)),`/workspace/activity`))}function at(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var ot=new Date(0).toISOString();function st(e){return e!==void 0&&e!==ot&&!Number.isNaN(Date.parse(e))}var ct=new Set([404,409,503]);function lt(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??ot,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function ut(e,t){return new m(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var dt=(e,t)=>e.kind===`project`&&ct.has(t.status)?t.status:void 0;function ft(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,I.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,I.useMemo)(()=>$e(n),[n]),o=C(),s=re({queryKey:r,queryFn:async({signal:e})=>{let t=o.getQueryData(r);try{return at(t,await it(n,{signal:e}))}catch(e){let r=e instanceof m?dt(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return lt(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,I.useEffect)(()=>{let e=!0,t=t=>{o.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let i=dt(n,t);if(i!==void 0&&n.kind===`project`){o.setQueryData(r,e=>lt(e,n.projectId,i,t.message));return}let a=o.getQueryCache().find({queryKey:r,exact:!0});a?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:a.state.errorUpdateCount+1,fetchStatus:`idle`})})},s=n=>{let i;try{i=rt(n)}catch(e){t(e);return}o.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&o.setQueryData(r,e=>at(e,i))})},l=a(et(n),s),u=i(Qe),d,f=()=>{let e=h()===`finite`&&u!==!1;e&&!d?d=c({path:tt(n),intervalMs:u},(e,n)=>{n===void 0?s(e):t(ut(e,n))}):!e&&d&&(d(),d=void 0)};f();let p=y(f);return()=>{e=!1,p(),d?.(),l()}},[o,r,n]),s}var pt=e=>String(e).padStart(2,`0`);function V(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${pt(r)}:${pt(i)}`:`${r}:${pt(i)}`}function H(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r>=24)return`${Math.floor(r/24)}d`;let i=n%60;return r<6&&i>0?`${r}h ${i}m`:`${r}h`}function U(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var mt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function W(e){let t=Date.parse(e);return Number.isNaN(t)?e:mt.format(t)}var ht=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),gt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function G(e){let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?String(e):`${ht.format(t)}, ${gt.format(t)} ${vt()}`}function _t(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`just now`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function vt(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var yt=new Set([`queued`,`running`,`waiting`]),bt={review:`In review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},xt={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},K=e=>yt.has(e),St=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,q=e=>w(e.rung).tone,Ct=(e,t=`Deadline`)=>e?`${t} ${W(e)}`:void 0;function wt(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${St(t.length,`task`)}`}function Tt(e,t){let n=e.tool,r={verb:`Running`,tone:q(e),icon:`tool`},i=n?.endedAt!==void 0&&U(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${H(U(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function Et(e,t){let n={verb:`Needs you`,tone:q(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${St(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function Dt(e){return{verb:`Needs you`,tone:q(e),icon:`user`,main:`Permission`,action:`open`}}function Ot(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:q(e),since:t.since};if(o){let e=c.length>0?wt(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...J(`detail`,Ct(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${kt[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...J(`detail`,Ct(t.deadline))}}var kt={one:`One`,any:`Any`,all:`All`};function At(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var jt=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function Mt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=jt.reduce((e,t)=>e+i(t),0),o=jt.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var Nt=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function Pt(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=Nt.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=Mt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function Ft(e,t){let n={tone:q(e),since:t.since,...J(`detail`,Ct(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:At(t),...J(`checks`,r),...J(`overflow`,Mt(t)),...J(`checkSummary`,Pt(t))}}function J(e,t){return t===void 0?{}:{[e]:t}}function It(e,t,n){let r=q(e);switch(t.kind){case`workers`:return Ot(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:wt(`For`,t.detail.peerRunIds,n),detail:`Deadline ${W(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:St(t.detail.running,`native subagent`),detail:`Deadline ${W(t.deadline)}`};case`pr`:return Ft(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${V(U(t.since,n.now))} · deadline ${W(t.deadline)}`};case`plugin`:return{verb:`Waiting`,tone:r,icon:`timer`,since:t.since,main:t.detail.summary,...J(`detail`,Ct(t.deadline))};case`timer`:return{verb:`Waiting for timer`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${W(t.detail.wakeAt)} · in ${V(-U(t.detail.wakeAt,n.now))}`};case`usage-limit`:return Lt(e,t.detail.resumeAt,n);case`human`:return}}function Lt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${W(t)} · in ${V(r-n.now)}`;return{verb:`Paused`,tone:q(e),icon:`pause`,main:`Usage limit`,detail:i}}function Rt(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:q(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${H(U(n,t.now))}`}:{}}}function zt(e,t){return{verb:bt[e.status]??e.status,tone:q(e),icon:xt[e.status]??`done`,main:t}}function Bt(e,t){return K(e.status)?Vt(e,t):zt(e,St(e.workers.filter(e=>K(e.status)).length,`live worker`))}function Vt(e,t){let n=e.wait;switch(e.rung){case`running`:return Tt(e,t);case`needs-permission`:return Dt(e);case`needs-you`:return Et(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?Lt(e,n.detail.resumeAt,t):{verb:`Paused`,tone:q(e),icon:`pause`,main:`Usage limit`};case`queued`:case`waiting-for-capacity`:return Rt(e,t);default:return(n&&It(e,n,t))??Rt(e,t)}}function Ht(e,t,n){if(n!==void 0&&K(e.status))return{verb:`Asks parent`,tone:q(e),main:`“${n}”`,asks:!0};let r=Ut(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Ut(e,t){switch(e.status){case`done`:return zt(e,e.collected?`Collected`:`Ready to collect`);case`review`:return zt(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return zt(e,e.error??bt[e.status]??e.status);default:return Vt({...e,workers:[]},t)}}var Wt={success:`text-success`,pending:`text-signal-word-amber`,danger:`text-signal-word-red`,accent:`text-accent-text`,info:`text-info`,running:`text-status-running`,neutral:`text-muted-foreground`};function Gt({tone:e,className:t,children:n,...i}){return(0,L.jsx)(`span`,{...i,className:r(`bg-card-2`,{"text-success":e===`success`,"text-signal-word-amber":e===`pending`,"text-signal-word-red":e===`danger`,"text-accent-text":e===`accent`,"text-info":e===`info`,"text-status-running":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var Kt={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},qt={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`};function Jt(e,t){let n=w(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:Zt(e,t)??n.label}}var Yt=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function Xt(e){return e?.kind===`workers`&&!e.detail.replies&&e.detail.owed>0}function Zt(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`&&!Xt(n))return`waiting on parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return Yt(`waiting on`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`waiting on replies`;if(n?.kind===`workers`&&n.detail.owed>0)return Yt(`waiting on`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return Yt(`waiting for`,n.detail.running,`subagent`)}function Qt(e,t){if(K(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function $t({run:e,role:t}){let{tone:n,shape:i,label:a}=Jt(e,t);return(0,L.jsx)(`span`,{"data-activity-anchor":e.runId,className:r(`inline-flex size-[12px] shrink-0 items-center justify-center`,Qt(e,i)),children:(0,L.jsx)(F,{tone:n,shape:i,role:`img`,"aria-label":a})})}var en={pass:`bg-success`,fail:`bg-danger`,pending:`bg-info`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},tn=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function nn({checks:e,overflow:t,passed:n,className:i}){return(0,L.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:i??r(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,L.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:r(`h-[5px] min-w-px flex-1 rounded-[2px]`,en[e.bucket],tn(e.bucket,n.has(e.name)))},e.name)),t?(0,L.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-[10px] leading-none text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`i`,{className:r(`h-[5px] w-2 rounded-[2px]`,en[t.bucket])}),`+`,t.count]}):null]})}function rn({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),i=Math.max(4,...e);return(0,L.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:r(`block h-4 w-[62px] shrink-0`,t),children:[n>0?(0,L.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}):null,e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/i*14);return(0,L.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var an=`inline-flex min-w-0 items-center rounded-md border px-3 py-1 text-[12px] font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring max-md:min-h-11`;function on({scope:e,projectId:t,projectName:n}){let i=e=>r(an,e?`border-border bg-card text-foreground shadow-xs`:`border-transparent text-muted-foreground hover:text-foreground`);return(0,L.jsxs)(`nav`,{"aria-label":`Activity scope`,"data-slot":`activity-scope`,className:`inline-flex max-w-full rounded-lg border border-border bg-muted/60 p-1`,children:[t===null?null:(0,L.jsx)(M,{to:`/p/${encodeURIComponent(t)}/activity`,"aria-current":e===`project`?`page`:void 0,className:i(e===`project`),children:(0,L.jsx)(`span`,{className:`max-w-40 truncate`,title:n??t,children:n??t})}),(0,L.jsx)(M,{to:`/activity`,state:{activityProjectId:t},"aria-current":e===`all`?`page`:void 0,className:i(e===`all`),children:`All projects`})]})}function sn({grouped:e,onToggle:t}){return(0,L.jsxs)(`button`,{type:`button`,"data-slot":`activity-group-toggle`,"aria-pressed":e,onClick:t,className:r(`inline-flex h-9 items-center gap-1.5 rounded-lg border px-2.5 text-[12px] font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,e?`border-accent-text/60 bg-accent-strong/10 text-foreground`:`border-border bg-card text-muted-foreground hover:text-foreground`),children:[(0,L.jsx)(Ve,{"aria-hidden":`true`,className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Group by project`})]})}function cn(){let e=`flex items-center gap-2`;return(0,L.jsxs)(Me,{children:[(0,L.jsx)(Ae,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`activity-legend`,"aria-label":`Activity legend`,className:`inline-flex h-9 items-center gap-1.5 rounded-lg border border-border bg-card px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,children:[(0,L.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Legend`})]})}),(0,L.jsx)(je,{align:`end`,className:`w-80 text-[12px] text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Activity legend`}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`pending`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Needs answer`}),` — waiting for your reply`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`info`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Needs review`}),` — ready for diff review or PR`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`danger`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Failed`}),` — stopped with an error`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`running`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Working`}),` — running tools right now`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`info`,shape:`ring`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Ring`}),` — waiting on CI, peer, or timer`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`running`,shape:`workers`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Robot`}),` — waiting on its own workers`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(rn,{rate:[0,2,5,1,3,0,4,2],className:`w-[34px]`}),(0,L.jsx)(`span`,{children:`Heartbeat: tool calls, last 30 s`})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,L.jsx)(`path`,{d:`M2 5h30`,strokeWidth:2,strokeDasharray:`6 4`,className:`stroke-message-peer-accent`})}),(0,L.jsx)(`span`,{children:`Open peer request (task → task)`})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:[(0,L.jsx)(`path`,{d:`M2 5h24`,strokeWidth:2.2,strokeLinecap:`round`,strokeDasharray:`0 6`,className:`stroke-message-peer-accent opacity-80`}),(0,L.jsx)(`circle`,{cx:`29.5`,cy:`5`,r:`3`,strokeWidth:1.6,className:`fill-card stroke-message-peer-accent`})]}),(0,L.jsx)(`span`,{children:`Waiting for a peer to write`})]})]})})]})}function ln({scope:e,projectId:t,projectName:n,grouped:r,onToggleGroup:i}){return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(cn,{}),i?(0,L.jsx)(sn,{grouped:!!r,onToggle:i}):null,(0,L.jsx)(on,{scope:e,projectId:t,projectName:n})]})}function un({now:e,updatedAt:t,stale:n}){let i=t!==void 0&&!Number.isNaN(Date.parse(t));return(0,L.jsxs)(`span`,{"data-slot":`activity-clock`,"data-stale":n?`true`:void 0,title:G(e),className:`inline-flex items-center gap-1.5 text-[13px] text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`span`,{"data-tone":`success`,className:r(`inline-flex size-[12px] items-center justify-center`,!n&&`activity-pulse`),children:(0,L.jsx)(F,{tone:n?`neutral`:`success`,"aria-hidden":`true`})}),(0,L.jsx)(`b`,{className:r(`font-semibold`,n?`text-muted-foreground`:`text-success`),children:n?`Not updating`:`Live`}),i?(0,L.jsxs)(`span`,{children:[`· updated `,_t(U(t,e))]}):null]})}function dn({name:e,now:t,updatedAt:n,stale:r=!1,scopeSwitch:i}){return{title:`Activity`,scope:e,subtitle:t===void 0?void 0:(0,L.jsx)(un,{now:t,updatedAt:n,stale:r}),secondaryActions:i}}function fn({primary:e=!1}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(N,{variant:e?`primary`:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 py-1.5 max-md:min-h-11`,children:(0,L.jsx)(P,{to:`/new`,children:`New task`})}),(0,L.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 py-1.5 max-md:min-h-11`,children:(0,L.jsx)(P,{to:`/`,children:`View tasks`})})]})}function pn({value:e,bump:t}){return(0,L.jsx)(`strong`,{"data-bump":t===void 0?void 0:`true`,className:r(`font-semibold text-foreground tabular-nums`,t!==void 0&&`activity-bump`),children:e},t??`still`)}function Y({icon:e,count:t,label:n,bump:r}){return(0,L.jsxs)(`li`,{"data-slot":`activity-chip`,"data-chip":n,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground`,children:[e,(0,L.jsx)(pn,{value:t,bump:r}),` `,n]})}function mn({summary:e,tasksTo:t,bumps:n={}}){let r=e=>n[e]?.key;return(0,L.jsxs)(`ul`,{"data-slot":`activity-summary`,"aria-live":`polite`,"aria-label":`Summary`,className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`pending`,"aria-hidden":`true`}),count:e.needsYou,label:`needs you`,bump:r(`needsYou`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`running`,"aria-hidden":`true`}),count:e.working,label:`working`,bump:r(`working`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`running`,shape:`ring`,"aria-hidden":`true`}),count:e.waiting,label:`waiting`,bump:r(`waiting`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),count:e.queued,label:`queued`,bump:r(`queued`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`}),count:e.activeWorkers,label:`active workers`,bump:r(`activeWorkers`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(Ee,{"aria-hidden":`true`,className:`size-3.5 text-message-peer-accent`}),count:e.openRequests,label:`open requests`,bump:r(`openRequests`)}),(0,L.jsx)(`li`,{"data-slot":`activity-chip`,"data-chip":`in review`,children:(0,L.jsxs)(P,{to:t,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground transition-colors hover:border-accent-text/40 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11`,children:[(0,L.jsx)(F,{tone:`info`,"aria-hidden":`true`}),(0,L.jsx)(pn,{value:e.inReview,bump:r(`inReview`)}),` in review`,(0,L.jsx)(Se,{"aria-hidden":`true`,className:`size-3 text-soft-foreground`})]})})]})}function hn(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function gn(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function X(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var _n=(e,t)=>X(e,t.senderRunId,t.senderTitle),vn=(e,t)=>X(e,t.recipientRunId,t.recipientTitle),yn=(e,t)=>`wait:${e}:${t}`;function Z(e){let t=[];for(let n of e){let e=n.wait;if(!(!K(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:yn(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function bn(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function xn(e,t){return t.filter(t=>t.waiterRunId===e)}function Sn(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${vn(n,r)}`),r.recipientRunId===e&&i.push(`${_n(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${X(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${X(n,t.waiterRunId)} waits for you to write`);return i}function Cn(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function wn(e,t){let n=-U(e,t);return n>=1e3?`reply due in ${V(n)}`:`reply overdue`}function Tn(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function En(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:Dn[On(e,t)]}}var Dn={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function On(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var kn=new Set([`queued`,`waiting-for-capacity`]);function An(e){if(K(e.status))return v(e.rung)?`needsYou`:e.rung===`running`?`working`:kn.has(e.rung)?`queued`:`waiting`}function jn(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=An(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>K(e.status)).length}}return t}function Mn(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Nn({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var Q={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},$={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},Pn=(e,t)=>`${e}\n${t}`;function Fn(e,t){let n=Pn(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var In=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Ln={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function Rn(e,t){let n=Ln[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.workerHold+Q.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},Q.workerHold)}function zn(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},Q.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},Q.comet)}function Bn(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},Q.fade);return}let a=Q.comet+Q.replied+Q.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},Q.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},Q.comet+Q.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},Q.comet)}function Vn(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:w(t.task.rung).tone},Q.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},Q.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},Q.workerEnter);case`worker-settled`:return Rn(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},Q.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},Q.cardLeave);case`check-passed`:return e.timed(`checks`,Pn(t.runId,t.name),{},Q.check);case`request-opened`:return zn(e,t.request);case`request-closed`:return Bn(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},Q.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},Q.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},Q.fade)}}function Hn(e,t,n){let r=new In(t);if(!n)for(let t of e)Vn(r,t);return{changes:r.changes,timers:r.timers}}function Un(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function Wn(e,t){return t.reduce(Un,e)}function Gn(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}function Kn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=Tn(e,t),l=xn(e,n);return c.length===0&&l.length===0?null:(0,L.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,vn(r,e)]})},e.requestId)),l.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,X(r,e.peerRunId)]})},e.id))]})}var qn=e=>`/tasks/${encodeURIComponent(e)}`;function Jn({texts:e}){return e.length===0?null:(0,L.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,L.jsx)(`li`,{children:e},t))})}var Yn={compact:{base:`relative flex flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1 text-[12px] text-muted-foreground`,asks:`border-l-2 border-dashed border-message-inbound-accent bg-message-inbound-bg`,shape:void 0,title:`min-w-0 truncate text-[12px] font-medium text-foreground`,line:`truncate text-[11.5px] text-muted-foreground tabular-nums`,main:`text-foreground`},card:{base:`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,asks:`-mx-1.5 bg-message-inbound-bg px-1.5`,shape:`mt-[3px]`,title:`min-w-0 truncate text-[12.5px] font-medium text-foreground`,line:`col-start-2 truncate text-[11.5px] text-muted-foreground tabular-nums`,main:void 0}};function Xn({to:e,title:t,global:n}){let r=`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;return n?(0,L.jsx)(M,{to:e,className:r,children:t}):(0,L.jsx)(P,{to:e,className:r,children:t})}function Zn({worker:e,parentId:t,requests:n,index:i,ctx:a,motion:o,href:c,global:l=!1,compact:u=!1}){let f=Ht(e,a,Cn(e.runId,t,n)?.text),p=o.workerHold[e.runId],m=d().data,h=u?Yn.compact:Yn.card,g=[e.runner?s(m,e.runner):void 0,e.model].filter(Boolean).join(` · `);return(0,L.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":f.asks?`true`:void 0,"data-hold":p?.phase,className:r(h.base,f.asks&&h.asks,e.runId in o.workerEnter&&`activity-row-enter`,p?.phase===`fold`&&`activity-row-fold`),children:[p?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:r(`activity-row-flash`,qt[p.tone])},p.key):null,(0,L.jsx)(`span`,{className:h.shape,children:(0,L.jsx)($t,{run:e,role:`worker`})}),(0,L.jsxs)(`span`,{className:h.title,children:[(0,L.jsx)(Xn,{to:c??qn(e.runId),title:e.title,global:l}),g?(0,L.jsx)(`span`,{className:`ml-1.5 text-[11px] font-normal text-muted-foreground`,children:g}):null]}),(0,L.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:h.line,children:[(0,L.jsx)(`b`,{className:r(`font-semibold`,Wt[f.tone]),children:f.verb}),` · `,(0,L.jsx)(`span`,{className:r(h.main,f.mono&&`font-mono`),children:f.main})]}),(0,L.jsx)(Jn,{texts:Sn(e.runId,n,i)})]})}function Qn({workers:e}){return(0,L.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[e.map(e=>(0,L.jsx)($t,{run:e,role:`worker`},e.runId)),(0,L.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function $n({task:e,requests:t,index:n,ctx:r,dense:i=!1,motion:a,projectId:o,global:s=!1,compact:c=!1}){let l=e=>e in a.workerHold,u=e.workers.filter(e=>K(e.status)||e.status===`review`||l(e.runId)),d=Nn(Mn(e,l));if(u.length===0&&!d)return null;let f=e=>s&&o?`/p/${encodeURIComponent(o)}/tasks/${encodeURIComponent(e)}`:qn(e);return c?(0,L.jsxs)(`div`,{className:`ml-4 border-l border-border pl-3`,children:[u.length>0?(0,L.jsx)(`ul`,{"data-slot":`activity-workers`,className:`flex flex-col gap-0.5`,children:u.map(i=>(0,L.jsx)(Zn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a,href:f(i.runId),global:s,compact:!0},i.runId))}):null,d?(0,L.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1 px-2 text-[11px] text-muted-foreground`,children:d}):null]}):(0,L.jsxs)(L.Fragment,{children:[u.length>0&&i?(0,L.jsx)(Qn,{workers:u}):null,u.length>0&&!i?(0,L.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:u.map(i=>(0,L.jsx)(Zn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,d?(0,L.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-[11px] text-muted-foreground`,children:d}):null]})}function er(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function tr({task:e,motion:t,glow:n}){let i=t.flash[e.runId];return(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,i?(0,L.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":i.tone,"aria-hidden":`true`,className:r(`activity-flash`,Kt[i.tone])},i.key):null]})}var nr=e=>/(auto|scroll|hidden|clip)/.test(getComputedStyle(e).overflowY);function rr(e){let t=[];for(let n=e.parentElement;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)nr(n)&&t.push(n);return t}var ir=e=>({requestId:e.id,senderRunId:e.peerRunId,recipientRunId:e.waiterRunId});function ar({frame:e,cancel:t,draw:n}){let r=[],i,a=t=>{i=void 0,r=r.map(e=>({...e,start:e.start??t})).filter(e=>t<e.start+e.duration),n(r,t),r.length>0&&(i=e(a))};return{launch(t){r.some(e=>e.id===t.id)||(r.push(t),i===void 0&&(i=e(a)))},stop(){i!==void 0&&t(i),i=void 0,r=[],n([],0)},running:()=>i!==void 0}}var or=e=>e<.5?2*e*e:1-(-2*e+2)**2/2;function sr(e,t,n=0){let r=Math.min(1,Math.max(0,(t-e.start)/e.duration)),i=Math.max(0,or(r)-n);return e.reverse?1-i:i}var cr=`http://www.w3.org/2000/svg`,lr=[0,.03,.06,.09,.12],ur=[4.5,3.5,3,2.5,2],dr={peer:`fill-message-peer-accent`,family:`fill-message-inbound-accent`,success:`fill-success`};function fr(e,t){let n=e.querySelector(`g[data-comet="${CSS.escape(t.id)}"]`);if(n)return n;let r=document.createElementNS(cr,`g`);r.setAttribute(`data-comet`,t.id);let i=document.createElementNS(cr,`circle`);return i.setAttribute(`r`,`9`),i.setAttribute(`class`,`${dr[t.tone]} opacity-35`),r.append(i),lr.forEach((e,n)=>{let i=document.createElementNS(cr,`circle`);i.setAttribute(`r`,String(ur[n])),i.setAttribute(`class`,n===0?`fill-foreground`:dr[t.tone]),i.setAttribute(`opacity`,String(1-n*.15)),r.append(i)}),e.append(r),r}function pr(e,t,n){let r=new Set(t.map(e=>e.id));for(let t of e.querySelectorAll(`g[data-comet]`))r.has(t.getAttribute(`data-comet`)??``)||t.remove();let i=e.ownerSVGElement;for(let r of t){let t=i?.querySelector(`path[data-request="${CSS.escape(r.requestId)}"]`);if(!t||typeof t.getTotalLength!=`function`)continue;let a=t.getTotalLength();fr(e,r).querySelectorAll(`circle`).forEach((e,i)=>{let o=t.getPointAtLength(sr(r,n,lr[Math.max(0,i-1)])*a);e.setAttribute(`transform`,`translate(${o.x} ${o.y})`)})}}var mr=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(performance.now()),16),hr=e=>typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e);function gr(e,t,n){let r=I.useRef(null),i=I.useRef(void 0),a=I.useRef(new Set);return I.useEffect(()=>{let e=r.current;if(!e)return;let t=ar({frame:mr,cancel:hr,draw:(t,n)=>pr(e,t,n)});return i.current=t,()=>{t.stop(),i.current=void 0}},[]),I.useEffect(()=>{if(n){i.current?.stop();return}for(let t of a.current)t in e||a.current.delete(t);for(let[n,r]of Object.entries(e))a.current.has(n)||!t.has(r.requestId)||(a.current.add(n),i.current?.launch({id:n,requestId:r.requestId,reverse:r.reverse,tone:r.tone,duration:Q.comet}))},[e,t,n]),r}var _r=`activity-layout-settled`;function vr(e,t,n,r,i,a=!1){let[o,s]=I.useState([]);return I.useLayoutEffect(()=>{let i=e.current?.parentElement;if(!i)return;let o=()=>{let e=t(i);s(t=>n(t,e)?t:e)};o();let c=a?yr(i,o):void 0;i.addEventListener(_r,o);let l=typeof ResizeObserver>`u`?void 0:new ResizeObserver(o);l?.observe(i);for(let e of i.querySelectorAll(r))l?.observe(e);return()=>{l?.disconnect(),i.removeEventListener(_r,o),c?.()}},[e,t,n,r,i,a]),o}function yr(e,t){let n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=[...rr(e),window];for(let e of i)e.addEventListener(`scroll`,r,{passive:!0});return window.addEventListener(`resize`,r),()=>{for(let e of i)e.removeEventListener(`scroll`,r);window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n)}}function br(e,t){if(e.deadline!==void 0)return xr(e.createdAt,e.deadline,t)}function xr(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isNaN(r)||Number.isNaN(i)||i<=r?1:Math.min(1,Math.max(0,(n-r)/(i-r)))}function Sr(e,t){if(e===`fade`)return`activity-line-out`;if(e!==`replied`)return r(`activity-march`,t&&`activity-line-in`)}function Cr(e,t){return t in e.waitsClosing?`activity-line-out`:r(`activity-drift`,t in e.opening&&`activity-line-in`)}var wr=(e,t)=>e.closing[t]?.phase??`open`;function Tr(e,t){let n=e.closing[t];return n!==void 0&&n.replied&&n.phase!==`reply`}function Er({id:e}){return(0,L.jsx)(`marker`,{id:e,viewBox:`0 0 12 12`,refX:`10`,refY:`6`,markerWidth:`5`,markerHeight:`5`,markerUnits:`strokeWidth`,orient:`auto`,children:(0,L.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4`,strokeWidth:`2.4`,className:`fill-background stroke-message-peer-accent`})})}function Dr(e,t){let n=new Map;for(let r of[...e?.projects??[],...t.projects])for(let[e,t]of gn(r))n.set(e,t);return n}var Or={"timed-out":`timed out`,cancelled:`was cancelled`,destroyed:`closed: the recipient was destroyed`,failed:`closed: the recipient failed`,"completed-without-reply":`closed without a reply`,"sender-closed":`was closed by its sender`,"human-fallback":`went to a human`,deleted:`closed: the recipient was deleted`};function kr(e,t,n){let r=n(e.senderRunId,e.senderTitle),i=n(e.recipientRunId,e.recipientTitle);return t===`replied`?`${i} replied to ${r}`:`${r}’s request to ${i} ${Or[t??``]??`closed`}`}var Ar={done:{tone:`success`,word:`finished`},failed:{tone:`danger`,word:`failed`},cancelled:{tone:`neutral`,word:`was cancelled`},review:{tone:`info`,word:`waits for review`}},jr=e=>e.relationship===`peer`?`peer`:`family`;function Mr(e,t,n){let r=(e,n)=>X(t,e,n);switch(e.kind){case`request-opened`:return{tone:jr(e.request),text:`${r(e.request.senderRunId,e.request.senderTitle)} asked ${r(e.request.recipientRunId,e.request.recipientTitle)}`};case`request-closed`:return{tone:e.status===`replied`?`success`:`neutral`,text:kr(e.request,e.status,r)};case`rung-changed`:return{tone:w(e.task.rung).tone,text:`${e.task.title}: ${Bt(e.task,{now:n,titleOf:e=>r(e)}).verb}`};case`worker-started`:return{tone:`running`,text:`${e.worker.title} started`};case`worker-settled`:{let t=Ar[e.worker.status]??{tone:`neutral`,word:`settled`};return{tone:t.tone,text:`${e.worker.title} ${t.word}`}}case`card-entered`:return{tone:w(e.task.rung).tone,text:`${e.task.title} started`};case`card-left`:return{tone:`neutral`,text:`${e.task.title} left active work`};case`check-passed`:return{tone:`success`,text:`PR ${e.pr}: check “${e.name}” passed`};default:return}}function Nr(e,t,n,r){return[...t.map((e,t)=>({...e,id:r+t,at:n})),...e].slice(0,6)}function Pr(e){return Math.max(0,Math.floor(e/1e3))<5?`now`:H(e)}var Fr=`rounded-xl border border-border bg-card px-3.5 py-3`,Ir=`mb-2 flex gap-2 text-[11.5px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`;function Lr({request:e,index:t,now:n,motion:i}){let{kind:a,relation:o}=En(e,t),s=br(e,n),c=e.relationship===`peer`?`text-message-peer-accent`:`text-message-inbound-accent`;return(0,L.jsxs)(`li`,{"data-slot":i===`fold`?`activity-request-closing`:`activity-request`,"data-request":e.requestId,"aria-hidden":i===`fold`||void 0,className:r(`border-t border-border py-2.5 first:border-t-0 first:pt-0`,i===`enter`&&`activity-row-enter`,i===`fold`&&`activity-row-fold`),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[12px] font-medium`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:_n(t,e)}),(0,L.jsx)(xe,{"aria-label":`to`,className:`size-3 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:vn(t,e)}),(0,L.jsx)(`span`,{className:r(`ml-auto shrink-0 text-[10px] font-semibold tracking-[0.05em] uppercase`,c),children:a})]}),(0,L.jsxs)(`p`,{className:`my-1 line-clamp-3 text-[12px] text-muted-foreground`,children:[`“`,e.text,`”`]}),(0,L.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] text-muted-foreground tabular-nums`,children:[(0,L.jsxs)(`span`,{children:[o,` · open `,V(U(e.createdAt,n))]}),e.deadline?(0,L.jsx)(`span`,{className:`ml-auto`,children:wn(e.deadline,n)}):null]}),s===void 0?null:(0,L.jsx)(`div`,{"aria-hidden":`true`,className:`mt-1.5 h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,L.jsx)(`span`,{className:r(`block h-full bg-current`,c),style:{width:`${Math.round(s*100)}%`}})})]})}var Rr={...qt,peer:`bg-message-peer-accent`,family:`bg-message-inbound-accent`};function zr({feed:e,now:t}){return(0,L.jsxs)(`section`,{"data-slot":`activity-just-now`,className:Fr,children:[(0,L.jsx)(`h2`,{className:Ir,children:`Just now`}),(0,L.jsx)(`ul`,{"data-slot":`activity-feed`,children:e.map((e,n)=>(0,L.jsxs)(`li`,{"data-slot":`activity-feed-entry`,className:r(`grid grid-cols-[10px_minmax(0,1fr)_auto] items-baseline gap-2 py-1 text-[12px] text-muted-foreground`,n===0&&`activity-feed-enter`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:r(`size-[7px] -translate-y-px rounded-full`,Rr[e.tone])}),(0,L.jsx)(`span`,{className:`min-w-0`,children:e.text}),(0,L.jsx)(`span`,{"data-slot":`activity-feed-age`,className:`text-[11px] tabular-nums`,children:Pr(t-e.at)})]},e.id))})]})}function Br({requests:e,closing:t=[],index:n,now:i,feed:a=[],motion:o=$,columnGap:s}){let c=e.length>0||t.length>0,l=a.length>0;return!c&&!l?null:(0,L.jsxs)(`aside`,{"data-slot":`activity-rail`,"aria-label":`Activity details`,style:s===void 0?void 0:{columnGap:s},className:r(`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start items-start gap-4`,c&&l&&`md:grid-cols-2`),children:[c?(0,L.jsxs)(`section`,{"data-slot":`activity-open-requests`,className:Fr,children:[(0,L.jsxs)(`h2`,{className:Ir,children:[`Open requests `,(0,L.jsx)(`b`,{className:`text-foreground`,children:e.length})]}),(0,L.jsxs)(`ul`,{children:[e.map(e=>(0,L.jsx)(Lr,{request:e,index:n,now:i,motion:e.requestId in o.opening?`enter`:void 0},e.requestId)),t.map(e=>(0,L.jsx)(Lr,{request:e,index:n,now:i,motion:`fold`},e.requestId))]})]}):null,l?(0,L.jsx)(zr,{feed:a,now:i}):null]})}var Vr=new Set;function Hr(e){let[t,n]=I.useState({}),r=t.pointer??t.focus,i=I.useCallback((e,t)=>n(n=>n[e]===t?n:{...n,[e]:t}),[]);return{linked:I.useMemo(()=>r===void 0?Vr:bn(r,e),[r,e]),active:I.useMemo(()=>r===void 0?Vr:new Set(e.filter(e=>e.waiterRunId===r||e.peerRunId===r).map(e=>e.id)),[r,e]),onHover:i}}function Ur(e,t,n=Z(e.tasks)){let r=new Set(e.tasks.map(e=>e.runId)),i=new Set(e.requests.map(e=>e.requestId)),a=Object.values(t.closing).filter(t=>t.projectId===e.projectId&&!i.has(t.request.requestId));return{cards:Object.values(t.leaving).filter(t=>t.projectId===e.projectId&&!r.has(t.task.runId)).map(e=>e.task),requests:a.map(e=>e.request),waits:Gn(e.projectId,n,t),folding:a.filter(e=>e.phase===`reply`||!e.replied).map(e=>e.request)}}var Wr=36,Gr=22,Kr=4,qr=10;function Jr(e,t,n,r=$){let i=[],a=(e,t)=>{let r=n.get(e);return r!==void 0&&r===n.get(t)};for(let t of e){if(t.relationship!==`peer`||!a(t.senderRunId,t.recipientRunId))continue;let e=r.closing[t.requestId];i.push({kind:`request`,id:t.requestId,from:t.senderRunId,to:t.recipientRunId,createdAt:t.createdAt,...e?{closing:!0,replied:e.replied}:{}})}for(let e of t)a(e.peerRunId,e.waiterRunId)&&i.push({kind:`wait`,id:e.id,from:e.peerRunId,to:e.waiterRunId,since:e.since,...e.id in r.waitsClosing?{closing:!0}:{}});if(i.length===0)return{edges:i,gutterWidth:0};let o=Math.min(Kr,i.length);return{edges:i,gutterWidth:Math.min(132,64+(o-1)*Gr)}}function Yr(e,t,n){let r=new Set;if(!e)return r;for(let n of t)n.relationship===`peer`&&(n.senderRunId===e||n.recipientRunId===e)&&(r.add(n.senderRunId),r.add(n.recipientRunId));for(let t of n)(t.peerRunId===e||t.waiterRunId===e)&&(r.add(t.peerRunId),r.add(t.waiterRunId));return r}function Xr(e,t){return e.map(e=>{let n=t.get(e.from),r=t.get(e.to);if(!(!n||!r))return{edge:e,start:n,end:r,span:Math.abs(r.y-n.y)}}).filter(e=>e!==void 0).sort((e,t)=>e.span-t.span).map(({edge:e,start:t,end:n},r)=>{let i=r%Kr,a=Math.max(10,Math.min(t.x,n.x)-Wr-i*Gr),o=n.y-t.y,s=o>=0?1:-1,c=Math.min(qr,Math.abs(o)/2,Math.max(2,t.x-a-2)),l=e.kind===`request`?n.x-2:n.x-6;return{edge:e,path:[`M ${t.x} ${t.y}`,`L ${a+c} ${t.y}`,`Q ${a} ${t.y} ${a} ${t.y+s*c}`,`L ${a} ${n.y-s*c}`,`Q ${a} ${n.y} ${a+c} ${n.y}`,`L ${l} ${n.y}`].join(` `),laneX:a,labelY:t.y+o*(.5+(r%2==0?-.06:.08)),endX:n.x-4,endY:n.y}})}function Zr(e){let t=new Map,n=e.getBoundingClientRect();for(let r of e.querySelectorAll(`[data-activity-row]`)){let e=r.getAttribute(`data-activity-row`);if(!e)continue;let i=r.getBoundingClientRect();t.set(e,{x:i.left-n.left,y:i.top-n.top+Math.min(i.height/2,24)})}return t}function Qr({stage:e,edges:t,active:n,now:i,layoutKey:a,motion:o=$,paused:s=!1}){let c=I.useId(),[l,u]=I.useState([]);I.useLayoutEffect(()=>{if(!e||t.length===0){u([]);return}let n=()=>u(Xr(t,Zr(e)));if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,t,a]);let d=I.useMemo(()=>new Set(l.filter(e=>e.edge.kind===`request`).map(e=>e.edge.id)),[l]),f=gr(o.comets,d,s);return(0,L.jsxs)(`div`,{"data-slot":`activity-margin-arcs`,"aria-hidden":`true`,className:r(`pointer-events-none absolute inset-0 z-[5] hidden overflow-visible`,t.length>0&&`md:block`),children:[(0,L.jsxs)(`svg`,{className:`size-full overflow-visible`,children:[(0,L.jsx)(`defs`,{children:(0,L.jsx)(`marker`,{id:c,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,L.jsx)(`path`,{d:`M0 1 L7 4 L0 7 z`,className:`fill-message-peer-accent`})})}),l.map(e=>{let{edge:t}=e,i=n!==void 0&&(t.from===n||t.to===n),a=n!==void 0&&!i,o=t.kind===`request`?r(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-march`,t.closing&&`activity-line-out`):r(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-drift`,t.closing&&`activity-line-out`);return(0,L.jsxs)(`g`,{opacity:a?.22:i?1:.82,children:[(0,L.jsx)(`path`,{d:e.path,"data-request":t.kind===`request`?t.id:void 0,"data-wait":t.kind===`wait`?t.id:void 0,strokeWidth:i?2.4:1.8,strokeDasharray:t.kind===`request`?t.replied?void 0:`6 4`:`0 7`,strokeLinecap:t.kind===`wait`?`round`:void 0,markerEnd:t.kind===`request`?`url(#${c})`:void 0,className:o}),t.kind===`wait`?(0,L.jsx)(`circle`,{cx:e.endX,cy:e.endY,r:`3.2`,strokeWidth:`1.7`,className:`fill-card stroke-message-peer-accent`}):null]},`${t.kind}:${t.id}`)}),(0,L.jsx)(`g`,{ref:f})]}),l.map(e=>{let{edge:t}=e,a=n!==void 0&&(t.from===n||t.to===n),o=n!==void 0&&!a,s=V(U(t.kind===`request`?t.createdAt:t.since,i));return(0,L.jsx)(`span`,{style:{left:e.laneX,top:e.labelY},className:r(`absolute -translate-x-1/2 -translate-y-1/2 rounded-full border border-message-peer-accent/60 bg-card px-1.5 py-0.5 text-[10px] font-semibold whitespace-nowrap text-message-peer-accent tabular-nums shadow-xs transition-opacity`,t.kind===`wait`&&`border-dashed`,o&&`opacity-25`),children:t.kind===`request`?`Req · ${s}`:`Wait · ${s}`},`label:${t.kind}:${t.id}`)})]})}var $r={permission:0,answer:1,respond:2,review:3,failed:4},ei={running:0,waiting:1,queued:2,retained:3},ti=new Set([`queued`,`waiting-for-capacity`]);function ni(e){return e.status===`review`||e.status===`failed`||e.rung===`failed`||K(e.status)&&v(e.rung)}function ri(e){let{task:t}=e,n=t.wait?.kind===`human`?t.wait:void 0;if(n?.detail.reason===`question`)return{...e,kind:`answer`,stateLabel:`Needs answer`,tone:`pending`,blockingReason:n.detail.question??`The agent asked a question and is waiting for your answer.`,ageSince:n.since,actionLabel:`Answer`};if(n?.detail.reason===`budget`){let t=n.detail.queuedMessages;return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:t?`Automatic wakes used up · ${t} queued ${t===1?`message`:`messages`} waiting.`:`Automatic wakes used up.`,ageSince:n.since,actionLabel:`Respond`}}return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:`Your turn to reply or finish the task.`,ageSince:n?.since??t.startedAt??t.createdAt,actionLabel:`Respond`}}function ii(e,t){let n={runId:t.runId,projectId:e.projectId,projectName:e.name,task:t},r=t.finishedAt??t.startedAt??t.createdAt;if(t.rung===`needs-permission`){let e=t.wait&&`since`in t.wait?t.wait.since:void 0;return{...n,kind:`permission`,stateLabel:`Needs permission`,tone:`pending`,blockingReason:`Waiting for permission approval before continuing.`,ageSince:e??t.startedAt??t.createdAt,actionLabel:`Open task`}}return t.status===`review`||t.rung===`needs-review`?{...n,kind:`review`,stateLabel:`Needs review`,tone:`info`,blockingReason:`Changes are ready for review before anything lands.`,ageSince:r,actionLabel:`Review`}:t.status===`failed`||t.rung===`failed`?{...n,kind:`failed`,stateLabel:`Failed`,tone:`danger`,blockingReason:t.error??`Task stopped with an error.`,ageSince:r,actionLabel:`Inspect`}:ri(n)}function ai(e){return K(e.status)?e.rung===`running`?`running`:ti.has(e.rung)?`queued`:`waiting`:`retained`}var oi=e=>{if(!e)return 1/0;let t=Date.parse(e);return Number.isNaN(t)?1/0:t};function si(e){let t=[],n=[];for(let r of e)for(let e of r.tasks)ni(e)?t.push(ii(r,e)):n.push({runId:e.runId,projectId:r.projectId,projectName:r.name,task:e,tier:ai(e)});return t.sort((e,t)=>$r[e.kind]-$r[t.kind]||oi(e.ageSince)-oi(t.ageSince)||e.runId.localeCompare(t.runId)),n.sort((e,t)=>ei[e.tier]-ei[t.tier]),{attention:t,working:n}}function ci(e,t){let n=new Map;for(let t of e){let e=n.get(t.projectId);e?e.items.push(t):n.set(t.projectId,{projectId:t.projectId,projectName:t.projectName,items:[t]})}let r=new Map(t.map((e,t)=>[e,t]));return[...n.values()].sort((e,t)=>(r.get(e.projectId)??2**53-1)-(r.get(t.projectId)??2**53-1)||e.projectName.localeCompare(t.projectName))}function li(e,t,n,r){let i=new Map;for(let n of t)n.relationship===`peer`&&n.recipientRunId===e&&i.set(n.senderRunId,X(r,n.senderRunId,n.senderTitle));for(let t of n)t.peerRunId===e&&i.set(t.waiterRunId,X(r,t.waiterRunId));let a=[...i.values()];if(a.length!==0)return a.length===1?`Unblocks ${a[0]}`:a.length===2?`Unblocks ${a[0]} + ${a[1]}`:`Unblocks ${a[0]} + ${a.length-1} more`}function ui(e,t){if(e===void 0)return;let n=t.filter(t=>!e.has(t.runId));if(n.length!==0)return n.length===1?`New item needs your decision: ${n[0].task.title}`:`${n.length} new items need your decision`}var di={permission:`border-l-pending`,answer:`border-l-pending`,respond:`border-l-pending`,review:`border-l-info`,failed:`border-l-danger`},fi=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,pi=[],mi=[],hi=new Map;function gi(e,t,n){return n?`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`}function _i({items:e,grouped:t,projectOrder:n,countSuffix:r,renderItems:i}){return t?(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:ci(e,n).map(e=>(0,L.jsxs)(`div`,{"data-slot":`activity-project-group`,"data-project":e.projectId,className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h3`,{className:`flex items-center gap-2 text-[12.5px] font-semibold text-foreground`,children:[(0,L.jsx)(`span`,{children:e.projectName}),(0,L.jsxs)(`span`,{className:`text-[11.5px] font-normal text-muted-foreground tabular-nums`,children:[e.items.length,` `,r]})]}),i(e.items)]},e.projectId))}):(0,L.jsx)(L.Fragment,{children:i(e)})}var vi={permission:`text-foreground`,answer:`text-foreground`,respond:`text-foreground`,review:`text-muted-foreground`,failed:`font-mono text-[12px] text-signal-word-red`};function yi({href:e,title:t,global:n}){let r=`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:min-w-11 max-md:items-center pointer-coarse:inline-flex pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:items-center`;return n?(0,L.jsx)(M,{to:e,className:r,children:t}):(0,L.jsx)(P,{to:e,className:r,children:t})}function bi({record:e,href:t,global:n,selected:r,onTriage:i}){return e.kind===`permission`?(0,L.jsx)(N,{asChild:!0,size:`sm`,variant:`primary`,className:`min-h-9 max-md:min-h-11 max-md:flex-1`,children:n?(0,L.jsx)(M,{to:t,children:e.actionLabel}):(0,L.jsx)(P,{to:t,children:e.actionLabel})}):(0,L.jsx)(N,{type:`button`,size:`sm`,variant:e.kind===`answer`||e.kind===`respond`?`primary`:`outline`,"data-slot":`activity-triage-trigger`,"aria-expanded":r,className:`min-h-9 max-md:min-h-11 max-md:flex-1`,onClick:t=>i(e,t.currentTarget),children:e.actionLabel})}function xi({record:e,requests:t,waits:n,index:i,now:a,global:o,selected:c,linked:l,motion:u,onHover:f,onTriage:p}){let m=d().data,{task:h}=e,g=[h.runner?s(m,h.runner):void 0,h.model,h.currentStepId?`step ${h.currentStepId}`:void 0].filter(Boolean).join(` · `),_=li(e.runId,t,n,i),v=gi(e.projectId,e.runId,o),ee={now:a,titleOf:e=>i.get(e)?.title??`Unreadable task`},te=h.workers.length>0;return(0,L.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-decision`,"data-decision-kind":e.kind,"data-rung":h.rung,"data-selected":c?`true`:void 0,"data-linked":l?`true`:void 0,...er(e.runId,f),className:r(`relative grid min-w-0 grid-cols-1 items-center gap-3 rounded-xl border border-border border-l-[3px] bg-card px-4 py-3 transition-colors md:grid-cols-[minmax(0,1fr)_auto] md:gap-x-4`,di[e.kind],c&&`border-accent-text bg-accent-strong/[0.06]`,l&&`outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in u.entering&&`activity-card-enter`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,L.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 text-[12px] font-semibold`,Wt[e.tone]),children:[(0,L.jsx)($t,{run:h,role:`root`}),(0,L.jsx)(`span`,{"data-slot":`activity-verb`,children:e.stateLabel})]}),(0,L.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-semibold text-foreground`,children:(0,L.jsx)(yi,{href:v,title:h.title,global:o})}),(0,L.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,L.jsx)(`span`,{"data-slot":`activity-age`,title:G(e.ageSince),className:`text-[12px] text-muted-foreground tabular-nums`,children:H(U(e.ageSince,a))}):null]}),(0,L.jsx)(`p`,{"data-slot":`activity-main`,className:r(`break-words text-[13px] leading-relaxed`,vi[e.kind]),children:e.blockingReason}),g||_?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11.5px] text-muted-foreground`,children:[g?(0,L.jsx)(`span`,{children:g}):null,_?(0,L.jsxs)(`span`,{"data-slot":`activity-unblocks`,className:`font-medium text-message-peer-accent`,children:[`· `,_]}):null]}):null,(0,L.jsx)(Kn,{runId:e.runId,requests:t,waits:n,index:i,link:o?M:P,pathOf:t=>o?`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`,className:`mt-1 flex flex-col gap-0.5 md:hidden`,linkClassName:fi})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-2 max-md:w-full`,children:(0,L.jsx)(bi,{record:e,href:v,global:o,selected:c,onTriage:p})}),te?(0,L.jsx)(`div`,{className:`min-w-0 md:col-span-2`,children:(0,L.jsx)($n,{task:h,requests:t,index:i,ctx:ee,motion:u,projectId:e.projectId,global:o,compact:!0})}):null,(0,L.jsx)(Jn,{texts:Sn(e.runId,t,i,n)})]})}function Si({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,selectedRunId:c,linkedIds:l,motion:u=$,onHover:d,onTriage:f}){return e.length===0?null:(0,L.jsxs)(`section`,{"data-slot":`activity-attention`,"aria-label":`Needs your decision`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Needs your decision`}),(0,L.jsx)(`span`,{"data-slot":`activity-attention-count`,className:`inline-flex items-center rounded-full bg-inbox-count px-2 py-0.5 text-[11.5px] font-semibold text-inbox-count-foreground tabular-nums`,children:e.length}),(0,L.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Resolve inline without leaving the queue`})]}),(0,L.jsx)(_i,{items:e,grouped:o,projectOrder:s,countSuffix:`waiting`,renderItems:e=>(0,L.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:e.map(e=>(0,L.jsx)(xi,{record:e,requests:t.get(e.projectId)??pi,waits:n.get(e.projectId)??mi,index:r.get(e.projectId)??hi,now:i,global:a,selected:c===e.runId,linked:l.has(e.runId),motion:u,onHover:d,onTriage:f},e.runId))})})]})}function Ci(e){return`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.runId)}`}function wi(e){return{...e.id===void 0?{}:{id:e.id},header:e.header,question:e.question,...e.options===void 0?{}:{options:e.options.map(e=>({label:e.label,...e.description===void 0?{}:{description:e.description}}))},...e.multiSelect===void 0?{}:{multiSelect:e.multiSelect},...e.allowFreeText===void 0?{}:{allowFreeText:e.allowFreeText}}}function Ti(e,t){let n=De(t);if(!n)return;let r=ke(n);if(r)return{kind:`ask`,id:r.id,questions:r.questions.map(wi),...r.context===void 0?{}:{context:r.context},resolved:!1,...e.delegation?.role===`worker`?{parentRunId:e.delegation.parentRunId}:{}}}function Ei({run:e,projectId:t,prompt:n,onResolved:r}){let i=ze(e,t),a=be(e.id,{projectId:t,onSuccess:r}),[o,s]=(0,I.useState)(``),c=async()=>{let e=o.trim();e&&await i.send(e)===void 0&&(s(``),r())};return(0,L.jsxs)(`div`,{"data-slot":`activity-quick-reply`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-3.5`,children:[(0,L.jsx)(`p`,{className:`text-[13px] text-foreground`,children:n}),(0,L.jsx)(Be,{"aria-label":`Reply to task`,placeholder:`Write your reply…`,rows:3,value:o,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>s(e.target.value),className:`bg-background text-base md:text-[13px]`}),i.reason?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:i.error}):null,(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`primary`,className:`min-h-11`,disabled:i.isPending||i.blockedBy!==void 0||o.trim().length===0,onClick:()=>void c(),children:`Send reply`}),e.finishBlocked===null?(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,className:`min-h-11`,disabled:a.isPending,onClick:()=>a.mutate(),children:`Finish task`}):null]})]})}function Di({record:e,run:t,onResolved:n}){let r=re({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId,e.ageSince??``,e.blockingReason],queryFn:({signal:t})=>ee(e.runId,{projectId:e.projectId,signal:t}),staleTime:0,gcTime:0,refetchOnMount:`always`});if(r.isPending)return(0,L.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading question…`});let i=r.data?Ti(t,r.data.contextEvents):void 0;return i?(0,L.jsx)(ve,{ask:i,run:t,projectId:e.projectId,onAnswered:n}):(0,L.jsx)(Ei,{run:t,projectId:e.projectId,prompt:e.blockingReason,onResolved:n})}function Oi({record:e,run:t,onResolved:n}){let r=C(),i=ze(t,e.projectId),[a,s]=(0,I.useState)(``),c=l({mutationFn:()=>ae(f(e.runId,{projectId:e.projectId}),!0),onSuccess:()=>{T(`Failed task archived.`),r.invalidateQueries({queryKey:o.runs.all}),n()},onError:e=>T(e.message,{tone:`danger`})}),u=async()=>{let e=a.trim()||`Continue and resolve the failure.`;await i.send(e)===void 0&&(T(`Task resumed.`),n())},d=t.error??e.blockingReason;return(0,L.jsxs)(`div`,{"data-slot":`activity-failed-triage`,className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border border-danger/40 bg-card-2 p-3.5`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-signal-word-red`,children:`Failure details`}),(0,L.jsx)(`pre`,{className:`mt-2 overflow-x-auto font-mono text-xs whitespace-pre-wrap text-foreground`,children:d})]}),i.mode===`unavailable`?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:`activity-retry-note`,className:`text-xs font-medium text-foreground`,children:`Retry instruction (optional)`}),(0,L.jsx)(Be,{id:`activity-retry-note`,rows:2,placeholder:`Leave blank to continue and resolve the failure…`,value:a,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`}),i.reason?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:i.error}):null]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.mode===`unavailable`?null:(0,L.jsxs)(N,{type:`button`,size:`sm`,variant:`primary`,className:`min-h-11`,disabled:i.isPending||i.blockedBy!==void 0,onClick:()=>void u(),children:[(0,L.jsx)(Oe,{"aria-hidden":`true`,className:`size-3.5`}),`Retry task`]}),(0,L.jsxs)(N,{type:`button`,size:`sm`,variant:`outline`,className:`min-h-11`,disabled:c.isPending,onClick:()=>c.mutate(),children:[(0,L.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5`}),`Archive`]})]})]})}function ki(e){let{task:t}=e,n=t.workers.map(e=>`${e.runId}:${e.status}`).join(`,`);return`${t.status}|${t.rung}|${t.finishedAt??``}|${t.error??``}|${e.ageSince??``}|${n}`}function Ai({record:e,onResolved:t}){let n=C(),r=u(e.projectId,e.runId,!0,{staleTime:0,refetchOnMount:`always`}),i=ki(e),a=(0,I.useRef)(i);if((0,I.useEffect)(()=>{if(a.current===i)return;a.current=i;let t=!1,r=[e.projectId,`runs`,`detail`,e.runId];return me(n,r),n.cancelQueries({queryKey:r,exact:!0}).then(()=>{t||n.refetchQueries({queryKey:r,exact:!0,type:`active`})}),e.kind===`review`&&n.invalidateQueries({queryKey:[e.projectId,`runs`,`diff`,e.runId],exact:!0}),()=>{t=!0}},[i,n,e.kind,e.projectId,e.runId]),(0,I.useEffect)(()=>{let t=[e.projectId,`runs`,`detail`,e.runId];return te(()=>(me(n,t),n.cancelQueries({queryKey:t,exact:!0}).then(()=>n.refetchQueries({queryKey:t,exact:!0,type:`active`}))))},[n,e.projectId,e.runId]),r.isPending)return(0,L.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading task details…`});if(r.isError||!r.data)return(0,L.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 text-xs text-danger`,children:[(0,L.jsxs)(`p`,{children:[`Could not load task details: `,r.error?.message??`task unavailable`,`.`]}),(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,className:`min-h-11 self-start`,onClick:()=>void r.refetch(),children:`Retry`})]});let o=r.isFetching&&r.data.finishBlocked!==void 0?{...r.data,finishBlocked:void 0}:r.data;return e.kind===`answer`?(0,L.jsx)(Di,{record:e,run:o,onResolved:t}):e.kind===`review`?(0,L.jsx)(ye,{run:o,projectId:e.projectId,onResolved:t}):e.kind===`failed`?(0,L.jsx)(Oi,{record:e,run:o,onResolved:t}):(0,L.jsx)(Ei,{run:o,projectId:e.projectId,prompt:e.blockingReason,onResolved:t})}function ji({record:e,selectionToken:t,resolved:n=!1,now:i,onClose:a,onResolved:o,onRestoreFocus:s}){let c=C();return(0,L.jsx)(Pe,{open:e!==null,onOpenChange:e=>{e||a()},children:(0,L.jsx)(Ie,{side:`right`,showCloseButton:!1,"data-slot":`activity-triage-drawer`,onCloseAutoFocus:e=>{s&&(e.preventDefault(),s())},className:`flex h-full w-full flex-col gap-0 p-0 data-[state=closed]:duration-150 data-[state=open]:duration-200 sm:max-w-lg`,children:e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(Ne,{className:`flex-row items-start justify-between gap-3 border-b border-border bg-card px-4 py-3.5`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:r(`text-xs font-semibold`,Wt[e.tone]),children:e.stateLabel}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,L.jsx)(`span`,{title:G(e.ageSince),className:`text-xs text-muted-foreground tabular-nums`,children:H(U(e.ageSince,i))}):null]}),(0,L.jsx)(Fe,{className:`mt-1 truncate text-[16px] leading-snug`,children:e.task.title}),(0,L.jsxs)(Re,{className:`sr-only`,children:[`Resolve `,e.stateLabel.toLowerCase(),` for `,e.task.title,` without leaving Live Activity.`]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(N,{asChild:!0,size:`sm`,variant:`ghost`,className:`min-h-11 px-2.5 text-xs`,children:(0,L.jsxs)(M,{to:Ci(e),children:[`Open task`,(0,L.jsx)(we,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,L.jsx)(N,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Close triage drawer`,className:`size-11`,onClick:a,children:(0,L.jsx)(he,{"aria-hidden":`true`,className:`size-4`})})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n?(0,L.jsxs)(`div`,{"data-slot":`activity-triage-resolved`,role:`status`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4 text-[13px] text-muted-foreground`,children:[(0,L.jsx)(`p`,{className:`text-foreground`,children:`This task no longer needs your decision.`}),(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,className:`min-h-11 self-start`,onClick:a,children:`Close`})]}):(0,L.jsx)(Ai,{record:e,onResolved:((e,t)=>()=>{c.invalidateQueries({queryKey:[`workspace`,`activity`]}),c.invalidateQueries({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId]}),c.invalidateQueries({queryKey:[e.projectId,`runs`,`detail`,e.runId],exact:!0}),o(e.runId,t)})(e,t)},`${e.projectId}:${e.runId}:${e.kind}:${t??0}`)})]}):null})})}var Mi=12,Ni={fail:4,pending:3,pass:2,skipping:1,cancel:0};function Pi(e,t){let n=e.slice(Mi);if(n.length===0)return t;let r=n.length+(t?.count??0),i=t?.bucket??n[0].bucket;for(let e of n)Ni[e.bucket]>Ni[i]&&(i=e.bucket);return{count:r,bucket:i}}function Fi({record:e,requests:t,waits:n,index:i,ctx:a,global:o,linked:s,motion:c,onHover:l}){let{task:u}=e,d=Bt(u,a),f=gi(e.projectId,e.runId,o),p=u.startedAt??d.since??u.createdAt,m=c.slides[u.runId]?.key,h=Fn(c,u.runId);return(0,L.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-working-row`,"data-rung":u.rung,"data-linked":s?`true`:void 0,...er(e.runId,l),className:r(`relative flex min-w-0 flex-col gap-1.5 px-3.5 py-2.5 transition-colors first:rounded-t-xl last:rounded-b-xl`,s&&`bg-message-peer-bg outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in c.entering&&`activity-card-enter`),children:[(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-1 md:grid-cols-[14px_minmax(0,1.25fr)_minmax(0,1.45fr)_auto_auto]`,children:[(0,L.jsx)($t,{run:u,role:`root`}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`min-w-0 truncate text-[13px] font-semibold text-foreground`,children:o?(0,L.jsx)(M,{to:f,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:u.title}):(0,L.jsx)(P,{to:f,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:u.title})}),(0,L.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.projectName}),u.currentStepId?(0,L.jsxs)(`span`,{"data-slot":`activity-step`,className:`hidden shrink-0 text-[11px] text-muted-foreground sm:inline`,children:[`step `,u.currentStepId]}):null]}),(0,L.jsxs)(`div`,{className:`col-span-2 col-start-2 flex min-w-0 items-center gap-2 text-[12px] text-muted-foreground md:col-span-1 md:col-start-3`,children:[(0,L.jsx)(`span`,{"data-slot":`activity-verb`,className:r(`shrink-0 font-semibold`,Wt[d.tone]),children:d.verb}),(0,L.jsx)(`span`,{"data-slot":`activity-main`,className:r(`min-w-0 truncate text-foreground`,d.mono&&`font-mono text-[11.5px]`,m!==void 0&&`activity-slide`),children:d.main},m??`still`),d.checks&&d.checks.length>0?(0,L.jsx)(nn,{checks:d.checks.slice(0,Mi),overflow:Pi(d.checks,d.overflow),passed:h,className:`hidden w-20 shrink-0 items-center gap-[2px] sm:inline-flex`}):null,d.checkSummary?(0,L.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:d.checkSummary}):null]}),(0,L.jsx)(rn,{rate:u.rate,className:`hidden h-3.5 w-[52px] md:block`}),p?(0,L.jsx)(`span`,{"data-slot":`activity-elapsed`,title:G(p),className:`col-start-3 row-start-1 justify-self-end text-[12px] text-muted-foreground tabular-nums md:col-start-5`,children:H(U(p,a.now))}):(0,L.jsx)(`span`,{className:`col-start-3 row-start-1 md:col-start-5`})]}),(0,L.jsx)(Jn,{texts:Sn(e.runId,t,i,n)}),(0,L.jsx)(Kn,{runId:e.runId,requests:t,waits:n,index:i,link:o?M:P,pathOf:t=>gi(e.projectId,t,o),className:`ml-6 flex flex-col gap-0.5 md:hidden`,linkClassName:fi}),(0,L.jsx)($n,{task:e.task,requests:t,index:i,ctx:a,motion:c,projectId:e.projectId,global:o,compact:!0})]})}function Ii({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,linkedIds:c,motion:l=$,onHover:u}){return e.length===0?null:(0,L.jsxs)(`section`,{"data-slot":`activity-working`,"aria-label":`Working and active tasks`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Working & active`}),(0,L.jsx)(`span`,{"data-slot":`activity-working-count`,className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-[11.5px] font-semibold text-foreground tabular-nums`,children:e.length}),(0,L.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Live tool activity, waits, and worker trees`})]}),(0,L.jsx)(_i,{items:e,grouped:o,projectOrder:s,countSuffix:`active`,renderItems:e=>(0,L.jsx)(`div`,{className:`divide-y divide-border rounded-xl border border-border bg-card`,children:e.map(e=>{let o=r.get(e.projectId)??hi,s={now:i,titleOf:e=>o.get(e)?.title??`Unreadable task`};return(0,L.jsx)(Fi,{record:e,requests:t.get(e.projectId)??pi,waits:n.get(e.projectId)??mi,index:o,ctx:s,global:a,linked:c.has(e.runId),motion:l,onHover:u},e.runId)})})})]})}function Li(e){let t=new Map;for(let n of e)for(let[e,r]of gn(n))t.set(e,r);return t}function Ri(e,t){let n=[],r=[],i=[];for(let a of e){let e=Ur(a,t);n.push(...e.requests),r.push(...e.folding),i.push(...Gn(a.projectId,Z(a.tasks),t))}return{requests:n,folding:r,waits:i}}function zi(e,t){if(!e)return{activeDecision:null,resolvedExternally:!1};let n=t.find(t=>t.runId===e.runId&&t.projectId===e.projectId)??null;return{activeDecision:n??e.snapshot,resolvedExternally:n===null}}function Bi(e){return e<=0?{"data-has-arcs":void 0,style:void 0,className:`relative flex min-w-0 flex-col gap-6`}:{"data-has-arcs":`true`,style:{"--activity-arc-gutter":`${e}px`},className:`relative flex min-w-0 flex-col gap-6 md:pl-(--activity-arc-gutter)`}}function Vi(e){let[t,n]=I.useState(void 0),r=I.useRef(void 0),i=I.useRef(void 0),a=I.useRef(void 0);return I.useEffect(()=>{let t=ui(r.current,e);if(r.current=new Set(e.map(e=>e.runId)),t){if(a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0),i.current!==t){i.current=t,n(t);return}n(``),a.current=window.setTimeout(()=>{a.current=void 0,i.current=t,n(t)},0)}},[e]),I.useEffect(()=>()=>{a.current!==void 0&&window.clearTimeout(a.current)},[]),t}function Hi(e,t,n){if(e&&e.isConnected){e.focus({preventScroll:!0});return}(t?.querySelector(`[data-slot="activity-triage-trigger"]`)??n)?.focus({preventScroll:!0})}function Ui({projects:e,now:t,global:n,grouped:r,projectOrder:i,motion:a=$,feed:o=[],still:s=!1,paused:c=!1,emptyMessage:l}){let u=I.useRef(null),[d,f]=I.useState(null),p=I.useRef(0),[m,h]=I.useState(null),g=I.useRef(null),[_,v]=I.useState({}),ee=I.useMemo(()=>Li(e),[e]),te=I.useMemo(()=>new Map(e.map(e=>[e.projectId,gn(e)])),[e]),y=I.useMemo(()=>new Map(e.map(e=>[e.projectId,e.requests])),[e]),b=I.useMemo(()=>new Map(e.map(e=>[e.projectId,Z(e.tasks)])),[e]),{attention:x,working:S}=I.useMemo(()=>si(e),[e]),ne=Vi(x),C=I.useMemo(()=>e.flatMap(e=>e.requests),[e]),re=I.useMemo(()=>e.flatMap(e=>Z(e.tasks)),[e]),w=I.useMemo(()=>Ri(e,a),[e,a]),T=I.useMemo(()=>[...C,...w.requests],[C,w.requests]),ie=I.useMemo(()=>[...re,...w.waits],[re,w.waits]),ae=I.useMemo(()=>new Map([...x.map(e=>[e.runId,e.projectId]),...S.map(e=>[e.runId,e.projectId])]),[x,S]),{edges:oe,gutterWidth:E}=I.useMemo(()=>Jr(T,ie,ae,a),[T,ie,ae,a]),D=_.pointer??_.focus,se=I.useMemo(()=>{let e=D?ae.get(D):void 0;return e&&D?Yr(D,y.get(e)??[],b.get(e)??[]):new Set},[D,y,ae,b]),O=I.useCallback((e,t)=>{v(n=>{if(n[e]===t)return n;let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},[]),{activeDecision:ce,resolvedExternally:k}=I.useMemo(()=>zi(m,x),[x,m]),le=I.useCallback((e,t)=>{g.current=t,h({token:++p.current,projectId:e.projectId,runId:e.runId,snapshot:e})},[]),ue=I.useCallback(()=>Hi(g.current,d,u.current),[d]),de=I.useCallback(()=>h(null),[]),A=I.useCallback((e,t)=>{h(e=>e&&(t===void 0||e.token===t)?null:e)},[]),fe=`${r}:${x.map(e=>e.runId).join(`,`)}:${S.map(e=>e.runId).join(`,`)}:${oe.map(e=>e.id).join(`,`)}`,j=x.length===0&&S.length===0;return(0,L.jsxs)(`div`,{ref:u,tabIndex:-1,className:`flex min-w-0 flex-col gap-5 outline-none`,children:[(0,L.jsx)(`p`,{"data-slot":`activity-announcement`,role:`status`,"aria-live":`polite`,className:`sr-only`,children:ne??``}),j&&l?(0,L.jsx)(`p`,{"data-slot":`activity-empty`,className:`py-6 text-[13px] text-muted-foreground`,children:l}):null,j?null:(0,L.jsxs)(`div`,{ref:f,"data-slot":`activity-stage`,...Bi(E),children:[(0,L.jsx)(Qr,{stage:d,edges:oe,active:D,now:t,layoutKey:fe,motion:a,paused:c||s}),(0,L.jsx)(Si,{items:x,requestsByProject:y,waitsByProject:b,indexByProject:te,now:t,global:n,grouped:r,projectOrder:i,selectedRunId:ce?.runId,linkedIds:se,motion:a,onHover:O,onTriage:le}),(0,L.jsx)(Ii,{items:S,requestsByProject:y,waitsByProject:b,indexByProject:te,now:t,global:n,grouped:r,projectOrder:i,linkedIds:se,motion:a,onHover:O})]}),(0,L.jsx)(Br,{requests:C,closing:w.folding,index:ee,now:t,feed:o,motion:a}),(0,L.jsx)(ji,{record:ce,selectionToken:m?.token,resolved:k,now:t,onClose:de,onResolved:A,onRestoreFocus:ue})]})}var Wi=e=>new Map(e.map(e=>[e.runId,e])),Gi=e=>e!==void 0&&hn(e)===void 0;function Ki(e,t,n,r){let i=Wi(t.workers);for(let t of n.workers){let a=i.get(t.runId);!a&&K(t.status)&&r({kind:`worker-started`,projectId:e,parentId:n.runId,worker:t}),a&&K(a.status)&&!K(t.status)&&r({kind:`worker-settled`,projectId:e,parentId:n.runId,worker:t})}}function qi(e,t,n,r){if(t.wait?.kind!==`pr`||n.wait?.kind!==`pr`||t.wait.detail.number!==n.wait.detail.number)return;let i=new Set((t.wait.detail.checks??[]).filter(e=>e.bucket===`pending`).map(e=>e.name));for(let t of n.wait.detail.checks??[])t.bucket===`pass`&&i.has(t.name)&&r({kind:`check-passed`,projectId:e,runId:n.runId,pr:n.wait.detail.number,name:t.name})}var Ji=(e,t)=>t.tool!==void 0&&(t.tool.startedAt!==e.tool?.startedAt||t.tool.title!==e.tool?.title);function Yi(e,t,n,r){t.rung!==n.rung&&r({kind:`rung-changed`,projectId:e,task:n,from:t.rung}),Ji(t,n)&&r({kind:`tool-started`,projectId:e,runId:n.runId}),Ki(e,t,n,r),qi(e,t,n,r)}function Xi(e,t,n){let r=Wi(e.tasks),i=Wi(t.tasks);for(let e of t.tasks){let i=r.get(e.runId);i?Yi(t.projectId,i,e,n):n({kind:`card-entered`,projectId:t.projectId,task:e})}for(let r of e.tasks)i.has(r.runId)||n({kind:`card-left`,projectId:t.projectId,task:r})}function Zi(e,t,n){let r=new Set(e.requests.map(e=>e.requestId)),i=new Set(t.requests.map(e=>e.requestId)),a=new Map(t.closed.map(e=>[e.requestId,e.status]));for(let e of t.requests)r.has(e.requestId)||n({kind:`request-opened`,projectId:t.projectId,request:e});for(let r of e.requests){if(i.has(r.requestId))continue;let e=a.get(r.requestId);n({kind:`request-closed`,projectId:t.projectId,request:r,...e?{status:e}:{}})}}function Qi(e,t,n){let r=Z(e.tasks),i=Z(t.tasks),a=new Set(r.map(e=>e.id)),o=new Set(i.map(e=>e.id));for(let e of i)a.has(e.id)||n({kind:`wait-opened`,projectId:t.projectId,wait:e});for(let e of r)o.has(e.id)||n({kind:`wait-closed`,projectId:t.projectId,wait:e})}var $i=[`needsYou`,`working`,`waiting`,`queued`,`activeWorkers`,`openRequests`,`inReview`];function ea(e,t,n){let r=jn(e),i=jn(t);for(let e of $i)r[e]!==i[e]&&n({kind:`chip-changed`,chip:e,from:r[e],to:i[e]})}function ta(e,t){if(e===void 0)return[];let n=[],r=e=>n.push(e),i=new Map(e.projects.map(e=>[e.projectId,e]));for(let e of t.projects){let t=i.get(e.projectId);!Gi(t)||!Gi(e)||(Xi(t,e,r),Zi(t,e,r),Qi(t,e,r))}return ea(e.projects,t.projects,r),n}function na(e){return{input:e,reconcile:!1,seq:0,motion:$,feed:[],epoch:0,...e.snapshot?{seen:e.snapshot}:{}}}function ra(e){let{plan:t,...n}=e;return{...n,motion:$,epoch:e.epoch+1}}function ia(e,t,n){let r=ta(t,n);if(r.length===0)return e;let i=Date.parse(n.generatedAt),a=Dr(t,n),o=r.flatMap(e=>Mr(e,a,i)??[]),s=e.seq+o.length+1,c=Hn(r,s,e.input.reduced);return{...e,seq:s,feed:o.length>0?Nr(e.feed,o,i,e.seq+1):e.feed,motion:Wn(e.motion,c.changes),...c.timers.length>0?{plan:{key:s,timers:c.timers}}:{}}}function aa(e,t){let n=e.seen;if(!t||t===n)return e;let r={...e,seen:t};return!n||!e.input.active?r:e.reconcile?{...r,reconcile:!1}:ia(r,n,t)}function oa(e,t){let n=e.input;if(t.scope!==n.scope)return{...na(t),seq:e.seq,epoch:e.epoch+1};if(t.snapshot===n.snapshot&&t.active===n.active&&t.reduced===n.reduced)return e;let r={...e,input:t};return n.active&&!t.active&&(r={...ra(r),reconcile:!0}),!n.reduced&&t.reduced&&(r=ra(r)),aa(r,t.snapshot)}var sa=`(prefers-reduced-motion: reduce)`,ca=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(sa):void 0;function la(e){let t=ca();return t?.addEventListener?.(`change`,e),()=>t?.removeEventListener?.(`change`,e)}function ua(){return ca()?.matches??!1}function da(){return(0,I.useSyncExternalStore)(la,ua,()=>!1)}function fa(e,t){let n=I.useRef(new Set);I.useEffect(()=>{let e=n.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[e.epoch]),I.useEffect(()=>{for(let{after:r,change:i}of e.plan?.timers??[]){let e=setTimeout(()=>{n.current.delete(e),t(e=>({...e,motion:Wn(e.motion,[i])}))},r);n.current.add(e)}},[e.plan?.key])}function pa(e,t){let n=da(),r=b(),i={snapshot:e,scope:t,active:r,reduced:n},[a,o]=I.useState(()=>na(i)),s=oa(a,i);return s!==a&&o(s),fa(s,o),{motion:s.motion,feed:s.feed,reduced:n,paused:!r}}function ma(e,t){let n=Le(1e3),[r,i]=I.useState({offset:0}),a=r.offset;return st(e)&&e!==r.generatedAt&&t!==0&&(a=Date.parse(e)-t,i({generatedAt:e,offset:a})),n+a}export{$t as A,gn as C,mn as D,fn as E,G as F,U as I,H as L,K as M,Bt as N,dn as O,V as P,ft as R,hn as S,ln as T,$ as _,Er as a,X as b,Tr as c,gr as d,ir as f,Kn as g,er as h,Hr as i,Gt as j,rn as k,Cr as l,Jn as m,pa as n,Sr as o,tr as p,Ui as r,wr as s,ma as t,vr as u,Gn as v,jn as w,Z as x,Sn as y};
@@ -1,7 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{$t as i,Wt as a,Zt as o,g as s,h as c,rn as l,x as u,yt as d}from"./queries-ClkIgWFx.js";import{Fn as f,hi as p,n as m}from"./toaster-C-xqAWVX.js";import{t as h}from"./button-B7MKxYjT.js";import{t as g}from"./badge-DQ3U69Ht.js";import{t as _}from"./centered-state-V15AR_qo.js";import{O as v,Qn as y,pn as b}from"./index-7M_Uae0m.js";import{n as x,r as S,t as C}from"./remote-settings-notice-KN0zBmre.js";import{t as w}from"./code-editor-B4baSOhz.js";var T=e(t(),1);function E(e){return t=>t.runners.includes(e)}function D(e,t){let n=E(e);return t===`mcp`?e=>n(e)&&(e.holdsMcp===!0||e.kind===`mcp`):e=>n(e)&&e.kind===t}function O(e){let{label:t,note:n,groups:r}=e.agentConfig;return{id:e.id,label:t,note:n,groups:r.map(({id:t,label:n,note:r,empty:i,showsUserMcp:a})=>({id:t,label:n,note:r,...i?{empty:i}:{},...a?{showsUserMcp:a}:{},files:D(e.id,t)}))}}function k(e){return o(e).map(O)}var A=n();function j(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function M(){let e=c(),t=S(),n=d(),r=l(),a=r.data,o=(0,T.useMemo)(()=>k(a),[a]),s=(0,T.useMemo)(()=>n.data?v(n.data.checks,a):i(a),[n.data,a]);return r.isError?(0,A.jsx)(_,{icon:(0,A.jsx)(y,{}),tone:`danger`,title:`Runners did not load`,subtitle:r.error.message,heading:`h2`}):e.isError?(0,A.jsx)(_,{icon:(0,A.jsx)(y,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||a===void 0?(0,A.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,A.jsx)(N,{listing:e.data,descriptors:o,installed:s,onOpenFile:t})}function N({listing:e,descriptors:t,installed:n,onOpenFile:i}){let[a,o]=(0,T.useState)(`claude`),[s,c]=(0,T.useState)(null),l=t.find(e=>e.id===a)??t[0];if(l===void 0)return null;let u=P(l,e),d=u.find(e=>e.id===s)??F(u),f=e=>{o(e),c(null)};return(0,A.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,A.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit project, local, and user-wide config files for each coding agent.`}),!e.editable&&(0,A.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-muted-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,A.jsx)(`code`,{children:C}),`.`]}),(0,A.jsx)(x,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,A.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===l.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===l.id,onClick:()=>f(e.id),className:r(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===l.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,A.jsx)(g,{variant:`outline`,className:`text-[12px] text-soft-foreground`,children:`not installed`})]},e.id))}),l.note&&(0,A.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-xs text-muted-foreground`,children:l.note}),(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(17rem,24rem)_minmax(0,1fr)]`,children:[(0,A.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,A.jsx)(R,{agent:l,listing:e,selectedId:d?.id??null,onSelect:e=>{c(e),i()}})}),(0,A.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:d?(0,A.jsx)(B,{file:d},d.id):(0,A.jsx)(`p`,{"data-slot":`agent-config-editor-empty`,className:`rounded-md border border-border bg-muted/40 px-4 py-3 text-[13px] text-soft-foreground`,children:`This agent has no config files to show.`})})]})]})}function P(e,t){return e.groups.flatMap(e=>t.files.filter(e.files))}function F(e){return e.find(e=>e.scope===`project`)??e[0]??null}var I={project:`Project scope`,local:`Local scope`,user:`User scope`};function L(e,t){for(let n of t){if(!n.label.startsWith(`~/`))continue;let t=n.label.slice(1);if(!n.path.endsWith(t))continue;let r=n.path.slice(0,n.path.length-t.length);if(r&&(e===r||e.startsWith(`${r}/`)))return`~${e.slice(r.length)}`}return e.replace(/^\/(?:home|Users)\/[^/]+(?=\/|$)/,`~`)}function R({agent:e,listing:t,selectedId:n,onSelect:i}){return(0,A.jsx)(A.Fragment,{children:e.groups.map(a=>{let o=t.files.filter(a.files),s=a.showsUserMcp?t.userMcp:void 0;return o.length===0&&!s&&!a.empty?null:(0,A.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,A.jsx)(`p`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,A.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.note}),o.length===0&&a.empty&&(0,A.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground`,children:a.empty}),(0,A.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>i(e.id),title:e.label,className:r(`flex w-full flex-col items-start gap-1 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,A.jsx)(`span`,{"data-slot":`agent-config-file-name`,className:`min-w-0 max-w-full break-all font-mono text-[12px]`,children:e.label}),e.seeded||!e.exists?(0,A.jsxs)(`span`,{"data-slot":`agent-config-file-meta`,className:`flex flex-wrap items-center gap-1.5`,children:[e.seeded&&(0,A.jsx)(g,{variant:`outline`,className:`text-[11px]`,children:`Default template`}),!e.exists&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not created`})]}):null]})},e.id))}),s&&(0,A.jsx)(z,{userMcp:s,path:L(s.path,t.files)})]},a.id)})})}function z({userMcp:e,path:t}){return(0,A.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,A.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,A.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Managed by `,(0,A.jsx)(`code`,{"data-slot":`agent-config-user-mcp-command`,className:`whitespace-nowrap font-mono`,children:`claude mcp add`}),` in`,` `,(0,A.jsx)(`code`,{"data-slot":`agent-config-user-mcp-path`,title:e.path,className:`break-all font-mono text-foreground/80`,children:t}),` — Squawk does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,A.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(g,{variant:`outline`,className:`font-mono text-[11px]`,children:e})},e))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No user-scoped MCP servers.`}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Could not read the file.`})]})}function B({file:e}){let t=s(e.id),[n,r]=(0,T.useState)(null),[i,a]=(0,T.useState)(!1),[o,c]=(0,T.useState)(null),l=t.data?.version??null,u=n??t.data?.content??``,d=t.data?u!==t.data.content:!1,f=e.writable,p=e.kind===`mcp`||e.holdsMcp;b(f&&d);let{save:m,isSaving:h}=K({file:e,content:u,loadedVersion:l,setDraft:r,setConflict:a,setFormatError:c});return(0,T.useEffect)(()=>{t.data&&(r(t.data.content),a(!1),c(null))},[t.data?.version,t.data]),(0,A.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,A.jsx)(g,{variant:`outline`,"data-slot":`agent-config-scope`,"data-scope":e.scope,className:`text-[12px]`,children:I[e.scope]})]}),(0,A.jsx)(`p`,{"data-slot":`agent-config-path`,title:e.path,className:`font-mono text-xs text-foreground/80`,children:L(e.path,[e])}),(0,A.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,A.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,A.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,A.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,A.jsx)(`h3`,{children:p?`MCP configuration`:`File contents`}),p&&(0,A.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,A.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,A.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,A.jsx)(V,{file:e,content:u,isMcp:p,onChange:r}),(0,A.jsx)(W,{formatError:o,conflict:i,onReload:()=>void t.refetch()}),f&&(0,A.jsx)(H,{exists:e.exists,dirty:d,isSaving:h,onSave:m,onReset:()=>r(null)}),(0,A.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,A.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-xs text-muted-foreground`,children:e.precedence}),(0,A.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-xs text-foreground/80`,children:[j(e),e.hotReload?` ${e.hotReload}`:``]}),(0,A.jsx)(G,{reason:e.readOnlyReason})]})]})}function V({file:e,content:t,isMcp:n,onChange:r}){return(0,A.jsxs)(`div`,{"data-slot":`agent-config-editor-frame`,className:`relative`,children:[(0,A.jsx)(w,{value:t,language:e.format,readOnly:!e.writable,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),!e.exists&&t===``&&(0,A.jsx)(`pre`,{"data-slot":`agent-config-placeholder`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-px m-0 overflow-hidden whitespace-pre px-3 py-2 font-mono text-xs leading-[1.7] text-muted-foreground/80`,children:U(e,n)})]})}function H({exists:e,dirty:t,isSaving:n,onSave:r,onReset:i}){return(0,A.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,A.jsx)(h,{size:`sm`,onClick:r,disabled:!t||n,children:e?`Save file`:`Create file`}),(0,A.jsx)(h,{size:`sm`,variant:`outline`,onClick:i,disabled:!t||n,children:`Reset`}),!n&&(0,A.jsx)(`span`,{"data-slot":`agent-config-save-cue`,className:`self-center text-xs text-muted-foreground`,children:t?`Unsaved changes`:e?`No unsaved changes`:`Enter content above to create this file`})]})}function U(e,t){switch(e.format){case`json`:case`jsonc`:return`// File not created yet — example:\n${t?`{
2
- "mcpServers": {}
3
- }`:`{
4
- "permissions": {}
5
- }`}`;case`markdown`:return`<!-- File not created yet — write instructions here -->`;case`toml`:return`# File not created yet — example:
6
- # key = "value"`;case`yaml`:return`# File not created yet — example:
7
- # key: value`}}function W({formatError:e,conflict:t,onReload:n}){return(0,A.jsxs)(A.Fragment,{children:[e&&(0,A.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,A.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,A.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,A.jsx)(h,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function G({reason:e}){return e&&(0,A.jsx)(`p`,{children:e})}function K({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:i,setFormatError:o}){let s=u(e.id),c=p(),l=S();return{save:()=>{o(null),i(!1),s.mutate({content:t,version:n},{onSuccess:()=>{r(null),m(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof f&&e.status===409?l().then(()=>{c.getQueryData(a.health)?.capabilities.settingsAdmin===!1?m(e.message,{tone:`danger`}):i(!0)}):e instanceof f&&e.status===400?o(e.message):m(e.message,{tone:`danger`})}})},isSaving:s.isPending}}export{M as AgentConfigSection};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$t as r,At as i,C as a,Ct as o,Gt as s,St as c,Tt as l,Wt as u,Xt as d,Zt as f,_ as p,an as m,dn as h,dt as g,jt as _,on as v,rn as y}from"./queries-ClkIgWFx.js";import{Fn as b,Jt as x,P as S,Tr as C,a as w,hi as T,hn as E,n as D}from"./toaster-C-xqAWVX.js";import{s as O}from"./design-icons-CzEoMH9c.js";import{t as k}from"./button-B7MKxYjT.js";import{r as A}from"./switch-SP8pw5uU.js";import{t as j}from"./status-dot-BRzVlF2X.js";import{t as M}from"./centered-state-V15AR_qo.js";import{gn as ee,j as te,k as ne,pn as re}from"./index-7M_Uae0m.js";import{t as N}from"./textarea-vJt9undk.js";import{t as P}from"./settings-select-CCIMGnyA.js";import{a as F,i as I,n as L,r as R,t as z}from"./settings-agent-picker-BdoxLNMP.js";import{n as B}from"./saved-draft-BwzBc-_Y.js";import{t as V}from"./save-cue-Cd3ZAPBS.js";var H=e(t(),1),U=n(),W={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function G(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function K(e,t){return e?W[e]:t?{label:`Checking…`,tone:`neutral`}:W.unknown}function q(e,t){return e===`unknown`||t&&!e}function J({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,U.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,U.jsx)(`code`,{children:e.loginCommand}),`.`]}):q(t,r)?(0,U.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,U.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function Y({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`;return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,U.jsx)(A,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t)}),l?(0,U.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>D(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,U.jsx)(L,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,U.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,U.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>D(`${e.displayName} can be tried again.`),onError:e=>D(e.message,{tone:`danger`})}),children:`Try again`})]})}function ie({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,U.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,U.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,U.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ae(){let e=y(),t=o(),n=l(),r=i(),a=T(),[c,u]=(0,H.useState)(null),p=(0,H.useRef)(Promise.resolve()),g=(0,H.useRef)({}),_=(0,H.useRef)({}),v=(0,H.useRef)(t.data);(0,H.useEffect)(()=>{c&&C(t.data,c.provider)?.status===`connected`&&u(null)},[c,t.data]),(0,H.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!v.current){v.current=t.data;return}v.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?C(v.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let S=(0,H.useCallback)((e,t)=>{let n=s.providerStatus,r=a.getQueryData(n);if(!r)return;v.current||=r;let i=G(r,e,t);_.current[e]=(_.current[e]??0)+1,a.setQueryData(n,i);let o=(g.current[e]??0)+1;g.current[e]=o,p.current=p.current.then(async()=>{try{let r=await E(e,t),i=C(r,e)?.enabled;if(i===void 0)return;if(v.current=G(v.current??r,e,i),o===g.current[e]){let t=a.getQueryData(n);a.setQueryData(n,t?G(t,e,i):r)}}catch(t){if(o===g.current[e]){let r=C(v.current,e)?.enabled,i=a.getQueryData(n);i&&r!==void 0?a.setQueryData(n,G(i,e,r)):v.current?a.setQueryData(n,v.current):a.removeQueries({queryKey:n,exact:!0}),D(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[a]),w=h({mutationFn:e=>x(e),onSuccess:async(e,t)=>{u(null),D(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await a.invalidateQueries({queryKey:s.providerStatus}),await m(a,t,`none`)},onError:(t,n)=>{if(t instanceof b&&t.command){let r=d(e.data,n);u({provider:n,label:r,message:t.message,command:t.command});return}D(t.message,{tone:`danger`})}}),O=async e=>{try{await navigator.clipboard.writeText(e),D(`Command copied`)}catch{D(`Could not copy the command`,{tone:`danger`})}};return(0,U.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,U.jsxs)(`div`,{className:`mb-2`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,U.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,U.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,U.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:f(e.data).map(e=>{let i=C(t.data,e.id),a=i?.status,o=K(a,t.isPending),s=w.isPending&&w.variables===e.id,l=i?.authFailureId;return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,U.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(j,{tone:o.tone,pulse:t.isPending}),(0,U.jsx)(`span`,{children:o.label}),i?.enabled===!1?(0,U.jsx)(`span`,{children:`Disabled`}):null]}),(0,U.jsx)(J,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,U.jsx)(Y,{provider:e,state:a,current:i,isConnecting:s,incidentId:l,refresh:n,connect:w,retry:r,queueToggle:S})]}),l===void 0?null:(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,U.jsx)(ie,{manual:c,provider:e.id,connected:a===`connected`,onCopy:O})]},e.id)})})]})}var X=2e4;function Z(){let e=p(),t=y(),n=v(r(t.data)),i=o();return e.isPending?(0,U.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,U.jsx)(M,{icon:(0,U.jsx)(O,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,U.jsx)(oe,{config:e.data,catalogs:n,providerStatus:i,runners:t.data})}function oe({config:e,catalogs:t,providerStatus:n,runners:r}){let i=a(),o=T(),s=h({mutationFn:e=>S(e),onSuccess:e=>{o.setQueryData(u.config,e),o.invalidateQueries({queryKey:u.health}),o.invalidateQueries({queryKey:u.repo})},onError:e=>D(e.message,{tone:`danger`})}),[c,l]=B(e.systemPrompt??``),d=c.trim(),p=d===(e.systemPrompt??``),m=d.length>X;return re(!p),(0,U.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,U.jsx)(se,{defaultRunner:e.defaultRunner,providerStatus:n,saving:s.isPending,onPick:e=>s.mutate({defaultRunner:e})}),(0,U.jsx)(Q,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,U.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:f(r).map(i=>{let{providerConnected:a,providerReason:o}=F(n,i.id),c=t[i.id],l=ne(i.id,r,c),u=te(i.id,r,c?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,U.jsxs)(`label`,{className:`settings-option-row`,children:[(0,U.jsx)(`div`,{children:(0,U.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,U.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,U.jsxs)(P,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:s.isPending||!a,onChange:e=>s.mutate({defaultModels:{[i.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,U.jsx)(`option`,{disabled:!0,children:l}):null]})]},i.id)})})}),(0,U.jsxs)(Q,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,U.jsx)(N,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:c,onChange:e=>l(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,U.jsx)(ce,{length:d.length,overLimit:m,saved:p,pending:s.isPending,onSave:()=>s.mutate({systemPrompt:d===``?null:d},{onSuccess:()=>D(d===``?`System prompt cleared`:`System prompt saved`)})})]}),(0,U.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,U.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,U.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,U.jsx)(A,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:s.isPending,onCheckedChange:e=>s.mutate({liveTitleUpdates:e},{onSuccess:()=>D(e?`Live title updates on`:`Live title updates off`)})}),(0,U.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,U.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,U.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,U.jsx)(A,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:s.isPending,onCheckedChange:e=>s.mutate({reviewGate:e},{onSuccess:()=>D(e?`Review gate on`:`Review gate off`)})}),(0,U.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,U.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:i.data?.info?(0,U.jsxs)(P,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:s.isPending,onChange:e=>s.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,U.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),i.data.branches.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]}):(0,U.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,U.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,U.jsx)(`summary`,{children:`Provider connections`}),(0,U.jsx)(ae,{})]})]})}function se({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=g(),o=c(),s=w(),l=a(),u=_(),d=s.projectId??`default`,f=l.data?.info?.root,p=ee(i.data,s.projectId,f),m=y().data,h=R(i.data?.profiles??[],m),v=I(h,m);return(0,U.jsxs)(Q,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,U.jsx)(z,{rows:h,runner:e,accountFor:e=>p?.[e]??null,providerStatus:t,disabled:n,accountDisabled:u.isPending||o.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&u.mutate({projectId:d,provider:t,profileId:n},{onError:e=>D(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&C(t.data,e)?.enabled===!1?(0,U.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,v?(0,U.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function Q({title:e,hint:t,reportsDirty:n,children:r}){return(0,U.jsxs)(`section`,{"data-reports-dirty":n?``:void 0,className:`settings-field flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,U.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),r]})}function $({title:e,hint:t,children:n}){return(0,U.jsxs)(`section`,{className:`settings-option-row`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{children:e}),(0,U.jsx)(`p`,{children:t})]}),n]})}function ce({length:e,overLimit:t,saved:n,pending:r,onSave:i}){return(0,U.jsxs)(U.Fragment,{children:[t?(0,U.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,X.toLocaleString(),`.`]}):(0,U.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`}),(0,U.jsx)(`div`,{className:`settings-form-actions`,children:(0,U.jsx)(V,{show:n&&!t&&!r,children:(0,U.jsx)(k,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:n||t||r,onClick:i,children:`Save prompt`})})})]})}export{Z as AgentDefaultsSection};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-ClkIgWFx.js";import{B as u,Fn as d,H as f,Ur as p,V as m,_ as h,ar as g,c as ee,d as _,g as v,ir as y,ni as b,nr as x,o as S,s as C,sr as te,ti as ne,v as re,z as ie}from"./toaster-C-xqAWVX.js";import{B as w,G as ae,H as T,I as E,K as oe,N as D,P as O,V as se,W as k,j as A,z as j}from"./live-protocol-DMhTnCmf.js";import{h as ce}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as le,t as M}from"./label-BKUl84DF.js";import{I as ue,J as de,Y as fe,it as pe,l as me,pt as he,ut as ge,y as _e}from"./design-icons-CzEoMH9c.js";import{t as ve}from"./check-OP-CVgZG.js";import{t as N}from"./button-B7MKxYjT.js";import{n as ye,r as be,t as xe}from"./collapsible-BEV4FO-1.js";import{a as P,i as F,n as I,r as L,t as Se}from"./select-ETUx1MVz.js";import{r as Ce}from"./switch-SP8pw5uU.js";import{c as we,s as Te,t as R}from"./project-router-CT6gVIcC.js";import{a as Ee,c as De,d as Oe,n as ke,s as Ae,u as z}from"./page-shell-7pLJMOgh.js";import{t as je}from"./centered-state-V15AR_qo.js";import{D as Me,Dn as Ne,E as Pe,En as Fe,G as Ie,H as Le,U as Re,Vn as B,er as ze,j as Be,mn as Ve,r as He,t as Ue,vn as We}from"./index-7M_Uae0m.js";import{t as Ge}from"./textarea-vJt9undk.js";import{_ as Ke,a as qe,c as Je,d as Ye,f as Xe,g as Ze,h as Qe,i as $e,l as et,m as tt,n as nt,o as rt,p as it,r as at,s as ot,t as V,u as st,v as ct}from"./automation-format-DB34jUyF.js";var H=e(t(),1),U=A([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),lt=w({includeExisting:O().optional(),authors:D(k()).optional(),assignees:D(k()).optional(),requireCurrentLabels:O().optional(),allLabels:D(k()).optional(),anyLabels:D(k()).optional(),excludeLabels:D(k()).optional(),changedLabels:D(k()).optional(),lookbackDays:j(),maxRecords:j()}),ut=A([`github`,`schedule`]),dt=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:k(),variants:ae([E(1),E(2),E(3)]).optional(),systemPrompt:k().optional()}),ft=w({at:k(),outcome:A([`launched`,`cancelled`]),runId:k().optional(),receiptId:k().optional(),trigger:A([`schedule`,`late`,`manual`,`retry`]).optional()}),W=w({id:k(),revision:j(),name:k(),description:k().optional(),enabled:O(),kind:ut,events:D(U).optional(),intervalSeconds:j().optional(),filters:lt.optional(),schedule:Je.optional(),task:dt,archived:ft.optional(),createdAt:k(),updatedAt:k()}),G=w({timestamp:k(),tieBreaker:k().optional()}),pt=w({since:k().datetime(),until:k().datetime(),source:j().int().min(0).max(2),page:j().int().min(1).max(10),item:j().int().min(0).max(100),event:j().int().min(0).max(1e3),cursor:G.optional()}),mt={lastError:k().max(1e3).optional(),lastErrorAt:k().datetime().optional()},ht=w({revision:j().optional(),baselineAt:k().optional(),armedAt:k().optional(),historyScan:pt.optional(),cursor:G.optional(),frozenHighWatermark:G.extend({tieBreaker:k()}).optional(),backlogAfter:G.extend({tieBreaker:k()}).optional(),nextCheckAt:k().optional(),lastSuccessAt:k().optional(),nextRunAt:k().optional(),lastRunAt:k().optional(),etags:T(k(),k()).optional(),backoffUntil:k().optional(),consecutiveFailures:j().optional(),...mt,onceOutcome:A([`failed`,`missed`]).optional()});function gt(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var _t=A([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),vt=w({seq:j(),ts:k(),automationId:k(),revision:j(),event:U.optional(),result:_t,reason:k().optional(),durationMs:j().optional(),receiptId:k().optional(),runId:k().optional(),githubNumber:j().optional(),githubTitle:k().optional(),githubUrl:k().optional(),rateLimit:w({bucket:A([`core`,`search`]),remaining:j().optional(),resetAt:k().optional()}).optional()}),yt=w({matches:j(),launched:j(),duplicates:j(),errors:j()}),bt=W.extend({state:ht.optional(),latestLog:vt.optional(),counts:yt,nextRunAt:k().optional(),onceStatus:it.optional()});w({available:O(),reason:k().optional(),timeZone:k(),scheduler:w({state:A([`scheduled`,`idle`]),nextDue:k().optional()}),automations:D(bt)}),w({automation:W}).extend({once:w({dueAt:k(),timeZone:k(),resolvedInstant:k(),note:k()}).optional()}),w({automation:W,state:ht.optional(),latestLog:vt.optional(),onceStatus:it.optional()}),w({id:k(),automationId:k(),mode:A([`preview`,`execute`]),status:A([`queued`,`running`,`complete`,`error`]),createdAt:k(),completedAt:k().optional(),matches:j().optional(),truncated:O().optional(),error:k().optional()}),w({checkId:k()}),w({records:D(vt)}),w({receiptId:k(),runId:k()}),w({runId:k()}),W.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:ut.optional(),task:dt.omit({variants:!0}).strict(),enable:O().optional()}).omit({enable:!0}).extend({enabled:O().optional(),expectedRevision:j()}),w({archived:A([`include`,`only`]).optional()}),w({mode:A([`preview`,`execute`])});var K=n();function q({text:e}){return(0,K.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var xt={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},St={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function Ct(e){let[t,n]=(0,H.useState)(),[r,i]=(0,H.useState)(``),a=(0,H.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,H.useEffect)(()=>{a()},[a]),(0,H.useEffect)(()=>p(a),[a]),(0,H.useEffect)(()=>le((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function wt(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function Tt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&wt(e,t),[o,s]=(0,H.useState)(),[c,l]=(0,H.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await ie(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,K.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(He,{dot:xt[e.result],children:St[e.result]}),(0,K.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:nt(e.ts,n,u)})]}),e.reason?(0,K.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,K.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,K.jsx)(N,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var J=`all`;function Et({label:e,value:t,onChange:n,options:r}){return(0,K.jsxs)(Se,{value:t,onValueChange:n,children:[(0,K.jsx)(F,{"aria-label":e,className:`w-full sm:w-52`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(I,{children:r.map(e=>(0,K.jsx)(L,{value:e.value,children:e.label},e.value))})]})}function Dt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=Ct(e),[s,c]=(0,H.useState)(J),[l,u]=(0,H.useState)(J),d=(0,H.useMemo)(()=>(i??[]).filter(e=>(s===J||e.result===s)&&(l===J||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,K.jsx)(De,{route:`automations`,density:i?Oe(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,K.jsx)(Ae,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:a}),(0,K.jsx)(N,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,K.jsx)(q,{text:`Nothing has run yet.`}):(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Et,{label:`Result`,value:s,onChange:c,options:[{value:J,label:`All results`},..._t.options.map(e=>({value:e,label:St[e]}))]}),f?(0,K.jsx)(Et,{label:`Event`,value:l,onChange:u,options:[{value:J,label:`All events`},...U.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,K.jsx)(q,{text:`No rows match these filters.`}):(0,K.jsx)(Tt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,K.jsx)(q,{text:`Loading execution log…`})})}function Ot({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=Ct(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,K.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,K.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,K.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(q,{text:o}),(0,K.jsx)(N,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,K.jsx)(Tt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function kt({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?at(i):null,[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await _(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,K.jsx)(De,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,K.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,K.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,K.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${V(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,K.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,K.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,K.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,K.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,K.jsxs)(`section`,{className:`min-w-0`,children:[(0,K.jsx)(Ot,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,K.jsx)(N,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,K.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(N,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,K.jsx)(N,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(N,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,K.jsx)(N,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var At=A([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),Y=D(k().trim().min(1).max(200)).max(100).optional(),jt=w({includeExisting:O().optional(),requireCurrentLabels:O().optional(),authors:Y,assignees:Y,allLabels:Y,anyLabels:Y,excludeLabels:Y,changedLabels:Y,lookbackDays:j().int().min(1).max(90).default(7),maxRecords:j().int().min(1).max(100).default(25)}).passthrough(),Mt=w({prompt:k().min(1).max(1e5),workflow:k().trim().min(1).max(200).optional(),steps:D(y).min(1).max(100).optional(),runner:ne.optional(),model:k().trim().min(1).max(200).optional(),effort:k().trim().min(1).max(32).optional(),variants:ae([E(1),E(2),E(3)]).optional(),worktree:O().optional(),autonomous:O().optional(),...g,...te,systemPrompt:k().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Nt=new Set(Object.keys(Mt.shape).filter(e=>e!==`variants`));function Pt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Nt.has(e)))}se(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},w({id:k().min(1).max(100),revision:j().int().positive(),name:k().trim().min(1).max(200),description:k().max(2e3).optional(),enabled:O().default(!1),kind:ut.default(`github`),events:D(At).min(1).max(4).optional(),intervalSeconds:j().int().min(60).max(86400).optional(),filters:jt.optional(),schedule:Je.passthrough().optional(),task:Mt,archived:w({at:k().datetime(),outcome:A([`launched`,`cancelled`]),runId:k().optional(),receiptId:k().optional(),trigger:A([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:k().datetime(),updatedAt:k().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:b.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:b.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:b.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:b.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:b.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),w({version:E(1).default(1),automations:D(oe()).default([]),tombstones:T(k(),k().datetime()).optional()}).passthrough();var X=w({timestamp:k().datetime(),tieBreaker:k().optional()}).passthrough(),Ft=pt.extend({cursor:X.optional()}),It=w({revision:j().int().positive().optional(),baselineAt:k().datetime().optional(),armedAt:k().datetime().optional(),historyScan:Ft.optional(),cursor:X.optional(),frozenHighWatermark:X.extend({tieBreaker:k()}).optional(),backlogAfter:X.extend({tieBreaker:k()}).optional(),nextCheckAt:k().datetime().optional(),lastSuccessAt:k().datetime().optional(),nextRunAt:k().datetime().optional(),lastRunAt:k().datetime().optional(),etags:T(k(),k()).optional(),backoffUntil:k().datetime().optional(),consecutiveFailures:j().int().nonnegative().optional(),...mt,onceOutcome:A([`failed`,`missed`]).optional()}).passthrough();w({version:E(1).default(1),states:T(k(),It).default({})}).passthrough(),w({receiptId:k().min(1),receiptKey:k().min(1),eventId:k().min(1),automationId:k().min(1),revision:j().int().positive(),status:A([`reserved`,`launched`,`launch-error`,`released`]),runId:k().optional(),observedAt:k().datetime(),updatedAt:k().datetime(),error:k().max(2e3).optional(),occurrenceAt:k().datetime().optional(),candidate:w({eventId:k(),event:At,timestamp:k().datetime(),tieBreaker:k(),repo:k(),nodeId:k(),number:j().int().positive(),title:k().max(500),url:k().url(),author:k().max(200),assignees:D(k().max(200)).max(100),labels:D(k().max(200)).max(100),changedLabel:k().max(200).optional()}).passthrough().optional()}).passthrough();var Lt=A([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);w({seq:j().int().positive(),ts:k().datetime(),automationId:k().min(1),revision:j().int().positive(),event:At.optional(),result:Lt,reason:k().max(2e3).optional(),durationMs:j().int().nonnegative().optional(),receiptId:k().optional(),runId:k().optional(),githubNumber:j().int().positive().optional(),githubTitle:k().max(500).optional(),githubUrl:k().url().optional(),rateLimit:w({bucket:A([`core`,`search`]),remaining:j().int().nonnegative().optional(),resetAt:k().datetime().optional()}).passthrough().optional()}).passthrough();var Rt=`quick-task`;function zt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Pt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:st(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Rt}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function Bt(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Vt(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Ht(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Bt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Vt(e)}}function Ut(e){return{...Ht(e),enable:e.enabled}}function Wt(e,t){return{...Ht(e),task:{...Vt(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Z(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Gt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Kt=new Set([`anyLabels`,`authors`,`changedLabels`]);function qt(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!Gt.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||Kt.has(e)&&Array.isArray(t)&&t.length>0)}function Jt(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Yt(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function Q(e,t){return t.startsWith(`-`)?`--${e}=${Z(t)}`:`--${e} ${Z(t)}`}function Xt(e){let t=[`${Ve()} automation add`,Q(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Q(`at`,e.schedule.at),Q(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Q(`latest-start`,Yt(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Q(`cron`,et(e.schedule)));else{t.push(Q(`on`,e.events.join(`,`)),`--every ${Jt(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(Q(`label`,n));for(let n of e.filters?.authors??[])t.push(Q(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Q(`changed-label`,n))}return t.push(...Zt(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Q(`prompt`,e.task.prompt)),t.join(` `)}function Zt(e){let t=[];return e.workflow&&t.push(Q(`workflow`,e.workflow)),e.runner&&t.push(Q(`runner`,e.runner)),e.model&&t.push(Q(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function Qt(e,t){let n=Ut(e),r=qt(n)?Xt(n):`${Ve()} automation create --json ${Z(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Z(t.origin)} CEZ_PROJECT_ID=${Z(t.projectId)} HSQ_COCKPIT_URL=${Z(t.origin)} HSQ_PROJECT_ID=${Z(t.projectId)} ${r}`:r}function $t(e){let t=[],n=!1;for(let r of en(e)){let e=t.length-1;!n&&/^[A-Z_][A-Z0-9_]*=/.test(r)?t.push(r):r.startsWith(`--`)||!n?(t.push(r),n=!0):t[e]=`${t[e]} ${r}`}return t.map((e,t)=>t===0?e:` ${e}`).join(` \\
2
- `)}function en(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];!r&&a===`\\`&&i+1<e.length?(n+=a+e[i+1],i+=1):a===`'`?(r=!r,n+=a):a===` `&&!r?(n&&t.push(n),n=``):n+=a}return n&&t.push(n),t}function tn({draft:e}){let t=Te(),n=window.location.origin,i=(0,H.useMemo)(()=>{let r=Qt(e);return t?`HSQ_COCKPIT_URL=${Z(n)} HSQ_PROJECT_ID=${Z(t)} ${r}`:r},[e,n,t]),a=(0,H.useMemo)(()=>$t(i),[i]),[o,s]=(0,H.useState)(`idle`),[c,l]=(0,H.useState)(!1),u=(0,H.useId)(),d=(0,H.useRef)(void 0);(0,H.useEffect)(()=>()=>clearTimeout(d.current),[]),(0,H.useEffect)(()=>s(`idle`),[i]);let f=async()=>{clearTimeout(d.current);try{await navigator.clipboard.writeText(a),s(`copied`),d.current=setTimeout(()=>s(`idle`),1600)}catch{s(`failed`)}};return(0,K.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border bg-card px-4 py-3.5`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,K.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,K.jsxs)(N,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":c,"aria-controls":u,"aria-label":c?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>l(e=>!e),children:[(0,K.jsx)(`span`,{className:`truncate`,children:c?`Hide`:`Show`}),(0,K.jsx)(me,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,c&&`rotate-180`)})]}),(0,K.jsxs)(N,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>void f(),children:[o===`copied`?(0,K.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}):(0,K.jsx)(ze,{"aria-hidden":`true`,className:`size-3.5`}),o===`copied`?`Copied`:`Copy`]})]}),(0,K.jsx)(`div`,{id:u,hidden:!c,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,K.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:a})}),(0,K.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:o===`failed`?`Could not copy — select the line and copy it by hand.`:(0,K.jsxs)(K.Fragment,{children:[`The definition Save paused would create. `,(0,K.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-[11px] whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Ve()} automation schema`}),` prints its shape.`]})})]})}function nn({pressed:e,onClick:t,disabled:n,children:i}){return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var rn={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},an={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function on(e){let t=e.map(e=>rn[e]);if(t.length===0)return`When GitHub changes`;let n=t.slice(0,-1),r=t[t.length-1];return`When ${n.length>0?`${n.join(`, `)} or ${r}`:r}`}var sn=U.options,cn=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],ln=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],un=e=>(e??[]).join(`, `),dn=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function fn(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function pn(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${fn(e.filters.includeExisting)}`}function mn({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=dn(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=cn.some(t=>t.seconds===e.intervalSeconds)?cn:[...cn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,K.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,K.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:sn.map(t=>(0,K.jsx)(nn,{pressed:e.events.includes(t),onClick:()=>r(t),children:an[t]},t))}),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-interval`,children:`Check every`}),(0,K.jsxs)(Se,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,K.jsx)(F,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(I,{children:o.map(e=>(0,K.jsx)(L,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,K.jsx)(Ce,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,K.jsx)(`span`,{children:`Include existing items`})]}),(0,K.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:fn(e.filters.includeExisting)})]}),(0,K.jsxs)(xe,{children:[(0,K.jsxs)(be,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,K.jsx)(me,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,K.jsx)(ye,{children:(0,K.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[ln.map(t=>(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,K.jsx)(B,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:un(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,K.jsx)(B,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,K.jsx)(B,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var hn=e=>String(e).padStart(2,`0`);function gn({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,H.useState)(hn(t)),o=(0,H.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${hn(n)}.`,l=(0,H.useId)();return(0,H.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(hn(t))}),s?(0,K.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var _n=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],vn=`none`,yn=e=>String(e).padStart(2,`0`);function bn(e,t=Date.now()){let n=ct(t,e)??ct(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${yn(r.getUTCMonth()+1)}-${yn(r.getUTCDate())}T09:00`}function xn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function Sn({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?tt(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${yn(t)}:${yn(n)}`}),l=(0,H.useRef)(null),u=(0,H.useId)(),d=Xe(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,H.useEffect)(()=>{l.current?.setCustomValidity(f?qe:``)},[f]);let p=at(e);return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-once-date`,children:`Date`}),(0,K.jsx)(B,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,K.jsx)(gn,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,K.jsx)(gn,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,K.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:qe}):null,(0,K.jsx)(wn,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,K.jsx)(Tn,{value:e.latestStartMinutes,onChange:t=>n(Cn(e,t))}),p?(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function Cn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function wn({value:e,onCommit:t}){let[n,r]=(0,H.useState)(e),i=(0,H.useRef)(null),a=(0,H.useId)(),o=(0,H.useId)(),[s]=(0,H.useState)(xn),c=n!==e||!Ke(n),l=Ze(n);return(0,H.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,K.jsx)(B,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),Ke(e.target.value)&&t(e.target.value)}}),(0,K.jsx)(`datalist`,{id:a,children:s.map(e=>(0,K.jsx)(`option`,{value:e},e))}),c?(0,K.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function Tn({value:e,onChange:t}){let n=_n.some(t=>t.minutes===e)||e===void 0?_n:[..._n,{minutes:e,label:`${e} minutes`}];return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,K.jsxs)(Se,{value:e===void 0?vn:String(e),onValueChange:e=>t(e===vn?void 0:Number(e)),children:[(0,K.jsx)(F,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(I,{children:n.map(e=>(0,K.jsx)(L,{value:e.minutes===void 0?vn:String(e.minutes),children:e.label},e.label))})]}),(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var En=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Dn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??bn(r),timeZone:e.timeZone??r}:{type:t});return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:En.map(t=>(0,K.jsx)(nn,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,K.jsx)(Sn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,K.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:ot.map((t,n)=>(0,K.jsx)(nn,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(M,{htmlFor:`automation-every`,children:`Run every`}),(0,K.jsxs)(Se,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,K.jsx)(F,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,K.jsx)(P,{})}),(0,K.jsx)(I,{children:rt.map(e=>(0,K.jsx)(L,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,K.jsx)(gn,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,K.jsx)(gn,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,K.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,K.jsx)(`code`,{className:`font-mono text-foreground`,children:et(e)})]})]})}var On=40*864e5,kn=5;function An({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,K.jsx)(jn,{schedule:e,now:n});let r=Ye(e,n+1,n+On,t,kn);return(0,K.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,K.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,K.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,K.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,K.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:V(new Date(e).toISOString(),t)}),(0,K.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:$e(n,e)})]},e))}),(0,K.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function jn({schedule:e,now:t}){let n=Xe(e),r=at(e);return(0,K.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,K.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,K.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:$e(t,n)}):null]}),r?.note?(0,K.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,K.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var Mn={schedule:`On a schedule`,github:`When GitHub changes`};function Nn(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function Pn({title:e,hideLegend:t=!1,failure:n,section:r,children:i}){let a=(0,H.useId)();return(0,K.jsxs)(`section`,{role:t?void 0:`group`,"aria-labelledby":t?void 0:a,className:`grid min-w-0 gap-3.5 rounded-xl border border-border bg-card p-5`,children:[t?null:(0,K.jsx)(`h2`,{id:a,className:`text-sm font-semibold text-foreground`,children:e}),i,n?.section===r&&!n.conflict?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:n.message}):null]})}function Fn({draft:e,patch:t,forge:n,automation:r}){return(0,K.jsx)(K.Fragment,{children:r?(0,K.jsxs)(`p`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Mn[e.kind]]}):(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(Ue,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Mn.schedule},{value:`github`,label:Mn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function In({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,K.jsx)(Dn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,K.jsx)(mn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Ln({draft:e,patch:t,saving:n,automation:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(M,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,K.jsx)(Ge,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,K.jsxs)(K.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,K.jsxs)(K.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,K.jsx)(Hn,{draft:e,patch:t}),(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,K.jsx)(Ce,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,K.jsxs)(`span`,{children:[`Autonomous `,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,K.jsx)(Me,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,K.jsx)(Pe,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Rn({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,K.jsx)(Ce,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,K.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:fn(e.filters.includeExisting)})]})}function zn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,H.useState)(()=>zt(e)),[s,c]=(0,H.useState)(e?.revision),[l,u]=(0,H.useState)(),[p,h]=(0,H.useState)(!1),[g,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(``),C=e=>o(t=>({...t,...e})),te=async t=>{if(t.preventDefault(),p)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await f(e.id,Wt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(Ut(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof d&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:Nn(n),message:n})}finally{h(!1)}},ne=async()=>{if(!(!e||y)){b(!0),S(``);try{await _(e.id),r()}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}},re=(0,H.useId)(),ie=(0,H.useId)(),w=a.kind===`schedule`;return(0,K.jsx)(Ee,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Vn({automation:e,draft:a,formId:re,saveHintId:ie,saving:p}),children:(0,K.jsxs)(`form`,{id:re,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:te,children:[(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,K.jsx)(Pn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(M,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,K.jsx)(B,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>C({name:e.target.value}),required:!0})]})}),(0,K.jsxs)(Pn,{title:`When`,section:`when`,failure:l,children:[(0,K.jsx)(Fn,{draft:a,patch:C,forge:t,automation:e}),(0,K.jsx)(In,{draft:a,patch:C,forge:t,timeZone:n,automation:e})]}),(0,K.jsx)(Pn,{title:`What to run`,section:`run`,failure:l,children:(0,K.jsx)(Ln,{draft:a,patch:C,saving:p,automation:e})}),(0,K.jsx)(Pn,{title:`Enable`,section:`enable`,failure:l,children:(0,K.jsx)(Rn,{draft:a,patch:C,automation:e})}),l?.section===`form`?(0,K.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,K.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,K.jsx)(N,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[g?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(N,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:y,onClick:()=>void ne(),children:`Delete automation`}),(0,K.jsx)(N,{type:`button`,variant:`outline`,disabled:y,onClick:()=>{v(!1),S(``)},children:`Keep`})]})]}):(0,K.jsx)(N,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>v(!0),children:`Delete`}),x?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:x}):null]}):null]}),(0,K.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4`,children:[w?(0,K.jsx)(An,{schedule:a.schedule,timeZone:n}):(0,K.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,K.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,K.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:pn(a)})]}),(0,K.jsx)(tn,{draft:a})]})]})})}function Bn(e){let t=[!e.name.trim()&&`a name`,!e.prompt.trim()&&`a prompt`].filter(Boolean);return t.length?`Add ${t.join(` and `)} to save.`:``}function Vn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Bn(t),s=e?`Save changes`:t.enabled?`Save and enable`:`Save paused`;return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:o?(0,K.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`text-xs text-muted-foreground`,children:o}):void 0,secondaryActions:(0,K.jsx)(Ae,{type:`button`,variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,K.jsx)(Ae,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Hn({draft:e,patch:t}){let n=i(),r=We(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=o(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),ee=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],_=[...new Set([...u,...e.runner?[e.runner]:[]])],v=Be(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,b=e=>(0,K.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,K.jsx)(Re,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Le,{slot:`automation-workflow-pill`,icon:b(ge),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:ee.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,K.jsx)(Le,{slot:`automation-runner-pill`,icon:b(pe),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?l(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},..._.map(e=>({value:e,label:l(p.data,e)}))],footer:(0,K.jsx)(Ie,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,K.jsx)(Le,{slot:`automation-model-pill`,icon:b(_e),fieldLabel:!0,ariaLabel:`Model`,label:y,value:e.model??``,options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Un({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,H.useState)({}),[c,l]=(0,H.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){d(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await m(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await S(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await C(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await v(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)}),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,K.jsx)(z,{route:`automations`,density:e?Oe(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,K.jsx)(Ae,{variant:`primary`,asChild:!0,children:(0,K.jsxs)(R,{to:`/automations/new`,children:[(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,K.jsx)(ke,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,K.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,K.jsx)(R,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:t}),(0,K.jsx)(N,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,K.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Active`,(0,K.jsx)(Wn,{count:y.length})]}),(0,K.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,K.jsx)(Wn,{count:b.length})]})]}):(0,K.jsx)(`span`,{}),(0,K.jsx)(`div`,{className:`pb-2.5`,children:(0,K.jsx)(Gn,{data:e})})]}),i&&x.length===0?(0,K.jsx)(q,{text:`No archived one-time schedules.`}):x.length===0?(0,K.jsx)(je,{icon:(0,K.jsx)(he,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,K.jsx)(N,{variant:`primary`,asChild:!0,children:(0,K.jsxs)(R,{to:`/automations/new`,children:[(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,K.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,K.jsx)(nr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void h(t),onPreview:()=>void ee(t),onCancel:()=>void g(t)},t.id))})]}):(0,K.jsx)(q,{text:`Loading automations…`})})}function Wn({count:e}){return e===0?null:(0,K.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function Gn({data:e}){return(0,K.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function Kn(e){return e.kind===`schedule`&&e.schedule?Qe(e.schedule):`${on(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var qn={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function Jn(e){if(e.schedule?.type===`once`)return qn[e.onceStatus??(e.enabled?`waiting`:`paused`)]}function Yn({automation:e,badge:t,nextRun:n}){return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,K.jsx)(e.kind===`schedule`?fe:ue,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,K.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:Kn(e)}),n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n]}):null]})]}),t?(0,K.jsx)(He,{dot:t.dot,children:t.label}):(0,K.jsx)(He,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]})}function Xn({automation:e,archive:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,K.jsx)(N,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}`,children:`Details`})})})]})}function Zn({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,K.jsx)(`span`,{children:`continuous`}):r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${V(r,t)}`}),(0,K.jsx)(`span`,{children:`· ${$e(Date.now(),Date.parse(r))}`})]}):(0,K.jsx)(`span`,{children:`Next run: —`})}function Qn({automation:e,timeZone:t}){let n=e.enabled?gt(e.state):void 0;return n?(0,K.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${V(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function $n({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,K.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,K.jsx)(N,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function er({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(N,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,K.jsx)(N,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function tr({note:e}){return(0,K.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function nr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,K.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border bg-card p-4`,children:[(0,K.jsx)(Yn,{automation:e,badge:Jn(e),nextRun:h?void 0:(0,K.jsx)(Zn,{automation:e,timeZone:t})}),h?(0,K.jsx)(Xn,{automation:e,archive:h}):null,h?null:(0,K.jsx)(Qn,{automation:e,timeZone:t}),h?null:(0,K.jsx)($n,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,K.jsx)(er,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,K.jsx)(tr,{note:n}):null,(0,K.jsx)(Ot,{automationId:e.id,automationName:e.name,timeZone:t})]})}function rr(e){let t=Te(),n=Ne(),[r,i]=(0,H.useState)(),[a,o]=(0,H.useState)(``),s=(0,H.useCallback)(t=>re({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,H.useEffect)(()=>{n&&s()},[n,s]),(0,H.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,H.useEffect)(()=>le((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function ir({mode:e=`list`}){let{automationId:t}=ce(),n=we(),[r,i]=(0,H.useState)(!1),{data:a,error:o,refresh:s}=rr(`include`),[c,l]=(0,H.useState)(0),u=Fe();if(u===`unknown`)return(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(q,{text:`Loading automations…`})});if(u===`unavailable`)return(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(je,{icon:(0,K.jsx)(he,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,K.jsx)(Un,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,K.jsx)(z,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:o}),(0,K.jsx)(N,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(q,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,K.jsx)(zn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,K.jsx)(kt,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,K.jsx)(zn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,K.jsx)(z,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,K.jsx)(N,{asChild:!0,variant:`outline`,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})}):t?(0,K.jsx)(Dt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,K.jsx)(q,{text:`Automation not found.`})}export{ir as AutomationsRoute};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DSMR_WLb.js";import{_t as n}from"./queries-ClkIgWFx.js";import{Fn as r}from"./toaster-C-xqAWVX.js";import{t as i}from"./createLucideIcon-BHp8sXmF.js";import{t as a}from"./chevron-right-BENZ-1ZN.js";import{t as o}from"./folder-o-AvL3y3.js";var s=i(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),c=e(),l=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,u=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function d(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?null:n===0?t.slice(0,1):t.slice(0,n)}function f({path:e,selected:r,onSelect:i,onEnter:l,decorate:u,emptyHint:d,showHidden:f=!1}){let m=n(e,f),h=m.data?.parent??null;return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-[11px] text-soft-foreground`,title:m.data?.path??void 0,children:m.data?.path??(m.isError?``:`Loading…`)}),m.isError?(0,c.jsx)(p,{error:m.error,path:e,onEnter:l,onRetry:()=>void m.refetch()}):(0,c.jsxs)(`ul`,{"data-slot":`fs-listing`,className:`max-h-64 divide-y divide-border/60 overflow-y-auto overscroll-contain rounded-md border border-border`,children:[h===null?null:(0,c.jsx)(`li`,{className:`flex`,children:(0,c.jsxs)(`button`,{type:`button`,"data-slot":`fs-up`,onClick:()=>l(h),className:`flex flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,c.jsx)(s,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),`Up one level`]})}),(m.data?.dirs??[]).map(e=>(0,c.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,c.jsxs)(`button`,{type:`button`,"data-slot":`fs-dir`,"aria-pressed":r?.path===e.path,onClick:()=>i(e),onDoubleClick:()=>l(e.path),className:t(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,r?.path===e.path&&`bg-muted`),children:[(0,c.jsx)(o,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,c.jsx)(`span`,{className:`truncate`,children:e.name}),u?.(e)]}),(0,c.jsx)(`button`,{type:`button`,"data-slot":`fs-enter`,"aria-label":`Open ${e.name}`,onClick:()=>l(e.path),className:`flex shrink-0 items-center px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,c.jsx)(a,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),m.data&&m.data.dirs.length===0?(0,c.jsx)(`li`,{className:`px-3 py-2 text-[13px] text-muted-foreground`,children:d}):null]}),m.data?.truncated?(0,c.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-[11px] text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function p({error:e,path:t,onEnter:n,onRetry:i}){let a=e instanceof r&&e.status===403,o=t===null?null:d(t);return(0,c.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,c.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:e instanceof Error?e.message:`could not list that folder`}),a?(0,c.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-[12.5px] text-soft-foreground`,children:`Allow it under Privacy & Security ▸ Files & Folders, then try again.`}):null,(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[12.5px]`,children:[o===null?null:(0,c.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>n(o),className:u,children:[(0,c.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),a?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:l,target:`_blank`,rel:`noreferrer`,className:u,children:`Open Privacy Settings`}),(0,c.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:i,className:u,children:`Try again`})]}):null]})]})}function m(e,t,r=!1){let i=n(e,r);return t?.path??i.data?.path??null}export{m as n,f as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{F as a,T as o,j as s,st as c,u as l}from"./design-icons-CzEoMH9c.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./external-link-BE6y205O.js";import{i as f,n as p,r as m,t as h}from"./diff-controls-_6OoQImc.js";import{t as g}from"./square-terminal-B6RYYieR.js";import{t as _}from"./button-B7MKxYjT.js";import{i as v,p as y,r as b,t as x}from"./dropdown-menu-4e2iKSMT.js";import{t as S}from"./diff-stat-U7DT4Ilj.js";var C=u(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),w=u(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),T=e(t(),1),E=n();function D({root:e,selected:t,onSelect:n}){return(0,E.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-[13px]`,children:(0,E.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,E.jsx)(k,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,E.jsx)(j,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})}function O({adds:e,dels:t}){return(0,E.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-xs font-medium tabular-nums`,children:[e>0?(0,E.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,E.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function k({dir:e,depth:t,selected:n,onSelect:r}){let[a,s]=(0,T.useState)(!0);return(0,E.jsxs)(`li`,{children:[(0,E.jsxs)(`button`,{type:`button`,"data-slot":`tree-dir`,"data-path":e.path,"data-state":a?`open`:`closed`,"aria-expanded":a,onClick:()=>s(e=>!e),className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+t*14}px`},children:[(0,E.jsx)(l,{size:16,"aria-hidden":`true`,className:i(`size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}),(0,E.jsx)(o,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,E.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,E.jsx)(O,{adds:e.adds,dels:e.dels})]}),a?(0,E.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,E.jsx)(k,{dir:e,depth:t+1,selected:n,onSelect:r},e.path)),e.files.map(e=>(0,E.jsx)(j,{file:e,depth:t+1,selected:n,onSelect:r},e.path))]}):null]})}var A={added:`text-success`,deleted:`text-danger`};function j({file:e,depth:t,selected:n,onSelect:r}){let a=n===e.path;return(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,"data-slot":`tree-file`,"data-path":e.path,"aria-current":a?`true`:void 0,onClick:()=>r(e.path),className:i(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,a?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+t*14}px`},children:[(0,E.jsx)(w,{"aria-hidden":`true`,className:i(`size-3.5 shrink-0`,A[e.status])}),(0,E.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,E.jsx)(O,{adds:e.adds,dels:e.dels})]})})}function M(e,t){return{kind:`dir`,name:e,path:t,dirs:[],files:[],adds:0,dels:0,fileCount:0}}function N(e){let t=e;for(;t.files.length===0&&t.dirs.length===1;){let e=t.dirs[0];t={...e,name:`${t.name}/${e.name}`}}return{...t,dirs:t.dirs.map(N)}}var P=(e,t)=>e.name.localeCompare(t.name);function F(e){let t=M(``,``),n=new Map([[``,t]]),r=e=>{let t=n.get(e);if(t)return t;let i=e.lastIndexOf(`/`),a=r(i===-1?``:e.slice(0,i)),o=M(i===-1?e:e.slice(i+1),e);return a.dirs.push(o),n.set(e,o),o};for(let t of e){let e=t.path.lastIndexOf(`/`);r(e===-1?``:t.path.slice(0,e)).files.push({kind:`file`,name:e===-1?t.path:t.path.slice(e+1),path:t.path,status:t.status,adds:t.adds,dels:t.dels,binary:t.binary})}let i=e=>{e.dirs.forEach(i),e.adds=e.files.reduce((e,t)=>e+t.adds,0)+e.dirs.reduce((e,t)=>e+t.adds,0),e.dels=e.files.reduce((e,t)=>e+t.dels,0)+e.dirs.reduce((e,t)=>e+t.dels,0),e.fileCount=e.files.length+e.dirs.reduce((e,t)=>e+t.fileCount,0),e.dirs.sort(P),e.files.sort(P)};return i(t),{...t,dirs:t.dirs.map(N)}}function I({bar:e,healthReady:t,branch:n,stat:r,mode:a,wrap:o,preview:s=!1,onModeChange:c,onWrapChange:l,onPreviewChange:u,onAction:d}){return(0,E.jsxs)(`div`,{"data-slot":`git-toolbar`,"data-health-ready":t,className:`flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-4 md:px-9 [&_button]:min-h-11`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[n?(0,E.jsx)(h,{branch:n}):null,r?(0,E.jsx)(z,{stat:r}):null]}),(0,E.jsxs)(`span`,{className:i(`ml-auto flex items-center gap-1.5`,!u&&`md:hidden`),children:[(0,E.jsx)(`span`,{className:`flex md:hidden`,children:(0,E.jsx)(f,{wrap:o,onWrapChange:l})}),u?(0,E.jsx)(m,{preview:s,onPreviewChange:u}):null]}),(0,E.jsxs)(`span`,{className:i(`flex items-center gap-2 max-md:w-full`,!u&&`md:ml-auto`),children:[(0,E.jsx)(`span`,{className:`hidden items-center gap-1.5 md:flex`,children:(0,E.jsx)(p,{mode:a,wrap:o,onModeChange:c,onWrapChange:l})}),(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`hidden h-5 w-px bg-border md:block`}),(0,E.jsxs)(`span`,{"data-slot":`git-toolbar-actions`,className:`flex items-center gap-1.5 max-md:flex-1 max-md:[&>*]:flex-1`,children:[e.secondary.map(e=>(0,E.jsx)(R,{action:e,variant:`outline`,onAction:d},e.id)),(0,E.jsx)(R,{action:e.primary,variant:`primary`,onAction:d})]}),e.menu.length>0?(0,E.jsxs)(x,{children:[(0,E.jsx)(y,{asChild:!0,children:(0,E.jsx)(_,{variant:`ghost`,size:`icon-sm`,"aria-label":`More git actions`,className:`max-md:min-w-11 max-md:border max-md:border-border max-md:bg-card`,children:(0,E.jsx)(C,{"aria-hidden":`true`})})}),(0,E.jsx)(b,{align:`end`,"data-slot":`git-toolbar-menu`,children:e.menu.map(e=>(0,E.jsxs)(v,{disabled:!e.enabled,title:e.reason,onSelect:()=>d(e.id),children:[L[e.id],e.label]},e.id))})]}):null]})]})}var L={commit:(0,E.jsx)(s,{size:16,"aria-hidden":`true`}),push:(0,E.jsx)(c,{size:16,"aria-hidden":`true`}),"create-pr":(0,E.jsx)(a,{size:16,"aria-hidden":`true`}),"view-pr":(0,E.jsx)(d,{"aria-hidden":`true`}),"open-terminal":(0,E.jsx)(g,{"aria-hidden":`true`})};function R({action:e,variant:t,onAction:n}){return e.id===`view-pr`?r(e.href)?(0,E.jsx)(_,{asChild:!0,variant:t,size:`sm`,"data-action":e.id,children:(0,E.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:[L[e.id],e.label]})}):(0,E.jsxs)(_,{variant:t,size:`sm`,"data-action":e.id,disabled:!0,title:`View PR unavailable — the recorded PR link is not an http(s) URL`,children:[L[e.id],e.label]}):(0,E.jsxs)(_,{variant:t,size:`sm`,"data-action":e.id,disabled:!e.enabled,title:e.enabled?void 0:e.reason,onClick:()=>n(e.id),children:[L[e.id],e.label]})}function z({stat:e}){return(0,E.jsx)(`span`,{"data-slot":`changes-stat`,children:(0,E.jsx)(S,{stat:{adds:B(e.adds),dels:B(e.dels),files:e.files}})})}function B(e){let[t,n]=(0,T.useState)(e),r=(0,T.useRef)(e);return(0,T.useEffect)(()=>{let t=r.current;if(t===e)return;if(typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||typeof requestAnimationFrame!=`function`){r.current=e,n(e);return}let i=performance.now(),a=0,o=s=>{let c=Math.min(1,(s-i)/350),l=1-(1-c)**3;n(Math.round(t+(e-t)*l)),c<1?a=requestAnimationFrame(o):r.current=e};return a=requestAnimationFrame(o),()=>{cancelAnimationFrame(a),r.current=e,n(e)}},[e]),t}export{D as i,I as n,F as r,z as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{M as a,Wt as o,cn as s,dn as c,i as l,k as u,l as d,o as f,r as p,s as m}from"./queries-ClkIgWFx.js";import{An as h,G as g,I as _,K as v,Si as y,U as b,hi as x,n as S,q as C}from"./toaster-C-xqAWVX.js";import{h as ee}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{F as w,I as T,X as E,Y as D,c as O,ct as k,l as A,ot as j,p as M,r as te}from"./design-icons-CzEoMH9c.js";import{t as ne}from"./chevron-down-CHGyCDBH.js";import{t as N}from"./chevron-right-BENZ-1ZN.js";import{t as P}from"./loader-circle-CPBhhDbB.js";import{t as F}from"./play-CmVAj_fu.js";import{t as I}from"./button-B7MKxYjT.js";import{a as re,i as ie,n as ae,r as L,t as oe}from"./select-ETUx1MVz.js";import{i as R,r as z,t as B}from"./popover-BPgUYFyu.js";import{r as se,t as V}from"./project-router-CT6gVIcC.js";import"./attention--Y0CyzCN.js";import{f as ce,v as le}from"./task-groups-aquji1Kv.js";import{t as ue}from"./status-dot-BRzVlF2X.js";import{a as de,o as fe,r as pe,s as me,t as he}from"./command-KdW7aO0N.js";import{d as ge,s as H,u as U}from"./page-shell-7pLJMOgh.js";import{t as W}from"./centered-state-V15AR_qo.js";import{t as _e}from"./use-search-params-writer-ClMScnNe.js";import{Ct as ve,Dn as ye,Sn as be,St as xe,Tt as Se,Zt as Ce,_t as we,bt as Te,ft as Ee,gt as De,ht as Oe,it as ke,mt as Ae,pt as je,s as Me,vt as Ne,wt as Pe,xt as Fe,yt as G}from"./index-7M_Uae0m.js";import{a as Ie,d as Le,f as Re,i as ze,l as Be,n as Ve,o as He,r as Ue,s as We,t as Ge,u as K}from"./use-hand-to-agent-state-P0PYtQDy.js";import{t as Ke}from"./tab-link-DE6t7XkG.js";var q=e(t(),1),qe=`cez-github-list-width`;function J(e){if(e==null||e===``||typeof e==`string`&&e.trim()===``)return 360;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(520,Math.max(280,Math.round(t))):360}function Je(){try{let e=localStorage.getItem(qe);return e===null?360:J(e)}catch{return 360}}function Ye(e){try{localStorage.setItem(qe,String(J(e)))}catch{}}var Y=n();function Xe({number:e,repo:t}){let n=r();return(0,Y.jsx)(Ze,{number:e,repo:t,scope:n},JSON.stringify([n,t,e]))}function Ze({number:e,repo:t,scope:n}){let r=(0,q.useId)(),o=(0,q.useId)(),[c,l]=(0,q.useState)(!1),u=c?ne:N,d=s(n,!0,n==="default"),f=a(`#${e}`,!0),p=(0,q.useMemo)(()=>xe(le(d.data??[],f.data?.pages.flatMap(e=>e.runs)??[]),e,t,n),[d.data,f.data,e,t,n]);return(0,Y.jsxs)(`section`,{"aria-labelledby":r,className:i(`mt-4 min-w-0 rounded-lg border border-border`,c?`p-3`:`p-0.5`),children:[(0,Y.jsx)(`h3`,{id:r,className:`text-xs font-semibold text-muted-foreground`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":c,"aria-controls":o,onClick:()=>l(e=>!e),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2.5 text-left hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Linked tasks`,d.data?` (${p.length}${f.hasNextPage||f.isError?`+`:``})`:``]})]})}),(0,Y.jsx)(`div`,{id:o,children:c?(0,Y.jsxs)(Y.Fragment,{children:[d.isPending?(0,Y.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:`Loading linked tasks…`}):null,d.isError?(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{role:`status`,children:`Couldn’t load linked tasks. Check your connection and try again.`}),(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void d.refetch(),disabled:d.isFetching,children:`Retry linked tasks`})]}):null,d.data&&p.length===0&&!d.isError?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No linked tasks yet.`}):null,p.length>0?(0,Y.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:p.map(e=>{let t=h(e);return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(V,{to:`/tasks/${encodeURIComponent(e.id)}`,className:`flex min-h-11 min-w-0 flex-col justify-center gap-1 rounded-md px-2 py-2 hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium break-words [overflow-wrap:anywhere]`,children:ce(e)}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ue,{tone:t.tone,shape:t.shape,pulse:t.pulse,role:`img`,"aria-label":t.label,title:t.label}),e.archived?(0,Y.jsx)(`span`,{className:`rounded border border-border px-1`,children:`Archived`}):null,(0,Y.jsx)(`time`,{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleDateString()})]})]})},e.id)})}):null,f.isError?(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{role:`status`,children:`Couldn’t load older archived linked tasks.`}),(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void f.refetch(),disabled:f.isFetching,children:`Retry older linked tasks`})]}):f.hasNextPage?(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void f.fetchNextPage(),disabled:f.isFetchingNextPage,children:f.isFetchingNextPage?`Loading older linked tasks…`:`Show older linked tasks`}):null]}):null})]})}var Qe=`w-44 max-w-full`,X=`min-h-11 min-w-11 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-ring disabled:opacity-60`,Z=`__all__`;function $e(e,t){let n=new Map;for(let t of e)for(let e of t.assignees??[])n.set(e.toLowerCase(),e);for(let e of t)n.set(e.toLowerCase(),e);return[...n.values()].sort((e,t)=>e.localeCompare(t))}function et(e,t){return!!e&&t.length===1&&t[0]?.toLowerCase()===e.toLowerCase()}function tt(e){let t=` Previous memberships are shown; issues with unknown membership remain visible.`;return e.projectsState===`refreshing`&&e.projects?`Refreshing project boards.${t}`:e.projectsState===`unavailable`&&e.projects?`${e.projectsReason}${t}`:e.projects?``:e.projectsReason??(e.projectsState===`refreshing`?`Project memberships pending.`:`Project boards unavailable.`)}function nt(e){return[e.viewerLogin?``:`GitHub login unavailable.`,tt(e)].filter(Boolean).join(` `)}function rt({options:e,assignees:t,onAssigneesChange:n}){return(0,Y.jsxs)(B,{children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`${X} inline-flex items-center gap-1.5`,disabled:e.length===0,children:[`Assignee`,t.length?` · ${t.length}`:``,(0,Y.jsx)(A,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,Y.jsx)(z,{align:`start`,className:`w-64 max-w-[calc(100vw-2rem)] p-2`,children:(0,Y.jsxs)(`fieldset`,{className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] overflow-y-auto`,children:[(0,Y.jsx)(`legend`,{className:`px-2 text-xs text-muted-foreground`,children:`Match any selected assignee`}),e.map(e=>{let r=t.some(t=>t.toLowerCase()===e.toLowerCase());return(0,Y.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded px-2 hover:bg-muted`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>n(r?t.filter(t=>t.toLowerCase()!==e.toLowerCase()):[...t,e])}),(0,Y.jsx)(`span`,{className:`break-all text-sm`,children:e})]},e.toLowerCase())})]})})]})}function it({data:e,projectId:t,onProjectChange:n,pickerRef:r}){if(e.projects?.length)return(0,Y.jsxs)(oe,{value:t||Z,onValueChange:e=>n(e===Z?``:e),children:[(0,Y.jsx)(ie,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":t,className:`${X} ${Qe} justify-between`,children:(0,Y.jsx)(re,{placeholder:`All boards`})}),(0,Y.jsxs)(ae,{align:`start`,children:[(0,Y.jsx)(L,{value:Z,children:`All boards`}),e.projects.map(e=>(0,Y.jsx)(L,{value:e.id,"data-board":e.id,children:e.title},e.id))]})]});if(e.projects||e.projectsState){let t=e.projects?`No boards`:e.projectsState===`refreshing`?`Loading boards…`:`Boards unavailable`;return(0,Y.jsxs)(oe,{disabled:!0,value:Z,children:[(0,Y.jsx)(ie,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":``,className:`${X} ${Qe} justify-between`,children:(0,Y.jsx)(re,{placeholder:t,children:t})}),(0,Y.jsx)(ae,{align:`start`,children:(0,Y.jsx)(L,{value:Z,children:t})})]})}return null}function at({data:e,message:t,lastMessage:n,hasMessage:r,statusOpen:i,setStatusOpen:a,triggerRef:o,contentRef:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`status`,className:`sr-only`,children:t}),(0,Y.jsxs)(B,{open:i,onOpenChange:a,children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.jsx)(`button`,{ref:o,type:`button`,className:`${X} inline-flex items-center justify-center ${t?``:`invisible`}`,"aria-label":`Project board status`,tabIndex:t?void 0:-1,children:e.projectsState===`refreshing`?(0,Y.jsx)(D,{size:14,"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):(0,Y.jsx)(j,{size:14,"aria-hidden":`true`,className:`size-3.5`})})}),(0,Y.jsx)(z,{ref:s,align:`start`,"data-slot":`gh-issue-status`,onCloseAutoFocus:e=>{r||e.preventDefault()},className:`w-72 max-w-[calc(100vw-2rem)] p-3 text-xs text-muted-foreground`,children:t||n.current})]})]})}function ot({data:e,assignees:t,projectId:n,onAssigneesChange:r,onProjectChange:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=$e(e.issues,t),f=et(e.viewerLogin,t),p=nt(e),m=p!==``,h=(0,q.useRef)(p);m&&(h.current=p);let g=(0,q.useRef)(!m);g.current=!m;let _=()=>(l.current&&!l.current.disabled?l.current:u.current)?.focus();return(0,q.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>{g.current&&!e.relatedTarget&&requestAnimationFrame(()=>{(!document.activeElement||document.activeElement===document.body)&&_()})};return e.addEventListener(`blur`,t),()=>e.removeEventListener(`blur`,t)},[]),(0,q.useEffect)(()=>{if(m)return;let e=document.activeElement,t=!!e&&(e===s.current||!!c.current?.contains(e));o(!1),t&&_()},[m]),(0,Y.jsxs)(`div`,{className:`contents`,"data-slot":`gh-issue-filters`,children:[(0,Y.jsx)(rt,{options:d,assignees:t,onAssigneesChange:r}),(0,Y.jsxs)(`button`,{ref:u,type:`button`,"data-slot":`gh-assigned-me`,className:`${X} inline-flex items-center gap-1.5 rounded-full aria-pressed:border-foreground aria-pressed:bg-foreground aria-pressed:text-background`,disabled:!e.viewerLogin,"aria-pressed":f,onClick:()=>r(f?[]:[e.viewerLogin]),children:[(0,Y.jsx)(k,{size:14,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Assigned to me`]}),(0,Y.jsx)(it,{data:e,projectId:n,onProjectChange:i,pickerRef:l}),(0,Y.jsx)(at,{data:e,message:p,lastMessage:h,hasMessage:m,statusOpen:a,setStatusOpen:o,triggerRef:s,contentRef:c})]})}function st({onRefresh:e,refreshing:t}){let n=Ee(r());return(0,Y.jsx)(U,{route:`github`,density:`full`,headerSpacing:`compact`,header:{title:`GitHub`,secondaryActions:(0,Y.jsx)(H,{type:`button`,variant:`ghost`,"data-slot":`gh-screen-refresh`,"aria-label":`Refresh from GitHub`,title:`Refresh from GitHub`,disabled:t,onClick:e,children:(0,Y.jsx)(D,{size:17,"aria-hidden":`true`,className:i(`size-[17px]`,t&&`motion-safe:animate-spin`)})})},children:(0,Y.jsx)(`div`,{"data-slot":`github-filter-screen`,children:(0,Y.jsx)(je,{model:n,variant:`screen`})})})}function ct({view:e,activeFilter:t,isDesktop:n,rawFilterParam:r,n:i,gh:a,actions:o}){return{headerSlot:`gh-masthead`,title:n?e===`issues`?`Issues`:`Pull requests`:`GitHub`,scope:n?Ae[t]:void 0,scopeSlot:`gh-title-qualifier`,subtitle:a.repo?(0,Y.jsxs)(`span`,{className:`block min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{"data-slot":`gh-repo`,children:a.repo}),(0,Y.jsxs)(`span`,{"data-slot":`gh-synced`,title:a.syncedAt?new Date(a.syncedAt).toLocaleString():void 0,children:[` `,`· `,a.syncedAt?(0,Y.jsx)(be,{iso:a.syncedAt,prefix:`Synced `}):`Not synced yet`]})]}):void 0,secondaryActions:(0,Y.jsx)(lt,{...o}),headerExtra:r!==null&&i===void 0?(0,Y.jsxs)(`div`,{"data-slot":`gh-filter-context`,className:`mt-1 flex min-w-0 items-center gap-3 md:hidden`,children:[(0,Y.jsxs)(V,{to:`/github`,"data-slot":`gh-back-filters`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Y.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to filters`]}),t===`all`?null:(0,Y.jsx)(`span`,{"data-slot":`gh-active-filter`,className:`truncate text-xs text-muted-foreground`,children:[...De,...we].find(e=>e.id===t)?.label})]}):void 0}}function lt({automationsAvailable:e,refreshing:t,onRefresh:n}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-page-actions`,className:`flex shrink-0 flex-wrap items-center gap-2`,children:[e?(0,Y.jsx)(H,{variant:`outline`,asChild:!0,children:(0,Y.jsx)(V,{to:`/automations/new`,children:`Set up automations`})}):null,(0,Y.jsxs)(H,{type:`button`,variant:`outline`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:t,onClick:n,children:[(0,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:i(`size-3.5`,t&&`motion-safe:animate-spin`)}),`Refresh`]})]})}function ut({view:e,number:t}){return(0,Y.jsx)(W,{icon:e===`issues`?(0,Y.jsx)(M,{size:16}):(0,Y.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:t===null?`Nothing selected`:`Not found`,subtitle:t===null?`No open ${e===`issues`?`issues`:`pull requests`} to show.`:`#${t} is not among the open ${e===`issues`?`issues`:`pull requests`}. Search for ${t} above to look it up on GitHub, closed and merged included.`})}function dt({item:e,view:t,filter:n,colors:r,active:a,queued:s,checks:c,comments:l}){let u=e.kind===`issue`?M:w,d=x(),f=()=>{d.prefetchQuery({queryKey:o.githubComments(e.kind,e.number),queryFn:({signal:t})=>v(e.kind,e.number,{},{signal:t}),staleTime:6e4})};return(0,Y.jsxs)(V,{to:G(t,n,e.number),draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,Ue(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},onMouseEnter:f,onFocus:f,"data-slot":`gh-row`,"data-number":e.number,"data-kind":e.kind,"aria-current":a?`page`:void 0,title:`Drag into the composer to prefill a task`,className:i(`flex flex-col gap-2 rounded-md px-3 py-4 transition-colors hover:bg-muted`,a&&`bg-accent-strong/10 text-accent-text`),children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 md:items-center`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`,"data-slot":`gh-row-icon`,className:i(`mt-0.5 size-3.5 shrink-0 md:mt-0`,e.kind===`issue`?`text-success`:`text-accent-icon`)}),(0,Y.jsx)(`span`,{"data-slot":`gh-row-title`,className:i(`line-clamp-2 min-w-0 text-[13px] font-medium md:block md:truncate`,a&&`font-semibold`),children:e.title})]}),(0,Y.jsxs)(`span`,{"data-slot":`gh-row-meta`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 pl-[22px] text-xs text-muted-foreground md:flex-nowrap md:gap-y-0`,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`#`,e.number]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{"data-slot":`gh-row-author`,className:`max-w-full shrink-0 truncate md:min-w-0 md:shrink`,children:e.author}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(be,{iso:e.createdAt,className:`shrink-0`}),l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(Ie,{count:l})]}):null,c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(ze,{checks:c})]}):null,s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{"data-slot":`gh-queued-flag`,className:`shrink-0 font-sans font-medium text-accent-text`,children:`↗ run queued`})]}):null]}),e.labels.length>0?(0,Y.jsx)(`span`,{"data-slot":`gh-row-labels`,className:`flex flex-wrap gap-1 pl-[22px]`,children:e.labels.map(e=>(0,Y.jsx)(We,{label:e,color:r[e],plain:!0},e))}):null]})}function Q(){return(0,Y.jsx)(`span`,{"data-slot":`gh-row-dot`,"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ft(e){let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`?e:e.closest(`[data-slot="main"]`)??e}function pt(e){let[t,n]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{if(!e){n(null);return}let t=()=>n(ft(e));t();let r=typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 768px)`):null;r?.addEventListener(`change`,t);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return i?.observe(e),()=>{r?.removeEventListener(`change`,t),i?.disconnect()}},[e]),t}function mt(e,t){let[n,r]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{let n=()=>{!e||!t||r(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[e,t]),n}function ht(e,t,n){let[r,i]=(0,q.useState)(null),a=(0,q.useRef)(n);return(0,q.useEffect)(()=>{a.current=n}),(0,q.useEffect)(()=>{if(!e||!r||!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&a.current()},{root:t.getAttribute(`data-slot`)===`main`?null:t,rootMargin:`0px 0px 600px 0px`});return n.observe(r),()=>n.disconnect()},[e,r,t]),i}function gt(e,t,n,r,i){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=pt(a),u=(0,q.useRef)(null);u.current=l;let d=mt(s,l),f=e===`issues`?n?.issues.length??0:n?.prs.length??0,p=t.hasNextPage&&r===null&&f>0;return{listEl:a,setListEl:o,setRowsEl:c,scrollOwner:l,scrollOwnerRef:u,startMargin:d,pagingAvailable:p,manualPaging:p&&i,loadMoreRef:ht(p&&!i&&!t.isFetchingNextPage&&!t.isFetchNextPageError,l,()=>void t.fetchNextPage())}}function _t({item:e,queuedRunId:t}){return t?(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11 no-hover:h-11`,children:(0,Y.jsxs)(V,{to:`/tasks/${t}`,"data-action":`gh-header-view-task`,children:[(0,Y.jsx)(O,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,Y.jsxs)(I,{type:`button`,variant:`primary`,size:`sm`,"data-action":`gh-header-handoff`,title:`Write the prompt and pick the workflow and runner for this ${e.kind===`pr`?`PR`:`issue`}`,className:`max-md:h-11 no-hover:h-11`,onClick:$,children:[(0,Y.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}function $(){let e=document.querySelector(`[data-slot="gh-detail-inner"] [data-slot="gh-custom-prompt"]`);e?.scrollIntoView({block:`center`}),e?.focus({preventScroll:!0})}var vt=100;function yt(e,t,n,r,i){if(!e?.available||t!==`prs`)return[];let a=new Set;n!==null&&Number.isInteger(n)&&a.add(n);for(let t of[...r,...i,...e.prs]){if(a.size>=vt)break;a.add(t.number)}return[...a]}function bt(e,t,n,r,i,a){let o=yt(n,e,r,i,a),s=p(o,e===`prs`),c=s.data?.available?s.data.checks:void 0,u=l(e===`issues`?`issue`:`pr`,(0,q.useMemo)(()=>(t.data?.pages??[]).map(t=>(e===`issues`?t.issues:t.prs).map(e=>e.number)),[t.data,e]),n?.available===!0&&n.commentsDeferred===!0),d=(0,q.useMemo)(()=>new Set(n?.commentsDeferred?(e===`issues`?n.issues:n.prs).map(e=>e.number):[]),[n,e]);return{checkPrNumbers:o,checksMap:c,commentsOf:e=>u[e.number]??(d.has(e.number)?void 0:e.comments)}}function xt(e){let[t,n]=_e(),r=t.get(`filter`),i=ve(e,r);return{rawFilterParam:r,filter:i,activeFilter:i??`all`,setFilterParam:e=>n(t=>{let n=new URLSearchParams(t);return e===null?n.delete(`filter`):n.set(`filter`,e),n})}}function St(e,t,{filter:n,activeFilter:r,setFilterParam:i}){let[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)([]),[l,u]=(0,q.useState)([]),{setProjectFilter:d,activeProject:f}=Ct(t),p=e===`issues`&&r===`assigned`,m=p?t?.viewerLogin?[t.viewerLogin]:[]:l;return{query:a,setQuery:o,labelFilter:s,setLabelFilter:c,setProjectFilter:d,activeProject:f,isAssignedFilter:p,effectiveAssignees:m,changeAssignees:e=>{u(e),p&&i(`all`)},clearFilters:()=>{o(``),c([]),u([]),d(``),n!==null&&n!==`all`&&i(`all`)},filtering:a.trim()!==``||s.length>0||e===`issues`&&(m.length>0||f!==``)||n!==null&&n!==`all`,narrowing:a.trim()!==``||s.length>0||e===`issues`&&(!p&&l.length>0||f!==``)}}function Ct(e){let[t,n]=(0,q.useState)(``),r=e?.projectsState===`refreshing`||e?.projectsState===`unavailable`,i=r||e?.projects?.some(e=>e.id===t)?t:``;return(0,q.useEffect)(()=>{e&&!r&&t&&!i&&n(``)},[e,t,i,r]),{setProjectFilter:n,activeProject:i}}function wt(e,t,{filter:n,activeFilter:i},a){let o=r(),c=e===`issues`&&(i===`no-task`||i===`has-task`),l=s(o,c,o==="default"),u=(0,q.useMemo)(()=>l.data?Fe(l.data,t?.repo,o):null,[l.data,t?.repo,o]),f=Te(e,n)?Se(n):null,p=d(`pr`,f??``,f!==null&&t?.available===!0),m=f!==null&&p.data?.available?p.data.items:null,h=(0,q.useMemo)(()=>t?.available?e===`issues`?t.issues:t.prs:[],[t,e]),g=(0,q.useMemo)(()=>m?Pe(m,h):null,[m,h]),_=Tt({view:e,gh:t,activeFilter:i,isAssignedFilter:a,taskFilter:c,taskNumbers:u,runsQuery:l,backedQuery:f,filterHits:m,filterSearch:p});return{backedQuery:f,filterSearch:p,fullList:h,filterRows:g,filterGate:_,openItems:(0,q.useMemo)(()=>_?[]:g??h,[_,g,h]),narrow:(0,q.useMemo)(()=>e===`issues`?i===`no-task`&&u?{excludeNumbers:u}:i===`has-task`&&u?{includeNumbers:u}:{}:i===`mine`&&t?.viewerLogin?{author:t.viewerLogin}:m?{includeNumbers:new Set(m.map(e=>e.number))}:{},[e,i,u,t?.viewerLogin,m])}}function Tt({view:e,gh:t,activeFilter:n,isAssignedFilter:r,taskFilter:i,taskNumbers:a,runsQuery:o,backedQuery:s,filterHits:c,filterSearch:l}){return t?.available?(r||e===`prs`&&n===`mine`)&&!t.viewerLogin?{kind:`blocked`,message:`GitHub login unavailable, so this filter cannot be applied.`}:i&&!a?o.isError?{kind:`blocked`,message:`The task list is unavailable, so this filter cannot be applied.`}:{kind:`loading`,message:`Loading tasks…`}:s!==null&&!c?l.data?.available===!1?{kind:`blocked`,message:`GitHub could not be searched: ${l.data.reason??`unknown reason`}.`}:l.isError?{kind:`blocked`,message:`GitHub could not be searched: ${l.error instanceof Error?l.error.message:`the search request failed`}.`}:{kind:`loading`,message:`Searching GitHub…`}:null:null}function Et(e,t){return t?C(t.kind,t.number,{refresh:!0}).then(n=>(e.setQueryData(t.key,n),!0)).catch(()=>!1):Promise.resolve(!0)}function Dt(e,t,n,{filterGate:r,filterRows:i,fullList:a}){let s=o.github()[0],c=t===void 0?null:Number.parseInt(t,10),l=!r&&n.data?.available?n.data.items.find(e=>e.number===c):void 0,u=i&&c!==null&&!a.some(e=>e.number===c)?i.find(e=>e.number===c):void 0,d=l??u,[f,p]=(0,q.useState)(null);return(0,q.useEffect)(()=>{d&&p({scope:s,view:e,item:d})},[s,e,d]),{selectedNumber:c,remoteDetail:d??(f?.scope===s&&f.view===e&&f.item.number===c?f.item:null)}}function Ot(e,t,n,{fullList:r,filterRows:i},a){let s=x(),c=(0,q.useRef)(null),l=e===`issues`?`issue`:`pr`,u=t?.available===!0&&n!==null&&Number.isSafeInteger(n)&&n>0&&!r.some(e=>e.number===n)&&!i?.some(e=>e.number===n)&&a===null,d=f(l,n??0,u),p=u&&d.data?.available&&d.data.item?.kind===l?d.data.item:null;c.current=u&&n!==null?{kind:l,number:n,key:o.githubItem(l,n)}:null;let[m,h]=(0,q.useState)(!1);return{exactWanted:u,exactItem:d,exactDetail:p,exactTargetRef:c,retryingExact:m,retryExact:()=>{h(!0),Et(s,c.current).then(e=>{h(!1),e||S(`Could not reach GitHub for #${n}`,{tone:`danger`})})}}}function kt(e,t,n){let r=x(),i=(0,q.useRef)(null);return{refresh:c({mutationFn:e=>(Et(r,e),b({refresh:!0,limit:50})),onSuccess:async a=>{await r.cancelQueries({queryKey:o.githubPages(50),exact:!0}),r.setQueryData(o.githubPages(50),{pages:[a],pageParams:[{}]}),r.invalidateQueries({queryKey:o.githubChecks(t)});let s=e===`issues`?`issue`:`pr`,c=(e===`issues`?a.issues:a.prs).map(e=>e.number),l=o.githubCommentCounts(s,c);r.removeQueries({queryKey:o.githubCommentCounts(s,[]).slice(0,4),predicate:e=>e.queryHash!==y(l)}),a.available&&a.commentsDeferred&&c.length>0&&g(s,c,{refresh:!0}).then(e=>r.setQueryData(l,e)).catch(()=>{}),r.invalidateQueries({queryKey:o.githubSearch(e===`issues`?`issue`:`pr`,n)}),r.invalidateQueries({queryKey:o.githubSearch(`pr`,Ne)}),r.invalidateQueries({queryKey:o.githubSearch(`pr`,Oe)});let u=i.current,d=o.githubComments(`issue`,0).slice(0,3);if(!u){r.removeQueries({queryKey:d});return}let f=o.githubComments(u.kind,u.number);v(u.kind,u.number,{refresh:!0}).then(e=>r.setQueryData(f,e)).catch(()=>{}),r.removeQueries({queryKey:d,predicate:e=>e.queryHash!==y(f)})},onError:e=>S(e.message,{tone:`danger`})}),openThreadRef:i}}var At=350;function jt(e,t){let[n,r]=(0,q.useState)(e);return(0,q.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function Mt(e,t,{query:n,labelFilter:r,effectiveAssignees:i,activeProject:a},{openItems:o,narrow:s,filterGate:c}){let l=jt(n,At),u=(0,q.useMemo)(()=>K(o,{query:l,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),[o,l,r,e,i,a,s]),f=n.trim()===l.trim(),p=t?.available===!0&&!c&&f&&Re(l,u),m=d(e===`issues`?`issue`:`pr`,l,p),h=K(o,{query:n,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),g=p&&m.data?.available?m.data:null,_=new Set(h.map(e=>e.number)),v=Nt(e,g,a,i);return{debouncedQuery:l,searchWanted:p,forgeSearch:m,items:h,searchPayload:g,metadataFailure:v,searchHits:g&&!v?K(g.items,{labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}).filter(e=>!_.has(e.number)):[],...Pt(n,f,p,m)}}function Nt(e,t,n,r){return e===`issues`&&t?n&&t.items.some(e=>e.projectIds===void 0)?t.projectsReason??`Project board data is incomplete. Refresh to try again.`:r.length&&t.items.some(e=>e.assignees===void 0)?`Assignee data is incomplete. Refresh to try again.`:null:null}function Pt(e,t,n,r){return{searching:e.trim()!==``&&!t||n&&r.isPending,searchFailed:n&&(r.data?.available===!1||r.isError),searchFailureReason:r.data?.available===!1?r.data.reason??`unknown reason`:r.error instanceof Error?r.error.message:`the search request failed`}}function Ft({width:e,onWidthChange:t}){let n=(0,q.useRef)(null),r=t=>{t.button===0&&(n.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault(),t.currentTarget.focus())},i=e=>{let r=n.current;r&&t(J(r.width+(e.clientX-r.x)))},a=e=>{n.current&&(n.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,Y.jsx)(`div`,{"data-slot":`gh-list-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the GitHub list`,"aria-valuenow":e,"aria-valuemin":280,"aria-valuemax":520,tabIndex:0,onPointerDown:r,onPointerMove:i,onPointerUp:a,onPointerCancel:a,onKeyDown:n=>{let r=n.key===`ArrowLeft`?e-16:n.key===`ArrowRight`?e+16:n.key===`Home`?280:n.key===`End`?520:null;r!==null&&(n.preventDefault(),t(J(r)))},onDoubleClick:()=>t(360),title:`Drag to resize the GitHub list — double-click to reset`,className:`absolute inset-y-0 -right-[2px] z-20 hidden w-[5px] cursor-col-resize touch-none bg-transparent transition-colors hover:bg-accent-strong/40 focus-visible:bg-accent-strong/60 focus-visible:outline-none md:block`})}function It({view:e,changes:t=!1,index:n=!1}){let{n:r}=ee(),i=xt(e),{rawFilterParam:a,activeFilter:o}=i,s=Ce(),{pages:c,data:l}=m(50),d=ye(),f=Rt(),p=Ge(),h=Lt({index:n,isDesktop:s,rawFilterParam:a,n:r,rememberedView:u().data?.githubView}),g=zt(l?.available===!0&&!h.filterScreen),[_,v]=(0,q.useState)(!1),y=St(e,l,i),b=wt(e,l,i,y.isAssignedFilter),x=Mt(e,l,y,b),S=Dt(e,r,x.forgeSearch,b),C=Ot(e,l,S.selectedNumber,b,S.remoteDetail),w=bt(e,c,l,S.selectedNumber,x.searchHits,b.openItems),{refresh:T,openThreadRef:E}=kt(e,w.checkPrNumbers,x.debouncedQuery),D=gt(e,c,l,b.backedQuery,y.narrowing);if(h.restorePrs)return(0,Y.jsx)(se,{to:`/github/prs`,replace:!0});if(!l)return c.isError?(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(j,{size:16}),tone:`danger`,title:`Could not load GitHub`,subtitle:c.error.message})}):(0,Y.jsx)(ke,{});E.current=null;let O=()=>T.mutate(C.exactTargetRef.current);if(h.filterScreen&&l.available)return(0,Y.jsx)(st,{onRefresh:O,refreshing:T.isPending});if(!l.available)return(0,Y.jsx)(Wt,{reason:l.reason,refreshing:T.isPending,onRetry:O});let{labelColors:k,labelOptions:A}=Bt(l,x.searchPayload,b.openItems,b.fullList),M=Vt({number:S.selectedNumber,items:x.items,searchHits:x.searchHits,fullList:b.fullList,filterRows:b.filterRows,remoteDetail:S.remoteDetail,exactDetail:C.exactDetail});E.current=M?{kind:M.kind,number:M.number}:null;let{linkFilter:te,listPath:ne}=Ht(e,a,o,s),N={view:e,filter:te,colors:k,selected:M,queued:p.queued,checksMap:w.checksMap,commentsOf:w.commentsOf},P=Ut(e,y,b.filterGate,x),F=ge(x.items.length+x.searchHits.length);return(0,Y.jsx)(U,{rootRef:g.routeRef,route:`github`,density:F,headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,bodyClassName:`gap-2.5`,header:ct({view:e,activeFilter:o,isDesktop:s,rawFilterParam:a,n:r,gh:l,actions:{automationsAvailable:d,refreshing:T.isPending,onRefresh:O}}),children:(0,Y.jsxs)(`div`,{ref:g.workspaceRef,"data-slot":`gh-workspace`,"data-stacked":g.panesStacked,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 md:h-[calc(var(--gh-workspace-height,calc(100dvh-4rem))-1rem)] md:flex-none md:gap-5`,children:[(0,Y.jsxs)(`header`,{"data-slot":`gh-header`,className:`flex shrink-0 flex-col gap-3 bg-background md:gap-4`,children:[(0,Y.jsx)(Gt,{view:e,isDesktop:s,gh:l,onSaveView:f}),(0,Y.jsx)(Kt,{view:e,gh:l,filters:y,labelOptions:A,labelColors:k,searchPayload:x.searchPayload})]}),(0,Y.jsxs)(`div`,{"data-slot":`gh-panes`,className:`flex min-h-0 min-w-0 flex-1 flex-col items-start gap-[22px] md:flex-row md:items-stretch md:overflow-hidden`,children:[(0,Y.jsx)(Yt,{view:e,n:r,rows:N,verdict:P,search:x,sidebar:b,list:c,paging:D,width:g.githubListWidth,onWidthChange:g.changeGithubListWidth,expanded:_,onExpandedChange:v}),(0,Y.jsx)(tn,{view:e,n:r,selected:M,selectedNumber:S.selectedNumber,exact:C,repo:l.repo,rows:N,listPath:ne,changes:t,handToAgent:p})]})]})})}function Lt({index:e,isDesktop:t,rawFilterParam:n,n:r,rememberedView:i}){return{filterScreen:e&&!t&&n===null&&r===void 0,restorePrs:e&&t&&n===null&&i===`prs`}}function Rt(){let e=x();return t=>{e.setQueryData(o.uiState,e=>({...e,githubView:t})),_({githubView:t}).then(t=>e.setQueryData(o.uiState,t)).catch(t=>{S(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:o.uiState})})}}function zt(e){let[t,n]=(0,q.useState)(Je),[r,i]=(0,q.useState)(!0),a=(0,q.useRef)(null),o=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!e)return;let n=a.current,r=o.current,s=n?.closest(`[data-slot="main"]`);if(!n||!r||!s)return;let c=window.matchMedia(`(min-width: 768px)`),l=!1,u=()=>{if(l=c.matches&&r.clientWidth>=t+22+360,i(!l),!l||s.clientHeight<1){n.style.removeProperty(`--gh-workspace-height`);return}n.style.setProperty(`--gh-workspace-height`,`${Math.round(s.clientHeight)}px`)};u();let d=new ResizeObserver(u);d.observe(s),d.observe(r);let f=e=>{if(!l||e.ctrlKey||!e.deltaY||Math.abs(e.deltaX)>Math.abs(e.deltaY)||r.getBoundingClientRect().top<=s.getBoundingClientRect().top+1||!(e.target instanceof Element)||!e.target.closest(`[data-slot="gh-panes"]`))return;e.preventDefault();let t=e.deltaMode===1?16:e.deltaMode===2?s.clientHeight:1;s.scrollTop+=e.deltaY*t};return r.addEventListener(`wheel`,f,{passive:!1}),c.addEventListener(`change`,u),()=>{r.removeEventListener(`wheel`,f),d.disconnect(),c.removeEventListener(`change`,u)}},[e,t]),{githubListWidth:t,changeGithubListWidth:e=>{let t=J(e);n(t),Ye(t)},panesStacked:r,routeRef:a,workspaceRef:o}}function Bt(e,t,n,r){return{labelColors:{...t?.labelColors,...e.labelColors},labelOptions:Be([...n,...r,...t?.items??[]])}}function Vt({number:e,items:t,searchHits:n,fullList:r,filterRows:i,remoteDetail:a,exactDetail:o}){return e===null?t[0]??n[0]??null:r.find(t=>t.number===e)??i?.find(t=>t.number===e)??a??o??null}function Ht(e,t,n,r){let i=t===null?null:n;return{linkFilter:i,listPath:G(e,i??(e===`issues`&&!r?`all`:null))}}function Ut(e,{query:t,filtering:n},r,{searching:i,searchFailed:a,searchFailureReason:o,metadataFailure:s,searchHits:c,searchPayload:l,items:u}){let d=e===`issues`?`issues`:`pull requests`;return r?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5`,"data-slot":`gh-filter-gate`,"data-kind":r.kind,children:[r.kind===`loading`?(0,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):null,r.message]}):n?i?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Searching GitHub for “`,t.trim(),`”…`]}):a?c.length>0?(0,Y.jsxs)(`p`,{role:`status`,children:[`Showing previous results. GitHub could not be refreshed: `,o,`. Use Refresh to try again.`]}):u.length>0?(0,Y.jsxs)(`p`,{children:[`GitHub could not be searched: `,o,`.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,` match your filter, and GitHub could not be searched: `,o,`.`]}):s?(0,Y.jsxs)(`p`,{role:`status`,children:[`Cannot apply the selected filters to GitHub results: `,s]}):c.length>0?null:l?.truncated?(0,Y.jsx)(`p`,{children:`No matches within GitHub’s first matches. Narrow your search to check more specific results.`}):l&&u.length>0?(0,Y.jsxs)(`p`,{children:[`No additional `,d,` match your filter on GitHub.`]}):l?(0,Y.jsxs)(`p`,{children:[`No `,d,` match your filter — open, closed or merged.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,` match your filter.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,`.`]})}function Wt({reason:e,refreshing:t,onRetry:n}){return(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(T,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:e??`unknown reason`,actions:(0,Y.jsx)(I,{variant:`outline`,"data-action":`gh-retry`,disabled:t,onClick:n,children:`Try again`}),children:(0,Y.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`The tab needs the `,(0,Y.jsx)(`span`,{className:`font-mono`,children:`gh`}),` CLI, logged in (`,(0,Y.jsx)(`span`,{className:`font-mono`,children:`gh auth login`}),`), and a repo with a GitHub remote. Everything else in Squawk works without it.`]})})})}function Gt({view:e,isDesktop:t,gh:n,onSaveView:r}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`flex min-h-11 flex-wrap items-center gap-3`,children:[(0,Y.jsxs)(Ke,{to:t?`/github`:`/github?filter=all`,active:e===`issues`,onClick:()=>r(`issues`),children:[`Issues · `,n.issuesTotal??n.issues.length]}),(0,Y.jsxs)(Ke,{to:`/github/prs`,active:e===`prs`,onClick:()=>r(`prs`),children:[`Pull requests · `,n.prsTotal??n.prs.length]})]})}function Kt({view:e,gh:t,filters:n,labelOptions:r,labelColors:i,searchPayload:a}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-filter-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 basis-full md:flex-1 md:basis-auto`,children:[(0,Y.jsx)(E,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Y.jsx)(`input`,{type:`search`,"data-slot":`gh-search`,"aria-label":`Search ${e}`,placeholder:e===`issues`?`Filter issues…`:`Filter pull requests…`,value:n.query,onChange:e=>n.setQuery(e.target.value),className:`min-h-11 w-full rounded-lg border border-border bg-card py-1 pr-2.5 pl-8 text-[13px] text-foreground outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Y.jsx)(an,{options:r,colors:i,selected:n.labelFilter,onChange:n.setLabelFilter}),e===`issues`?(0,Y.jsx)(ot,{data:{...t,issues:[...t.issues,...a?.items??[]]},assignees:n.effectiveAssignees,projectId:n.activeProject,onAssigneesChange:n.changeAssignees,onProjectChange:n.setProjectFilter}):null,(0,Y.jsx)(`button`,{type:`button`,disabled:!n.filtering,"data-slot":`gh-clear-filters`,className:`min-h-11 min-w-11 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:border-border disabled:bg-transparent disabled:text-muted-foreground`,onClick:n.clearFilters,children:`Clear filters`})]})}function qt(e,t){return e.kind===`pr`?t?.[e.number]??e.checks:e.checks}function Jt(e,t){return(0,Y.jsx)(dt,{item:e,view:t.view,filter:t.filter,colors:t.colors,active:t.selected?.url===e.url,queued:t.queued.has(e.url),checks:qt(e,t.checksMap),comments:t.commentsOf(e)})}function Yt({view:e,n:t,rows:n,verdict:r,search:i,sidebar:a,list:o,paging:s,width:c,onWidthChange:l,expanded:u,onExpandedChange:d}){let{items:f,searchHits:p}=i,m=e===`issues`&&t!==void 0&&!u;return(0,Y.jsxs)(`section`,{ref:s.setListEl,"data-slot":`gh-list`,"data-mobile-preview":m||void 0,style:{"--github-list-width":`${c}px`},className:`relative flex w-full min-h-0 min-w-0 flex-col rounded-lg border border-border bg-card p-3 md:w-[var(--github-list-width)] md:shrink-0 md:overflow-x-hidden md:overflow-y-auto`,children:[f.length===0?r&&(0,Y.jsx)(`div`,{"data-slot":`gh-empty`,className:`px-4 py-4 text-sm text-muted-foreground`,children:r}):(0,Y.jsx)(Xt,{items:f,rows:n,compactPreview:m,paging:s}),s.pagingAvailable?(0,Y.jsx)(Zt,{view:e,list:o,paging:s}):null,(0,Y.jsx)(Qt,{backedQuery:a.backedQuery,filterSearch:a.filterSearch}),(0,Y.jsx)($t,{view:e,n:t,count:f.length,expanded:u,onExpandedChange:d}),f.length>0&&i.searchWanted&&r?(0,Y.jsx)(`div`,{"data-slot":`gh-search-status`,role:`status`,className:`px-4 py-4 text-sm text-muted-foreground`,children:r}):null,p.length>0?(0,Y.jsx)(en,{hits:p,searchPayload:i.searchPayload,rows:n}):null,(0,Y.jsx)(Ft,{width:c,onWidthChange:l})]})}function Xt({items:e,rows:t,compactPreview:n,paging:r}){let{setRowsEl:i,scrollOwner:a,listEl:o,scrollOwnerRef:s,startMargin:c}=r,l=e.map((e,r)=>(0,Y.jsx)(`div`,{role:`listitem`,"data-slot":`gh-row-item`,"data-divided":r>0||void 0,"data-compact-hidden":n&&r>=2&&t.selected?.url!==e.url||void 0,children:Jt(e,t)},e.url));return(0,Y.jsx)(`div`,{ref:i,"data-slot":`gh-rows`,"data-virtualized":a?`true`:void 0,role:`list`,children:a?(0,Y.jsx)(Me,{scrollRef:s,startMargin:c,children:l},a===o?`list`:`main`):l})}function Zt({view:e,list:t,paging:n}){return(0,Y.jsx)(`div`,{ref:n.loadMoreRef,"data-slot":`gh-load-more`,className:`flex min-h-6 items-center justify-center gap-1.5 px-4 pb-3 text-xs text-muted-foreground`,children:t.isFetchingNextPage?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Loading more…`]}):t.isFetchNextPageError?(0,Y.jsxs)(Y.Fragment,{children:[`Could not load more.`,(0,Y.jsx)(`button`,{type:`button`,"data-slot":`gh-load-more-retry`,onClick:()=>void t.fetchNextPage(),className:`font-medium text-accent-text hover:underline`,children:`Retry`})]}):n.manualPaging?(0,Y.jsxs)(Y.Fragment,{children:[`Filters cover the loaded `,e===`issues`?`issues`:`pull requests`,`.`,(0,Y.jsx)(`button`,{type:`button`,"data-slot":`gh-load-more-manual`,onClick:()=>void t.fetchNextPage(),className:`font-medium text-accent-text hover:underline`,children:`Load more`})]}):null})}function Qt({backedQuery:e,filterSearch:t}){return e!==null&&t.data?.available&&t.data.truncated?(0,Y.jsxs)(`div`,{"data-slot":`gh-filter-note`,role:`status`,className:`px-4 py-3 text-xs text-muted-foreground`,children:[`Showing the first `,t.data.items.length,` matches from GitHub search; more may exist.`]}):null}function $t({view:e,n:t,count:n,expanded:r,onExpandedChange:i}){return e===`issues`&&t!==void 0&&n>2?(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 self-start md:hidden`,"data-slot":`gh-expand-list`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Show fewer issues`:`View all ${n} issues`}):null}function en({hits:e,searchPayload:t,rows:n}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-search-hits`,children:[(0,Y.jsxs)(`p`,{className:`px-4 pt-2 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:[`Found on GitHub`,t?.truncated?` (first matches)`:``]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5 px-2 pb-2`,children:e.map(e=>(0,Y.jsx)(`li`,{children:Jt(e,n)},e.url))})]})}function tn({view:e,n:t,selected:n,selectedNumber:r,exact:a,repo:o,rows:s,listPath:c,changes:l,handToAgent:u}){let{exactWanted:d,exactItem:f}=a;return(0,Y.jsx)(`section`,{"data-slot":`gh-detail`,className:i(`w-full min-w-0 min-h-0 flex-1 flex-col rounded-lg border border-border bg-card md:overflow-y-auto`,t===void 0?`hidden md:flex`:`flex`),children:n?(0,Y.jsx)(nn,{item:n,n:t,repo:o,rows:s,listPath:c,changes:l,handToAgent:u}):d&&f.isPending?(0,Y.jsx)(`div`,{"data-slot":`gh-detail-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(P,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading #${r}…`,subtitle:`It is not among the open items, so the tab is asking GitHub for it.`})}):d&&(f.isError||f.data?.available===!1)?(0,Y.jsx)(rn,{number:r,exact:a}):(0,Y.jsx)(ut,{view:e,number:r})})}function nn({item:e,n:t,repo:n,rows:r,listPath:i,changes:a,handToAgent:o}){let{workflows:s,skillList:c,workflow:l,setWorkflow:u,selectedSkills:d,setSelectedSkills:f,engine:p,setEngine:m,queued:h,onQueued:g}=o;return(0,Y.jsx)(He,{item:e,comments:r.commentsOf(e),afterHeading:e.kind===`issue`?(0,Y.jsx)(Xe,{number:e.number,repo:n},t??`list`):void 0,backLink:{to:i},subNav:{filter:r.filter,changes:a},onRunAgent:$,headerAction:(0,Y.jsx)(_t,{item:e,queuedRunId:h.get(e.url)??null}),colors:r.colors,checks:qt(e,r.checksMap),children:(0,Y.jsx)(Ve,{item:e,workflows:s.data?.workflows??[],skills:c,workflow:l,onWorkflowChange:u,selectedSkills:d,onSkillsChange:f,engine:p,onEngineChange:m,queuedRunId:h.get(e.url)??null,onQueued:g},e.url)})}function rn({number:e,exact:t}){let{exactItem:n,retryingExact:r,retryExact:i}=t;return(0,Y.jsx)(W,{icon:(0,Y.jsx)(j,{size:16}),tone:n.isError?`danger`:`neutral`,heading:`h2`,title:`Could not load #${e}`,subtitle:n.data?.available===!1?n.data.reason:n.error instanceof Error?n.error.message:`The request failed.`,actions:(0,Y.jsx)(I,{variant:`outline`,disabled:r,onClick:i,children:`Retry`})})}function an({options:e,colors:t,selected:n,onChange:r}){let[a,o]=(0,q.useState)(!1),s=e=>r(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,Y.jsxs)(B,{open:a,onOpenChange:o,children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-label-filter`,disabled:e.length===0,className:i(`inline-flex min-h-11 min-w-11 shrink-0 items-center gap-1.5 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:opacity-60`,n.length>0&&`border-accent-strong/60 text-foreground`),children:[n.length>0?`Labels · ${n.length}`:`Labels`,(0,Y.jsx)(A,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,Y.jsx)(z,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,Y.jsxs)(he,{children:[(0,Y.jsx)(de,{placeholder:`Filter labels…`}),(0,Y.jsxs)(me,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Y.jsx)(pe,{children:`No labels.`}),n.length>0?(0,Y.jsxs)(fe,{value:`__clear__`,onSelect:()=>r([]),className:`min-h-11 text-soft-foreground`,children:[`Clear `,n.length,` filter`,n.length>1?`s`:``]}):null,e.map(e=>{let r=n.includes(e);return(0,Y.jsxs)(fe,{value:e,onSelect:()=>s(e),className:`min-h-11`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-2.5 shrink-0 rounded-full border`,style:Le(t[e])}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Y.jsx)(O,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e)})]})]})})]})}export{It as GithubRoute};