@hearsay-tools/squawk 0.19.0-dev.8968 → 0.19.0-dev.8977
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/index.js +24 -8
- package/dist/contract/query-requests.d.ts +5 -0
- package/dist/contract/repo.d.ts +23 -0
- package/dist/server/git-changes.d.ts +27 -0
- package/dist/server/git-changes.js +47 -0
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/repo-routes.d.ts +111 -13
- package/dist/server/repo-routes.js +20 -3
- package/dist/server/repo-routes.js.map +1 -1
- package/dist/server/runs-routes.d.ts +86 -28
- package/dist/server/runs-routes.js +12 -10
- package/dist/server/runs-routes.js.map +1 -1
- package/dist/server/server.d.ts +1823 -1511
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-ubzHoDCj.js → accounts-section-Bh6Ne88P.js} +1 -1
- package/web/dist/assets/activity-motion-B4hhwfpy.js +1 -0
- package/web/dist/assets/{activity-route-BJ_KGtKZ.js → activity-route-XNJHWQrd.js} +1 -1
- package/web/dist/assets/{agent-config-section-hmVjtjoY.js → agent-config-section-oavZQZ6z.js} +2 -2
- package/web/dist/assets/{agent-defaults-section-BQKpdzj_.js → agent-defaults-section-Dlbff8d1.js} +1 -1
- package/web/dist/assets/{appearance-BaczNXEP.js → appearance-kpegMyn3.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-CXbUm4s9.js → archive-on-merge-field-Hw5MDxKb.js} +1 -1
- package/web/dist/assets/attention-BHNhUrnd.js +1 -0
- package/web/dist/assets/automations-route-DUZ4KZ71.js +2 -0
- package/web/dist/assets/{middle-truncated-name-TQxp8NxE.js → code-workbench-CUkiQ1pF.js} +1 -1
- package/web/dist/assets/commit-list-CHGDpN9k.js +1 -0
- package/web/dist/assets/{diff-_j1dYOKk.js → diff-DsPWectf.js} +2 -2
- package/web/dist/assets/{diff-controls-LdJu9jvm.js → diff-controls-BfNiZ7m7.js} +1 -1
- package/web/dist/assets/{diff-view-hA-_3ujN.js → diff-view-Ds6tF4Li.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-DT4Tnp2l.js → discard-changes-dialog-SEDH0D2b.js} +1 -1
- package/web/dist/assets/{file-preview-ClCnVg6z.js → file-preview-Dd4Bn_jS.js} +1 -1
- package/web/dist/assets/file-text-nGpo7MVd.js +1 -0
- package/web/dist/assets/{folder-browser-DiQGbqCN.js → folder-browser-BgGSB2gk.js} +1 -1
- package/web/dist/assets/{git-toolbar-BavnCfoa.js → git-toolbar-CyDX0ZlL.js} +1 -1
- package/web/dist/assets/github-CSHuD5n6.js +1 -0
- package/web/dist/assets/{global-activity-route-DZNrWVSz.js → global-activity-route-BeiBJ_S6.js} +2 -2
- package/web/dist/assets/index-BXyNYltk.css +1 -0
- package/web/dist/assets/{index-CS4IQx7a.js → index-D7e7hQRs.js} +7 -7
- package/web/dist/assets/{label-B1zf-eXb.js → label-CxJpzeLL.js} +1 -1
- package/web/dist/assets/{markdown-BJynZeyO.js → markdown-xkaHkz73.js} +1 -1
- package/web/dist/assets/middle-truncated-name-D41ibfXD.js +1 -0
- package/web/dist/assets/{open-in-menu-DfTnT8YF.js → open-in-menu-CmsJeSrD.js} +1 -1
- package/web/dist/assets/{option-select-CeMvhKGB.js → option-select-yBRQj6E_.js} +1 -1
- package/web/dist/assets/{preferences-section-1TdwWBaU.js → preferences-section-37pdeCWJ.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-B_IyuLH_.js → preview-pane-connected-By08oMDu.js} +2 -2
- package/web/dist/assets/{project-location-zpoFmFbY.js → project-location-FjgEfTb0.js} +1 -1
- package/web/dist/assets/{project-router-onKnSy5a.js → project-router-BNcdL2CI.js} +1 -1
- package/web/dist/assets/{projects-section-DCSrvgdU.js → projects-section-C2APAdf3.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-CPda4gof.js → prompt-templates-section-HpQeEo4v.js} +2 -2
- package/web/dist/assets/queries-BSxNcgZm.js +1 -0
- package/web/dist/assets/{reference-chip-Cv3i1kxz.js → reference-chip-DFwi97Ps.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-D_GLdblC.js → remote-settings-notice-CaFJB726.js} +1 -1
- package/web/dist/assets/repo-git-CpW0usPY.js +1 -0
- package/web/dist/assets/{report-reader-BAHgsI-N.js → report-reader-CmEcwfsT.js} +1 -1
- package/web/dist/assets/{report-selection-CmEfaDz7.js → report-selection-CaEdb2HO.js} +1 -1
- package/web/dist/assets/{reports-ZhVWe08S.js → reports-G5DwAoma.js} +1 -1
- package/web/dist/assets/{resources-section-CCKl5lWd.js → resources-section-BIjd5azP.js} +1 -1
- package/web/dist/assets/{review-panel-DNd2lB0z.js → review-panel-CgKnI_Kf.js} +4 -4
- package/web/dist/assets/{run-detail-refresh-Caj4BPPd.js → run-detail-refresh-GbAx5_Mn.js} +1 -1
- package/web/dist/assets/{run-header-2Ol_oWfx.js → run-header-DRYGraQL.js} +2 -2
- package/web/dist/assets/{select-1oriQjL8.js → select-akdt2vf9.js} +1 -1
- package/web/dist/assets/{session-context-section-BqGDbveU.js → session-context-section-Ckddzf6W.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-Ci3lUfW1.js → settings-agent-picker-Bt31ulJ9.js} +1 -1
- package/web/dist/assets/{settings-save-bar-DXwUaK3L.js → settings-save-bar-BCxZrjjt.js} +1 -1
- package/web/dist/assets/{settings-shell-aWDWs253.js → settings-shell-C84UojR3.js} +1 -1
- package/web/dist/assets/{sidebar-section-D5aLInDQ.js → sidebar-section-Dr9ev5Vo.js} +1 -1
- package/web/dist/assets/{skills-mbZtZ3vc.js → skills-Dh6dbL6k.js} +1 -1
- package/web/dist/assets/{tab-link-B2k-zaeP.js → tab-link-BrzzZnhE.js} +1 -1
- package/web/dist/assets/task-changes-pVv5Oafz.js +1 -0
- package/web/dist/assets/task-commits-Bex46n4l.js +1 -0
- package/web/dist/assets/{task-file-scope-B2EH5Os6.js → task-file-scope-DI5YpFAh.js} +1 -1
- package/web/dist/assets/task-files-C1nhWf4J.js +1 -0
- package/web/dist/assets/{task-github-item-CjALWL4A.js → task-github-item-CBOKx42k.js} +1 -1
- package/web/dist/assets/{task-groups-dEzH1nMg.js → task-groups-CsjJ9R5Y.js} +1 -1
- package/web/dist/assets/task-thread-DP78hgdh.js +2 -0
- package/web/dist/assets/{tasks-table-CPAY1N-E.js → tasks-table--jkwCj2N.js} +1 -1
- package/web/dist/assets/{thread-state-uWiG7IgM.js → thread-state-CHQ0rJr9.js} +1 -1
- package/web/dist/assets/{toaster-Bs1mVYf9.js → toaster-BJG79kO8.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-C5m1ufIR.js +1 -0
- package/web/dist/assets/use-path-bases-D5kpDgkA.js +1 -0
- package/web/dist/assets/use-workspace-config-save-DF7JuKqF.js +1 -0
- package/web/dist/assets/{workflows-CDATZgDf.js → workflows-C3Q0b6rr.js} +2 -2
- package/web/dist/assets/{workspace-tools-BICzaBFy.js → workspace-tools-Bhqgjmre.js} +1 -1
- package/web/dist/assets/{worktrees-section-CD-TSxcn.js → worktrees-section-BDEXzzG0.js} +5 -5
- package/web/dist/index.html +15 -15
- package/web/dist/assets/activity-motion-C3MbfqoU.js +0 -1
- package/web/dist/assets/attention-C9zoC-gL.js +0 -1
- package/web/dist/assets/automations-route-DUxB4z34.js +0 -2
- package/web/dist/assets/commit-list-BnAxcran.js +0 -1
- package/web/dist/assets/github-CK5AGoz0.js +0 -1
- package/web/dist/assets/index-DB8vFvSO.css +0 -1
- package/web/dist/assets/queries-CII6fTHH.js +0 -1
- package/web/dist/assets/repo-git-6j7BfJ2_.js +0 -1
- package/web/dist/assets/task-changes-BD1GZRIs.js +0 -1
- package/web/dist/assets/task-commits-Dz047BbX.js +0 -1
- package/web/dist/assets/task-files-C9YQDRk6.js +0 -1
- package/web/dist/assets/task-thread-B-cAE0Li.js +0 -2
- package/web/dist/assets/use-hand-to-agent-state-D8ltY5hM.js +0 -1
- package/web/dist/assets/use-path-bases-BK81NQ26.js +0 -1
- package/web/dist/assets/use-workspace-config-save-0Mtdwfrd.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-CII6fTHH.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 te,s as ne,sr as re,ti as ie,v as ae,z as oe}from"./toaster-Bs1mVYf9.js";import{B as S,G as se,H as ce,I as C,K as le,N as w,P as T,V as ue,W as E,j as D,z as O}from"./live-protocol-DMhTnCmf.js";import{h as de,n as fe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as pe,t as k}from"./label-B1zf-eXb.js";import{L as me,X as he,Z as ge,b as _e,ft as ve,ht as ye,nt as be,ot as xe,u as Se}from"./design-icons-QbNMZniQ.js";import{t as Ce}from"./check-OP-CVgZG.js";import{t as A}from"./button-C8jUIs8Q.js";import{n as we,r as Te,t as Ee}from"./collapsible-Bx2vViFx.js";import{a as j,i as M,n as N,r as P,t as F}from"./select-1oriQjL8.js";import{t as De}from"./switch-CAKeV99j.js";import{c as Oe,s as ke,t as I}from"./project-router-onKnSy5a.js";import{c as L,d as R,f as Ae,l as je,n as Me,o as Ne}from"./page-shell-Dky5crRl.js";import{r as Pe}from"./agents-settings-path-7X6_cvUg.js";import{t as Fe}from"./centered-state-BgSV4e79.js";import{Cn as Ie,D as Le,Dn as Re,Hn as ze,K as Be,O as Ve,P as He,Un as Ue,Y as We,gr as Ge,k as Ke,q as qe,r as Je,rr as z,t as Ye,yn as Xe}from"./index-CS4IQx7a.js";import{t as Ze}from"./textarea-vEsJAUAV.js";import{_ as Qe,a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as B,u as pt,v as mt}from"./automation-format-DB34jUyF.js";var V=e(t(),1),H=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ht=S({includeExisting:T().optional(),authors:w(E()).optional(),assignees:w(E()).optional(),requireCurrentLabels:T().optional(),allLabels:w(E()).optional(),anyLabels:w(E()).optional(),excludeLabels:w(E()).optional(),changedLabels:w(E()).optional(),lookbackDays:O(),maxRecords:O()}),gt=D([`github`,`schedule`]),_t=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:E(),variants:se([C(1),C(2),C(3)]).optional(),systemPrompt:E().optional()}),vt=S({at:E(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}),U=S({id:E(),revision:O(),name:E(),description:E().optional(),enabled:T(),kind:gt,events:w(H).optional(),intervalSeconds:O().optional(),filters:ht.optional(),schedule:et.optional(),task:_t,archived:vt.optional(),createdAt:E(),updatedAt:E()}),W=S({timestamp:E(),tieBreaker:E().optional()}),yt=S({since:E().datetime(),until:E().datetime(),source:O().int().min(0).max(2),page:O().int().min(1).max(10),item:O().int().min(0).max(100),event:O().int().min(0).max(1e3),cursor:W.optional()}),bt={lastError:E().max(1e3).optional(),lastErrorAt:E().datetime().optional()},xt=S({revision:O().optional(),baselineAt:E().optional(),armedAt:E().optional(),historyScan:yt.optional(),cursor:W.optional(),frozenHighWatermark:W.extend({tieBreaker:E()}).optional(),backlogAfter:W.extend({tieBreaker:E()}).optional(),nextCheckAt:E().optional(),lastSuccessAt:E().optional(),nextRunAt:E().optional(),lastRunAt:E().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().optional(),consecutiveFailures:O().optional(),...bt,onceOutcome:D([`failed`,`missed`]).optional()});function St(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 Ct=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),wt=S({seq:O(),ts:E(),automationId:E(),revision:O(),event:H.optional(),result:Ct,reason:E().optional(),durationMs:O().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().optional(),githubTitle:E().optional(),githubUrl:E().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().optional(),resetAt:E().optional()}).optional()}),Tt=S({matches:O(),launched:O(),duplicates:O(),errors:O()}),Et=U.extend({state:xt.optional(),latestLog:wt.optional(),counts:Tt,nextRunAt:E().optional(),onceStatus:ut.optional()});S({available:T(),reason:E().optional(),timeZone:E(),scheduler:S({state:D([`scheduled`,`idle`]),nextDue:E().optional()}),automations:w(Et)}),S({automation:U}).extend({once:S({dueAt:E(),timeZone:E(),resolvedInstant:E(),note:E()}).optional()}),S({automation:U,state:xt.optional(),latestLog:wt.optional(),onceStatus:ut.optional()}),S({id:E(),automationId:E(),mode:D([`preview`,`execute`]),status:D([`queued`,`running`,`complete`,`error`]),createdAt:E(),completedAt:E().optional(),matches:O().optional(),truncated:T().optional(),error:E().optional()}),S({checkId:E()}),S({records:w(wt)}),S({receiptId:E(),runId:E()}),S({runId:E()}),U.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:gt.optional(),task:_t.omit({variants:!0}).strict(),enable:T().optional()}).omit({enable:!0}).extend({enabled:T().optional(),expectedRevision:O()}),S({archived:D([`include`,`only`]).optional()}),S({mode:D([`preview`,`execute`])});var G=n();function K({text:e}){return(0,G.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Dt={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`pending`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},Ot={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 kt(e){let[t,n]=(0,V.useState)(),[r,i]=(0,V.useState)(``),a=(0,V.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,V.useEffect)(()=>{a()},[a]),(0,V.useEffect)(()=>p(a),[a]),(0,V.useEffect)(()=>pe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function At(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 jt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&At(e,t),[o,s]=(0,V.useState)(),[c,l]=(0,V.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await oe(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,G.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,G.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(Je,{dot:Dt[e.result],children:Ot[e.result]}),(0,G.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:ct(e.ts,n,u)})]}),e.reason?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,G.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,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,G.jsx)(A,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var q=`all`;function Mt({label:e,value:t,onChange:n,options:r}){return(0,G.jsxs)(F,{value:t,onValueChange:n,children:[(0,G.jsx)(M,{"aria-label":e,className:`w-full sm:w-52`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:r.map(e=>(0,G.jsx)(P,{value:e.value,children:e.label},e.value))})]})}function Nt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=kt(e),[s,c]=(0,V.useState)(q),[l,u]=(0,V.useState)(q),d=(0,V.useMemo)(()=>(i??[]).filter(e=>(s===q||e.result===s)&&(l===q||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,G.jsx)(je,{route:`automations`,density:i?Ae(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,G.jsx)(L,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:a}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,G.jsx)(K,{text:`Nothing has run yet.`}):(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Mt,{label:`Result`,value:s,onChange:c,options:[{value:q,label:`All results`},...Ct.options.map(e=>({value:e,label:Ot[e]}))]}),f?(0,G.jsx)(Mt,{label:`Event`,value:l,onChange:u,options:[{value:q,label:`All events`},...H.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,G.jsx)(K,{text:`No rows match these filters.`}):(0,G.jsx)(jt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,G.jsx)(K,{text:`Loading execution log…`})})}function Pt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=kt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,G.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,G.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,G.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,G.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,G.jsx)(jt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Ft({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?dt(i):null,[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(``),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null);(0,V.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,G.jsx)(je,{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,G.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,G.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${B(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,G.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,G.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,G.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,G.jsxs)(`section`,{className:`min-w-0`,children:[(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,G.jsx)(A,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})]}),u?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var It=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),J=w(E().trim().min(1).max(200)).max(100).optional(),Lt=S({includeExisting:T().optional(),requireCurrentLabels:T().optional(),authors:J,assignees:J,allLabels:J,anyLabels:J,excludeLabels:J,changedLabels:J,lookbackDays:O().int().min(1).max(90).default(7),maxRecords:O().int().min(1).max(100).default(25)}).passthrough(),Rt=S({prompt:E().min(1).max(1e5),workflow:E().trim().min(1).max(200).optional(),steps:w(y).min(1).max(100).optional(),runner:ie.optional(),model:E().trim().min(1).max(200).optional(),effort:E().trim().min(1).max(32).optional(),variants:se([C(1),C(2),C(3)]).optional(),worktree:T().optional(),autonomous:T().optional(),...g,...re,systemPrompt:E().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),zt=new Set(Object.keys(Rt.shape).filter(e=>e!==`variants`));function Bt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>zt.has(e)))}ue(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??{}}},S({id:E().min(1).max(100),revision:O().int().positive(),name:E().trim().min(1).max(200),description:E().max(2e3).optional(),enabled:T().default(!1),kind:gt.default(`github`),events:w(It).min(1).max(4).optional(),intervalSeconds:O().int().min(60).max(86400).optional(),filters:Lt.optional(),schedule:et.passthrough().optional(),task:Rt,archived:S({at:E().datetime(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:E().datetime(),updatedAt:E().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`})})),S({version:C(1).default(1),automations:w(le()).default([]),tombstones:ce(E(),E().datetime()).optional()}).passthrough();var Y=S({timestamp:E().datetime(),tieBreaker:E().optional()}).passthrough(),Vt=yt.extend({cursor:Y.optional()}),Ht=S({revision:O().int().positive().optional(),baselineAt:E().datetime().optional(),armedAt:E().datetime().optional(),historyScan:Vt.optional(),cursor:Y.optional(),frozenHighWatermark:Y.extend({tieBreaker:E()}).optional(),backlogAfter:Y.extend({tieBreaker:E()}).optional(),nextCheckAt:E().datetime().optional(),lastSuccessAt:E().datetime().optional(),nextRunAt:E().datetime().optional(),lastRunAt:E().datetime().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().datetime().optional(),consecutiveFailures:O().int().nonnegative().optional(),...bt,onceOutcome:D([`failed`,`missed`]).optional()}).passthrough();S({version:C(1).default(1),states:ce(E(),Ht).default({})}).passthrough(),S({receiptId:E().min(1),receiptKey:E().min(1),eventId:E().min(1),automationId:E().min(1),revision:O().int().positive(),status:D([`reserved`,`launched`,`launch-error`,`released`]),runId:E().optional(),observedAt:E().datetime(),updatedAt:E().datetime(),error:E().max(2e3).optional(),occurrenceAt:E().datetime().optional(),candidate:S({eventId:E(),event:It,timestamp:E().datetime(),tieBreaker:E(),repo:E(),nodeId:E(),number:O().int().positive(),title:E().max(500),url:E().url(),author:E().max(200),assignees:w(E().max(200)).max(100),labels:w(E().max(200)).max(100),changedLabel:E().max(200).optional()}).passthrough().optional()}).passthrough();var Ut=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);S({seq:O().int().positive(),ts:E().datetime(),automationId:E().min(1),revision:O().int().positive(),event:It.optional(),result:Ut,reason:E().max(2e3).optional(),durationMs:O().int().nonnegative().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().int().positive().optional(),githubTitle:E().max(500).optional(),githubUrl:E().url().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().int().nonnegative().optional(),resetAt:E().datetime().optional()}).passthrough().optional()}).passthrough();var Wt=`quick-task`;function Gt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Bt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:pt(e.schedule??{type:`daily`}),events:e.events??[H.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Wt}:{}:{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 Kt(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 qt(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 Jt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Kt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:qt(e)}}function Yt(e){return{...Jt(e),enable:e.enabled}}function Xt(e,t){return{...Jt(e),task:{...qt(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function X(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Zt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Qt=new Set([`anyLabels`,`authors`,`changedLabels`]);function $t(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=>!Zt.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||Qt.has(e)&&Array.isArray(t)&&t.length>0)}function en(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function tn(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function Z(e,t){return t.startsWith(`-`)?`--${e}=${X(t)}`:`--${e} ${X(t)}`}function nn(e){let t=[`${Xe()} automation add`,Z(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Z(`at`,e.schedule.at),Z(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Z(`latest-start`,tn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Z(`cron`,ot(e.schedule)));else{t.push(Z(`on`,e.events.join(`,`)),`--every ${en(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(Z(`label`,n));for(let n of e.filters?.authors??[])t.push(Z(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Z(`changed-label`,n))}return t.push(...rn(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Z(`prompt`,e.task.prompt)),t.join(` `)}function rn(e){let t=[];return e.workflow&&t.push(Z(`workflow`,e.workflow)),e.runner&&t.push(Z(`runner`,e.runner)),e.model&&t.push(Z(`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 an(e,t){let n=Yt(e),r=$t(n)?nn(n):`${Xe()} automation create --json ${X(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${X(t.origin)} CEZ_PROJECT_ID=${X(t.projectId)} HSQ_COCKPIT_URL=${X(t.origin)} HSQ_PROJECT_ID=${X(t.projectId)} ${r}`:r}function on(e){let t=[],n=!1;for(let r of sn(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 sn(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 cn({draft:e,saveLabel:t,editing:n}){let i=ke(),a=window.location.origin,o=(0,V.useMemo)(()=>{let t=an(e);return i?`HSQ_COCKPIT_URL=${X(a)} HSQ_PROJECT_ID=${X(i)} ${t}`:t},[e,a,i]),s=(0,V.useMemo)(()=>on(o),[o]),[c,l]=(0,V.useState)(`idle`),[u,d]=(0,V.useState)(!1),f=(0,V.useId)(),p=(0,V.useRef)(void 0);(0,V.useEffect)(()=>()=>clearTimeout(p.current),[]),(0,V.useEffect)(()=>l(`idle`),[o]);let m=async()=>{clearTimeout(p.current);try{await navigator.clipboard.writeText(s),l(`copied`),p.current=setTimeout(()=>l(`idle`),1600)}catch{l(`failed`)}};return(0,G.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 border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,G.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,G.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":u,"aria-controls":f,"aria-label":u?`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:()=>d(e=>!e),children:[(0,G.jsx)(`span`,{className:`truncate`,children:u?`Hide`:`Show`}),(0,G.jsx)(Se,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,u&&`rotate-180`)})]}),(0,G.jsxs)(A,{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 m(),children:[c===`copied`?(0,G.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`}):(0,G.jsx)(Ge,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,G.jsx)(`div`,{id:f,hidden:!u,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,G.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:s})}),(0,G.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:c===`failed`?`Could not copy — select the line and copy it by hand.`:(0,G.jsxs)(G.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,G.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Xe()} automation schema`}),` prints its shape.`]})})]})}function ln({pressed:e,onClick:t,disabled:n,children:i}){return(0,G.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 un={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},dn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function fn(e){let t=e.map(e=>un[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 pn=H.options,mn=[{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`}],hn=[{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.`}],gn=e=>(e??[]).join(`, `),_n=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function vn(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 yn(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`}. ${vn(e.filters.includeExisting)}`}function bn({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=_n(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=mn.some(t=>t.seconds===e.intervalSeconds)?mn:[...mn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,G.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,G.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:pn.map(t=>(0,G.jsx)(ln,{pressed:e.events.includes(t),onClick:()=>r(t),children:dn[t]},t))}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-interval`,children:`Check every`}),(0,G.jsxs)(F,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:o.map(e=>(0,G.jsx)(P,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,G.jsx)(De,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,G.jsx)(`span`,{children:`Include existing items`})]}),(0,G.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:vn(e.filters.includeExisting)})]}),(0,G.jsxs)(Ee,{children:[(0,G.jsxs)(Te,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,G.jsx)(Se,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,G.jsx)(we,{children:(0,G.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[hn.map(t=>(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,G.jsx)(z,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:gn(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,G.jsx)(z,{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 xn=e=>String(e).padStart(2,`0`);function Q({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,V.useState)(xn(t)),o=(0,V.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${xn(n)}.`,l=(0,V.useId)();return(0,V.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(z,{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(xn(t))}),s?(0,G.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Sn=[{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`}],Cn=`none`,wn=e=>String(e).padStart(2,`0`);function Tn(e,t=Date.now()){let n=mt(t,e)??mt(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${wn(r.getUTCMonth()+1)}-${wn(r.getUTCDate())}T09:00`}function En(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function Dn({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?st(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${wn(t)}:${wn(n)}`}),l=(0,V.useRef)(null),u=(0,V.useId)(),d=nt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,V.useEffect)(()=>{l.current?.setCustomValidity(f?$e:``)},[f]);let p=dt(e);return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-date`,children:`Date`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,G.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:$e}):null,(0,G.jsx)(kn,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,G.jsx)(An,{value:e.latestStartMinutes,onChange:t=>n(On(e,t))}),p?(0,G.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 On(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function kn({value:e,onCommit:t}){let[n,r]=(0,V.useState)(e),i=(0,V.useRef)(null),a=(0,V.useId)(),o=(0,V.useId)(),[s]=(0,V.useState)(En),c=n!==e||!Qe(n),l=rt(n);return(0,V.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,G.jsx)(z,{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),Qe(e.target.value)&&t(e.target.value)}}),(0,G.jsx)(`datalist`,{id:a,children:s.map(e=>(0,G.jsx)(`option`,{value:e},e))}),c?(0,G.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function An({value:e,onChange:t}){let n=Sn.some(t=>t.minutes===e)||e===void 0?Sn:[...Sn,{minutes:e,label:`${e} minutes`}];return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,G.jsxs)(F,{value:e===void 0?Cn:String(e),onValueChange:e=>t(e===Cn?void 0:Number(e)),children:[(0,G.jsx)(M,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:n.map(e=>(0,G.jsx)(P,{value:e.minutes===void 0?Cn:String(e.minutes),children:e.label},e.label))})]}),(0,G.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 jn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Mn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??Tn(r),timeZone:e.timeZone??r}:{type:t});return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.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:jn.map(t=>(0,G.jsx)(ln,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,G.jsx)(Dn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,G.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:ft.map((t,n)=>(0,G.jsx)(ln,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-every`,children:`Run every`}),(0,G.jsxs)(F,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:lt.map(e=>(0,G.jsx)(P,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,G.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,G.jsx)(`code`,{className:`font-mono text-foreground`,children:ot(e)})]})]})}var Nn=40*864e5,Pn=5;function Fn({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,G.jsx)(In,{schedule:e,now:n});let r=tt(e,n+1,n+Nn,t,Pn);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,G.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,G.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:B(new Date(e).toISOString(),t)}),(0,G.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:at(n,e)})]},e))}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function In({schedule:e,now:t}){let n=nt(e),r=dt(e);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,G.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:at(t,n)}):null]}),r?.note?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,G.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 Ln={schedule:`On a schedule`,github:`When GitHub changes`};function Rn(e){return/time zone|due time/i.test(e)?`when`:/autonomous/i.test(e)?`execution`:/placeholder|prompt|workflow|runner|model|task/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 zn({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,V.useId)();return(0,G.jsxs)(`section`,{role:n?void 0:`group`,"aria-labelledby":n?void 0:o,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[n?null:t?(0,G.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,G.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:r.message}):null]})}function Bn({draft:e,patch:t,forge:n,automation:r}){return(0,G.jsx)(G.Fragment,{children:r?(0,G.jsxs)(`p`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Ln[e.kind]]}):(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(Ye,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Ln.schedule},{value:`github`,label:Ln.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Vn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,G.jsx)(Mn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,G.jsx)(bn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Hn({draft:e,patch:t}){let n=e.kind===`schedule`?[`date`,`time`,`project`,`automation`]:[`github.kind`,`github.number`,`github.title`,`github.url`,`github.author`,`github.assignees`,`github.labels`,`github.event`],r=[...new Set([...e.prompt.matchAll(/\{\{([^{}]+)\}\}/g)].map(e=>e[1]))].filter(e=>!n.includes(e));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,G.jsx)(Ze,{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,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,G.jsx)(Xn,{draft:e,patch:t})]})}function Un({label:e,help:t,checked:n,onChange:r}){let i=(0,V.useId)();return(0,G.jsxs)(`label`,{htmlFor:i,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,G.jsx)(`span`,{id:`${i}-label`,children:e}),(0,G.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,G.jsx)(De,{id:i,className:`completion-switch shrink-0`,checked:n,"aria-labelledby":`${i}-label`,"aria-describedby":`${i}-help`,onCheckedChange:r})]})}function Wn({draft:e,patch:t,saving:n,automation:r}){let i=e.kind===`schedule`,a=r?`Enabled`:`Enable after saving`,o=i&&e.schedule.type===`once`?`It runs once at the time set under When, then moves to Archived with its task.`:i?`The first run is the next occurrence in Next 5 runs.`:vn(e.filters.includeExisting);return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,G.jsx)(Un,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,G.jsx)(Ke,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,G.jsx)(Ve,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,G.jsx)(Un,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Gn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,V.useState)(()=>Gt(e)),[s,c]=(0,V.useState)(e?.revision),[l,u]=(0,V.useState)(),[p,h]=(0,V.useState)(!1),g=e=>o(t=>({...t,...e})),_=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,Xt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(Yt(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`?`execution`:Rn(n),message:n})}finally{h(!1)}},v=(0,V.useId)(),y=(0,V.useId)(),b=a.kind===`schedule`;return(0,G.jsx)(Ne,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Yn({automation:e,draft:a,formId:v,saveHintId:y,saving:p}),children:(0,G.jsxs)(`form`,{id:v,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:grid-rows-[auto_1fr] md:items-start`,onSubmit:_,children:[(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,G.jsx)(zn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,G.jsx)(z,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>g({name:e.target.value}),required:!0})]})}),(0,G.jsxs)(zn,{title:`When`,section:`when`,failure:l,children:[(0,G.jsx)(Bn,{draft:a,patch:g,forge:t,automation:e}),(0,G.jsx)(Vn,{draft:a,patch:g,forge:t,timeZone:n,automation:e})]}),(0,G.jsx)(zn,{title:`What to run`,section:`run`,failure:l,children:(0,G.jsx)(Hn,{draft:a,patch:g})})]}),(0,G.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4 md:col-start-2 md:row-span-2 md:row-start-1`,children:[(0,G.jsx)(zn,{title:`Execution settings`,icon:(0,G.jsx)(be,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,G.jsx)(Wn,{draft:a,patch:g,saving:p,automation:e})}),b?(0,G.jsx)(Fn,{schedule:a.schedule,timeZone:n}):(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,G.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,G.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:yn(a)})]}),(0,G.jsx)(cn,{draft:a,saveLabel:qn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,G.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,G.jsx)(A,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,G.jsx)(Kn,{automation:e,onDeleted:r}):null]}):null]})})}function Kn({automation:e,onDeleted:t}){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await _(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,G.jsx)(A,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,G.jsx)(A,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:o}):null]})}function qn(e,t){return e?`Save changes`:t.enabled?`Save and enable`:`Save paused`}function Jn(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 Yn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Jn(t),s=qn(e,t);return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:(0,G.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,G.jsx)(L,{type:`button`,variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,G.jsx)(L,{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 Xn({draft:e,patch:t}){let n=i(),r=Ie(),{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=He(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,b=e=>(0,G.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,G.jsx)(qe,{children:(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Be,{slot:`automation-workflow-pill`,icon:b(ve),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,G.jsx)(Be,{slot:`automation-runner-pill`,icon:b(xe),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,G.jsx)(We,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,G.jsx)(Be,{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 Zn(e){return{text:/\bauth\b|sign.?in|\blogin\b|\btoken\b|credentials|HTTP 401/i.test(e)?`GitHub CLI is not signed in`:/ENOENT|not found.*gh|gh.*not found/i.test(e)?`GitHub CLI is not installed`:`GitHub filter check failed`,tone:`error`,details:e}}function Qn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,V.useState)({}),[c,l]=(0,V.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t,n=!1)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){let r=t instanceof Error?t.message:String(t);d(e,n?Zn(r):{text:r,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 te(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await ne(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`){let t=r.error??`Preview failed`;d(e.id,Zn(t));return}await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)},!0),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,G.jsx)(R,{route:`automations`,density:e?Ae(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,G.jsx)(L,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(he,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,G.jsx)(Me,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,G.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,G.jsx)(I,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:t}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,G.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,G.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:[`Current`,(0,G.jsx)($n,{count:y.length})]}),(0,G.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,G.jsx)($n,{count:b.length})]})]}):(0,G.jsx)(`span`,{}),(0,G.jsx)(`div`,{className:`pb-2.5`,children:(0,G.jsx)(er,{data:e})})]}),i&&x.length===0?(0,G.jsx)(K,{text:`No archived automations.`}):x.length===0?(0,G.jsx)(Fe,{icon:(0,G.jsx)(ye,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,G.jsx)(A,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(he,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,G.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,G.jsx)(lr,{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,G.jsx)(K,{text:`Loading automations…`})})}function $n({count:e}){return e===0?null:(0,G.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function er({data:e}){return(0,G.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 tr(e){return e.kind===`schedule`&&e.schedule?it(e.schedule):`${fn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function nr({automation:e,nextRun:t}){let n=e.kind===`schedule`?ge:me,r=Re(e);return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,G.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,G.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,G.jsx)(`span`,{children:tr(e)}),t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,G.jsx)(Je,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function rr({automation:e,archive:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}`,children:`Details`})})})]})}function ir({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,G.jsx)(`span`,{children:`continuous`}):r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${B(r,t)}`}),(0,G.jsx)(`span`,{children:`· ${at(Date.now(),Date.parse(r))}`})]}):(0,G.jsx)(`span`,{children:`Next run: —`})}function ar({automation:e,timeZone:t}){let n=e.enabled?St(e.state):void 0;return n?(0,G.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,G.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${B(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function or({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,G.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function sr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,G.jsx)(A,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function cr({note:e}){return(0,G.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.details?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(fe,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Pe(`gh`),children:`Set up`}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function lr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,V.useState)(!1),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null);(0,V.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,G.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,G.jsx)(nr,{automation:e,nextRun:h?void 0:(0,G.jsx)(ir,{automation:e,timeZone:t})}),h?(0,G.jsx)(rr,{automation:e,archive:h}):null,h?null:(0,G.jsx)(ar,{automation:e,timeZone:t}),h?null:(0,G.jsx)(or,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,G.jsx)(sr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,G.jsx)(cr,{note:n}):null,(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function ur(e){let t=ke(),n=Ue(),[r,i]=(0,V.useState)(),[a,o]=(0,V.useState)(``),s=(0,V.useCallback)(t=>ae({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,V.useEffect)(()=>{n&&s()},[n,s]),(0,V.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,V.useEffect)(()=>pe((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 dr({mode:e=`list`}){let{automationId:t}=de(),n=Oe(),[r,i]=(0,V.useState)(!1),{data:a,error:o,refresh:s}=ur(`include`),[c,l]=(0,V.useState)(0),u=ze();if(u===`unknown`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});if(u===`absent`)return(0,G.jsx)(Le,{});if(u===`disabled`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(Fe,{icon:(0,G.jsx)(ye,{}),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,G.jsx)(Qn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,G.jsx)(Gn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,G.jsx)(Ft,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,G.jsx)(Gn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,G.jsx)(A,{asChild:!0,variant:`outline`,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})}):t?(0,G.jsx)(Nt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,G.jsx)(K,{text:`Automation not found.`})}export{dr as AutomationsRoute};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{Fn as i}from"./toaster-Bs1mVYf9.js";import{M as a,Q as o,ct as s,r as c}from"./design-icons-QbNMZniQ.js";import{n as l}from"./diff-controls-LdJu9jvm.js";import{l as u}from"./reference-chip-Cv3i1kxz.js";import{t as d}from"./button-C8jUIs8Q.js";import{t as f}from"./project-router-onKnSy5a.js";import{m as p}from"./page-shell-Dky5crRl.js";import{t as m}from"./centered-state-BgSV4e79.js";import{Fn as h,Rn as g,Ut as _,Wt as v,rr as y,s as b}from"./index-CS4IQx7a.js";import{t as x}from"./diff-_j1dYOKk.js";var S=e(t(),1),C=n();function w({commit:e,sha:t,backTo:n,backLabel:r,slot:o,className:v,diffClassName:y}){let b=p(),[w,T]=(0,S.useState)(`unified`),[E,D]=(0,S.useState)(!0),O=e.isError&&e.error instanceof i&&e.error.status===409,k=b?w:`unified`;return(0,C.jsxs)(`section`,{"data-slot":o,"data-sha":t,className:v,children:[(0,C.jsxs)(`div`,{className:`mx-4 flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border py-2 md:mx-9`,children:[(0,C.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,C.jsxs)(f,{to:n,children:[(0,C.jsx)(c,{size:16,"aria-hidden":`true`}),r]})}),(0,C.jsx)(`span`,{className:`ml-auto flex items-center gap-1`,children:(0,C.jsx)(l,{mode:w,wrap:E,onModeChange:T,onWrapChange:D})})]}),e.isPending?(0,C.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-muted-foreground md:px-9`,children:`Loading commit…`}):e.isError?(0,C.jsx)(m,{icon:O?(0,C.jsx)(u,{}):(0,C.jsx)(s,{size:16}),tone:O?`neutral`:`danger`,heading:`h2`,title:O?`Commit not found`:`Could not load the commit`,subtitle:e.error.message}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{"data-slot":`commit-meta`,className:`mx-4 border-b border-border py-3 md:mx-9`,children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold`,children:e.data.subject}),(0,C.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:e.data.author}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(`span`,{title:e.data.when,children:_(e.data.when)}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(g,{sha:e.data.sha,variant:`inline`}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(`span`,{"data-slot":`commit-stat`,children:(0,C.jsx)(h,{stat:e.data.stat})})]})]}),e.data.files.length===0?(0,C.jsx)(m,{icon:(0,C.jsx)(a,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,C.jsx)(`div`,{className:y,children:(0,C.jsx)(x,{files:e.data.files,mode:k,wrap:E,totals:!1,className:`min-w-0`})})]})]})}var T=56;function E({slot:e,commits:t,selectedSha:n,className:i,heading:a}){let[s,c]=(0,S.useState)(``),l=s.trim().toLowerCase(),u=l?t.filter(e=>e.subject.toLowerCase().includes(l)):t,d=u.length>150,f=(0,S.useRef)(null),p=(0,S.useRef)(null),[m,h]=(0,S.useState)(0);(0,S.useLayoutEffect)(()=>{if(!d)return;let e=()=>{let e=f.current,t=p.current;!e||!t||h(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d]);let g=u.map(e=>(0,C.jsx)(D,{commit:e,selected:n!==void 0&&e.sha===n},e.sha));return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`label`,{className:`relative mb-3 block`,children:[(0,C.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3 left-3 size-4 text-muted-foreground`}),(0,C.jsx)(y,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:s,onChange:e=>c(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,C.jsxs)(`div`,{ref:e=>{f.current=e,e&&(p.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":d,className:r(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-3 py-1 md:px-4`,i),children:[a?(0,C.jsx)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-2 py-2.5`,children:a}):null,u.length===0?(0,C.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,d?(0,C.jsx)(b,{scrollRef:p,startMargin:m,itemSize:T,children:g}):g]})]})}function D({commit:e,selected:t}){return(0,C.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_56px] [content-visibility:auto]`,children:(0,C.jsxs)(f,{"data-slot":`commit-row`,"data-sha":e.sha,"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,to:e.href,className:r(`flex min-h-11 min-w-0 items-start gap-2.5 rounded-md px-2 py-2.5 transition-colors hover:bg-muted`,t&&`bg-muted/70`),children:[(0,C.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-px size-4 shrink-0 text-accent-text`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{"data-slot":`commit-row-subject`,title:e.subject,className:`line-clamp-2 text-[13px] leading-snug font-medium break-words text-foreground`,children:e.subject}),(0,C.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,C.jsx)(O,{sha:e.sha}),(0,C.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.author,` · `,(0,C.jsx)(`span`,{title:v(e.when,e.at),children:_(e.when,e.at)})]}),e.stat?(0,C.jsx)(h,{stat:e.stat}):null]})]})]})})}function O({sha:e}){return(0,C.jsx)(g,{"data-slot":`commit-sha`,sha:e,variant:`chip`})}export{O as n,w as r,E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,p as i}from"./dist-C_rn70hE.js";import{M as a,Wt as o,a as s,cn as c,dn as l,i as u,k as d,l as f,o as p,r as m,s as h}from"./queries-CII6fTHH.js";import{An as g,G as _,I as v,K as y,Si as b,U as x,hi as S,n as C,q as w}from"./toaster-Bs1mVYf9.js";import{f as T,h as ee}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{I as E,L as te,Q as ne,Z as D,ct as O,i as re,l as k,m as A,r as j,u as M,ut as ie}from"./design-icons-QbNMZniQ.js";import{t as ae}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-C8jUIs8Q.js";import{a as oe,i as se,n as ce,r as L,t as le}from"./select-1oriQjL8.js";import{i as R,r as z,t as B}from"./popover-CvL6hQ5c.js";import{r as ue,t as V}from"./project-router-onKnSy5a.js";import"./attention-C9zoC-gL.js";import{f as de,v as fe}from"./task-groups-dEzH1nMg.js";import{t as pe}from"./status-dot-BXf-Ubd0.js";import{a as me,o as he,r as ge,s as _e,t as ve}from"./command-BiBq24zL.js";import{c as H,d as U,f as ye,m as be}from"./page-shell-Dky5crRl.js";import{t as W}from"./centered-state-BgSV4e79.js";import{t as xe}from"./use-search-params-writer-ClMScnNe.js";import{At as Se,Ct as Ce,Dt as we,Et as Te,Ln as Ee,Nn as De,Ot as Oe,St as ke,Tn as G,Tt as K,Un as Ae,_t as je,bt as Me,ct as Ne,gt as Pe,jt as Fe,kt as Ie,r as Le,s as Re,tr as ze,vt as Be,wt as Ve,xt as He,yt as Ue}from"./index-CS4IQx7a.js";import{t as We}from"./markdown-BJynZeyO.js";import{a as Ge,c as Ke,d as qe,f as q,i as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,r as et,s as tt,t as nt}from"./use-hand-to-agent-state-D8ltY5hM.js";import{t as rt}from"./tab-link-B2k-zaeP.js";var J=e(t(),1),Y=n();function it({number:e,repo:t}){let n=i();return(0,Y.jsx)(at,{number:e,repo:t,scope:n},JSON.stringify([n,t,e]))}function at({number:e,repo:t,scope:n}){let i=(0,J.useId)(),o=(0,J.useId)(),[s,l]=(0,J.useState)(!1),u=s?ae:N,d=c(n,!0,n==="default"),f=a(`#${e}`,!0),p=(0,J.useMemo)(()=>Oe(fe(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":i,className:r(`mt-4 min-w-0 rounded-lg border border-border`,s?`p-3`:`p-0.5`),children:[(0,Y.jsx)(`h3`,{id:i,className:`text-xs font-semibold text-muted-foreground`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":s,"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:s?(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=De(e,g(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:de(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)(pe,{tone:t.tone,shape:t.shape,pulse:t.pulse,role:`img`,"aria-label":t.label,title:t.label}),e.archived?(0,Y.jsx)(Le,{"data-slot":`linked-task-archived`,dot:G.tone,shape:G.shape,className:`px-2 py-px`,children:G.label}):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 ot=`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 st(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 ct(e,t){return!!e&&t.length===1&&t[0]?.toLowerCase()===e.toLowerCase()}function lt(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 ut(e){return[e.viewerLogin?``:`GitHub login unavailable.`,lt(e)].filter(Boolean).join(` `)}function dt({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)(M,{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 ft({data:e,projectId:t,onProjectChange:n,pickerRef:r}){if(e.projects?.length)return(0,Y.jsxs)(le,{value:t||Z,onValueChange:e=>n(e===Z?``:e),children:[(0,Y.jsx)(se,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":t,className:`${X} ${ot} justify-between`,children:(0,Y.jsx)(oe,{placeholder:`All boards`})}),(0,Y.jsxs)(ce,{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)(le,{disabled:!0,value:Z,children:[(0,Y.jsx)(se,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":``,className:`${X} ${ot} justify-between`,children:(0,Y.jsx)(oe,{placeholder:t,children:t})}),(0,Y.jsx)(ce,{align:`start`,children:(0,Y.jsx)(L,{value:Z,children:t})})]})}return null}function pt({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)(O,{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 mt({data:e,assignees:t,projectId:n,onAssigneesChange:r,onProjectChange:i}){let[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=st(e.issues,t),f=ct(e.viewerLogin,t),p=ut(e),m=p!==``,h=(0,J.useRef)(p);m&&(h.current=p);let g=(0,J.useRef)(!m);g.current=!m;let _=()=>(l.current&&!l.current.disabled?l.current:u.current)?.focus();return(0,J.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,J.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)(dt,{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-accent-strong aria-pressed:bg-accent-strong aria-pressed:text-accent-strong-foreground aria-pressed:hover:bg-accent-strong`,disabled:!e.viewerLogin,"aria-pressed":f,onClick:()=>r(f?[]:[e.viewerLogin]),children:[(0,Y.jsx)(ie,{size:14,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Assigned to me`]}),(0,Y.jsx)(ft,{data:e,projectId:n,onProjectChange:i,pickerRef:l}),(0,Y.jsx)(pt,{data:e,message:p,lastMessage:h,hasMessage:m,statusOpen:a,setStatusOpen:o,triggerRef:s,contentRef:c})]})}function ht({onRefresh:e,refreshing:t}){let n=Pe(i());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:r(`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 gt({view:e,activeFilter:t,isDesktop:n,listInUrl:r,n:i,gh:a,actions:o}){return{headerSlot:`gh-masthead`,title:n?e===`issues`?`Issues`:`Pull requests`:`GitHub`,scope:n?Be[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)(Ee,{iso:a.syncedAt,prefix:`Synced `}):`Not synced yet`]})]}):void 0,secondaryActions:(0,Y.jsx)(_t,{...o}),headerExtra:r&&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)(j,{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:[...He,...ke].find(e=>e.id===t)?.label})]}):void 0}}function _t({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:r(`size-3.5`,t&&`motion-safe:animate-spin`)}),`Refresh`]})]})}function vt({view:e,number:t}){return(0,Y.jsx)(W,{icon:e===`issues`?(0,Y.jsx)(A,{size:16}):(0,Y.jsx)(E,{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`}. Go back to the list and search for ${t} to look it up on GitHub, closed and merged included.`})}function yt({item:e,view:t,filter:n,narrows:i,colors:a,expanded:s,onToggle:c,queuedRunId:l,checks:u,comments:d}){let f=e.kind===`issue`?A:E,p=S(),m=`gh-row-summary-${e.kind}-${e.number}`,h=()=>{p.prefetchQuery({queryKey:o.githubComments(e.kind,e.number),queryFn:({signal:t})=>y(e.kind,e.number,{},{signal:t}),staleTime:6e4})};return(0,Y.jsxs)(`div`,{"data-slot":`gh-row-shell`,"data-expanded":s||void 0,className:r(`rounded-md`,s&&`bg-sidebar-row-selected`),children:[(0,Y.jsxs)(`button`,{type:`button`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,et(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},onMouseEnter:h,onFocus:h,onClick:c,"data-slot":`gh-row`,"data-number":e.number,"data-kind":e.kind,"aria-expanded":s,"aria-controls":s?m:void 0,title:`Drag into the composer to prefill a task`,className:`flex w-full flex-col gap-2 rounded-md px-3 py-4 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2`,children:[(0,Y.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-2 md:items-center`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`,"data-slot":`gh-row-icon`,className:r(`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:r(`line-clamp-2 min-w-0 flex-1 text-[13px] font-medium md:block md:truncate`,s&&`font-semibold`),children:e.title}),(0,Y.jsx)(M,{"data-slot":`gh-row-cue`,"aria-hidden":`true`,className:r(`mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none md:mt-0`,s&&`rotate-180`)})]}),(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)(Ee,{iso:e.createdAt,className:`shrink-0`}),d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(Qe,{count:d})]}):null,u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(Ge,{checks:u})]}):null,l?(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&&!s?(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)(Ye,{label:e,color:a[e],plain:!0},e))}):null]}),s?(0,Y.jsx)(bt,{id:m,item:e,colors:a,checks:u,detailPath:Ve(t,n,e.number,``,i),queuedRunId:l}):null]})}function bt({id:e,item:t,colors:n,checks:r,detailPath:i,queuedRunId:a}){let o=s(t.kind,t.number),c=(o.data?.detail?.body??t.body)?.trim(),l=t.kind===`pr`?`PR`:`issue`;return(0,Y.jsxs)(`div`,{id:e,"data-slot":`gh-row-summary`,className:`flex flex-col gap-3 px-3 pb-4 md:pl-[34px]`,children:[(0,Y.jsx)(`div`,{"data-slot":`gh-row-body`,className:`text-[13px] leading-relaxed text-soft-foreground`,children:c?(0,Y.jsx)(`div`,{"data-slot":`gh-row-excerpt`,inert:!0,className:xt,children:(0,Y.jsx)(We,{document:!0,children:c})}):o.isPending?(0,Y.jsx)(ze,{className:`h-4 w-2/3`}):o.isError||o.data?.available===!1?(0,Y.jsx)(`p`,{"data-slot":`gh-row-body-unavailable`,className:`text-muted-foreground`,children:`Description unavailable. Use Refresh to try again.`}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),t.labels.length>0||r?(0,Y.jsxs)(`div`,{"data-slot":`gh-row-facts`,className:`flex flex-wrap items-center gap-1.5`,children:[t.labels.map(e=>(0,Y.jsx)(Ye,{label:e,color:n[e]},e)),r?(0,Y.jsx)(Je,{checks:r,url:t.url}):null]}):null,(0,Y.jsxs)(`div`,{"data-slot":`gh-row-actions`,className:`flex flex-wrap items-center gap-2`,children:[a?(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:`/tasks/${a}`,"data-action":`gh-row-view-task`,children:[(0,Y.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,Y.jsx)(I,{asChild:!0,variant:`primary`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:i,state:{focusHandoff:!0},"data-action":`gh-row-handoff`,title:`Open this ${l} and write the prompt for an agent`,children:[(0,Y.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}),(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:i,"data-action":`gh-row-open`,children:[`Open `,l,(0,Y.jsx)(re,{size:16,"aria-hidden":`true`,className:`size-3.5`})]})})]})]})}var xt=r(`max-h-[calc(3lh)] overflow-hidden [overflow-wrap:anywhere]`,`[&_*]:!my-0 [&_p+*]:!mt-1 [&_ul]:list-inside [&_ol]:list-inside`,`[&_:is(h1,h2,h3,h4,h5,h6,pre,img,table,hr,[data-streamdown="code-block"],[data-streamdown="table-wrapper"],[data-streamdown="image-wrapper"],[data-streamdown="mermaid-block"])]:hidden`);function Q(){return(0,Y.jsx)(`span`,{"data-slot":`gh-row-dot`,"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function St(e){let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`?e:e.closest(`[data-slot="main"]`)??e}function Ct(e){let[t,n]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{if(!e){n(null);return}let t=()=>n(St(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 wt(e,t){let[n,r]=(0,J.useState)(0);return(0,J.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 Tt(e,t,n){let[r,i]=(0,J.useState)(null),a=(0,J.useRef)(n);return(0,J.useEffect)(()=>{a.current=n}),(0,J.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 Et(e,t,n,r,i){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=Ct(a),u=(0,J.useRef)(null);u.current=l;let d=wt(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:Tt(p&&!i&&!t.isFetchingNextPage&&!t.isFetchNextPageError,l,()=>void t.fetchNextPage())}}function Dt({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)(k,{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 Ot=100;function kt(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>=Ot)break;a.add(t.number)}return[...a]}function At(e,t,n,r,i,a){let o=kt(n,e,r,i,a),s=m(o,e===`prs`),c=s.data?.available?s.data.checks:void 0,l=u(e===`issues`?`issue`:`pr`,(0,J.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,J.useMemo)(()=>new Set(n?.commentsDeferred?(e===`issues`?n.issues:n.prs).map(e=>e.number):[]),[n,e]);return{checkPrNumbers:o,checksMap:c,commentsOf:e=>l[e.number]??(d.has(e.number)?void 0:e.comments)}}function jt(e){let[t,n]=xe(),r=t.get(`filter`),i=Ie(e,r),a=i??`all`,o=e=>n(t=>{let n=new URLSearchParams(t);return e===null?n.delete(`filter`):n.set(`filter`,e),n}),s=K(t);return{rawFilterParam:r,filter:i,activeFilter:a,setFilterParam:o,narrows:s,url:(0,J.useMemo)(()=>{let t=new URLSearchParams(s);return{query:t.get(`q`)??``,labels:t.getAll(`label`),assignees:e===`issues`?t.getAll(`assignee`):[],board:e===`issues`?t.get(`board`)??``:``}},[s,e]),writeNarrows:(0,J.useCallback)(e=>n(t=>{let n=e(t);return(t.has(`filter`)||K(t)!==``)&&!n.has(`filter`)&&K(n)===``&&n.set(`filter`,`all`),n}),[n])}}function Mt(e,t){return n=>{let r=new URLSearchParams(n);r.delete(e);for(let n of t)r.append(e,n);return r}}function Nt(e,t,{rawFilterParam:n,filter:r,activeFilter:i,setFilterParam:a,narrows:o,url:s,writeNarrows:c}){let l=Ft(s.query,n!==null||o!==``,c),{query:u,setQuery:d}=l,f=s.labels,p=s.assignees,m=e=>c(Mt(`label`,e)),{setProjectFilter:h,activeProject:g}=It(t,s.board,c),_=e===`issues`&&i===`assigned`,v=_?t?.viewerLogin?[t.viewerLogin]:[]:p;return{query:u,setQuery:d,labelFilter:f,setLabelFilter:m,setProjectFilter:h,activeProject:g,isAssignedFilter:_,effectiveAssignees:v,changeAssignees:e=>{c(Mt(`assignee`,e)),_&&a(`all`)},clearFilters:()=>{l.clear(),c(e=>{let t=new URLSearchParams(e);for(let e of Me)t.delete(e);return r!==null&&r!==`all`&&t.set(`filter`,`all`),t})},filtering:u.trim()!==``||f.length>0||e===`issues`&&(v.length>0||g!==``)||r!==null&&r!==`all`,narrowing:u.trim()!==``||f.length>0||e===`issues`&&(!_&&p.length>0||g!==``)}}var Pt=250;function Ft(e,t,n){let r=`${T().pathname}${t?``:`#entry`}`,[i,a]=(0,J.useState)(e),o=(0,J.useRef)(e),s=(0,J.useRef)(void 0),c=(0,J.useRef)(r);return(0,J.useEffect)(()=>{e===o.current&&r===c.current||(clearTimeout(s.current),c.current=r,o.current=e,a(e))},[e,r]),(0,J.useEffect)(()=>()=>clearTimeout(s.current),[]),{query:i,setQuery:e=>{a(e),clearTimeout(s.current),s.current=setTimeout(()=>{let t=e.trim();o.current=t,n(e=>{let n=new URLSearchParams(e);return t===``?n.delete(`q`):n.set(`q`,t),n})},Pt)},clear:()=>{clearTimeout(s.current),o.current=``,a(``)}}}function It(e,t,n){let r=e=>n(t=>{let n=new URLSearchParams(t);return e===``?n.delete(`board`):n.set(`board`,e),n}),i=e?.projectsState===`refreshing`||e?.projectsState===`unavailable`,a=i||e?.projects?.some(e=>e.id===t)?t:``,o=e?.available===!0&&!i&&t!==``&&a===``;return(0,J.useEffect)(()=>{o&&n(e=>{let t=new URLSearchParams(e);return t.delete(`board`),t})},[o,n]),{setProjectFilter:r,activeProject:a}}function Lt(e,t,{filter:n,activeFilter:r},a){let o=i(),s=e===`issues`&&(r===`no-task`||r===`has-task`),l=c(o,s,o==="default"),u=(0,J.useMemo)(()=>l.data?we(l.data,t?.repo,o):null,[l.data,t?.repo,o]),d=Te(e,n)?Fe(n):null,p=f(`pr`,d??``,d!==null&&t?.available===!0),m=d!==null&&p.data?.available?p.data.items:null,h=(0,J.useMemo)(()=>t?.available?e===`issues`?t.issues:t.prs:[],[t,e]),g=(0,J.useMemo)(()=>m?Se(m,h):null,[m,h]),_=Rt({view:e,gh:t,activeFilter:r,isAssignedFilter:a,taskFilter:s,taskNumbers:u,runsQuery:l,backedQuery:d,filterHits:m,filterSearch:p});return{backedQuery:d,filterSearch:p,fullList:h,filterRows:g,filterGate:_,openItems:(0,J.useMemo)(()=>_?[]:g??h,[_,g,h]),narrow:(0,J.useMemo)(()=>e===`issues`?r===`no-task`&&u?{excludeNumbers:u}:r===`has-task`&&u?{includeNumbers:u}:{}:r===`mine`&&t?.viewerLogin?{author:t.viewerLogin}:m?{includeNumbers:new Set(m.map(e=>e.number))}:{},[e,r,u,t?.viewerLogin,m])}}function Rt({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 zt(e,t){return t?w(t.kind,t.number,{refresh:!0}).then(n=>(e.setQueryData(t.key,n),!0)).catch(()=>!1):Promise.resolve(!0)}function Bt(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,J.useState)(null);return(0,J.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 Vt(e,t,n,{fullList:r,filterRows:i},a){let s=S(),c=(0,J.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=p(l,n??0,u),f=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,J.useState)(!1);return{exactWanted:u,exactItem:d,exactDetail:f,exactTargetRef:c,retryingExact:m,retryExact:()=>{h(!0),zt(s,c.current).then(e=>{h(!1),e||C(`Could not reach GitHub for #${n}`,{tone:`danger`})})}}}function Ht(e,t,n){let r=S(),i=(0,J.useRef)(null);return{refresh:l({mutationFn:e=>(zt(r,e),x({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!==b(l)}),a.available&&a.commentsDeferred&&c.length>0&&_(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`,Ce)}),r.invalidateQueries({queryKey:o.githubSearch(`pr`,Ue)});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);y(u.kind,u.number,{refresh:!0}).then(e=>r.setQueryData(f,e)).catch(()=>{}),r.removeQueries({queryKey:d,predicate:e=>e.queryHash!==b(f)})},onError:e=>C(e.message,{tone:`danger`})}),openThreadRef:i}}var Ut=350;function Wt(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function Gt(e,t,{query:n,labelFilter:r,effectiveAssignees:i,activeProject:a},{openItems:o,narrow:s,filterGate:c}){let l=Wt(n,Ut),u=(0,J.useMemo)(()=>q(o,{query:l,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),[o,l,r,e,i,a,s]),d=n.trim()===l.trim(),p=t?.available===!0&&!c&&d&&Xe(l,u),m=f(e===`issues`?`issue`:`pr`,l,p),h=q(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=Kt(e,g,a,i);return{debouncedQuery:l,searchWanted:p,forgeSearch:m,items:h,searchPayload:g,metadataFailure:v,searchHits:g&&!v?q(g.items,{labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}).filter(e=>!_.has(e.number)):[],...qt(n,d,p,m)}}function Kt(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 qt(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 Jt({view:e,changes:t=!1,index:n=!1}){let{n:r}=ee(),i=jt(e),{rawFilterParam:a,activeFilter:o,narrows:s}=i,c=a!==null||s!==``,l=be(),{pages:u,data:f}=h(50),p=Ae(),m=Xt(),g=nt(),_=Yt({index:n,isDesktop:l,listInUrl:c,n:r,rememberedView:d().data?.githubView}),[v,y]=(0,J.useState)(null),b=Nt(e,f,i),x=Lt(e,f,i,b.isAssignedFilter),S=Gt(e,f,b,x),C=Bt(e,r,S.forgeSearch,x),w=Vt(e,f,C.selectedNumber,x,C.remoteDetail),T=At(e,u,f,C.selectedNumber,S.searchHits,x.openItems),{refresh:E,openThreadRef:te}=Ht(e,T.checkPrNumbers,S.debouncedQuery),ne=Et(e,u,f,x.backedQuery,b.narrowing);if(_.restorePrs)return(0,Y.jsx)(ue,{to:`/github/prs`,replace:!0});if(!f)return u.isError?(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(O,{size:16}),tone:`danger`,title:`Could not load GitHub`,subtitle:u.error.message})}):(0,Y.jsx)(Ne,{});te.current=null;let D=()=>E.mutate(w.exactTargetRef.current);if(_.filterScreen&&f.available)return(0,Y.jsx)(ht,{onRefresh:D,refreshing:E.isPending});if(!f.available)return(0,Y.jsx)(tn,{reason:f.reason,refreshing:E.isPending,onRetry:D});let{labelColors:re,labelOptions:k}=Zt(f,S.searchPayload,x.openItems,x.fullList),A=Qt({number:C.selectedNumber,fullList:x.fullList,filterRows:x.filterRows,remoteDetail:C.remoteDetail,exactDetail:w.exactDetail}),j=r===void 0?[...S.items,...S.searchHits].find(e=>e.url===v)??null:null,M=A??j;te.current=M?{kind:M.kind,number:M.number}:null;let{linkFilter:ie,listPath:ae}=$t(e,a,o,l,s),N={view:e,filter:ie,narrows:s,colors:re,expandedUrl:j?.url??null,onToggle:e=>y(t=>t===e.url?null:e.url),queued:g.queued,checksMap:T.checksMap,commentsOf:T.commentsOf},P=en(e,b,x.filterGate,S),F=gt({view:e,activeFilter:o,isDesktop:l,listInUrl:c,n:r,gh:f,actions:{automationsAvailable:p,refreshing:E.isPending,onRefresh:D}});return r===void 0?(0,Y.jsxs)(U,{route:`github`,density:ye(S.items.length+S.searchHits.length),headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,bodyClassName:`gap-2.5`,header:F,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)(nn,{view:e,isDesktop:l,gh:f,onSaveView:m}),(0,Y.jsx)(rn,{view:e,gh:f,filters:b,labelOptions:k,labelColors:re,searchPayload:S.searchPayload})]}),(0,Y.jsx)(sn,{view:e,rows:N,verdict:P,search:S,sidebar:x,list:u,paging:ne})]}):(0,Y.jsx)(U,{route:`github`,density:`full`,headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,header:F,children:(0,Y.jsx)(fn,{view:e,selected:A,selectedNumber:C.selectedNumber,exact:w,repo:f.repo,rows:N,listPath:ae,changes:t,handToAgent:g})})}function Yt({index:e,isDesktop:t,listInUrl:n,n:r,rememberedView:i}){return{filterScreen:e&&!t&&!n&&r===void 0,restorePrs:e&&t&&!n&&i===`prs`}}function Xt(){let e=S();return t=>{e.setQueryData(o.uiState,e=>({...e,githubView:t})),v({githubView:t}).then(t=>e.setQueryData(o.uiState,t)).catch(t=>{C(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:o.uiState})})}}function Zt(e,t,n,r){return{labelColors:{...t?.labelColors,...e.labelColors},labelOptions:qe([...n,...r,...t?.items??[]])}}function Qt({number:e,fullList:t,filterRows:n,remoteDetail:r,exactDetail:i}){return e===null?null:t.find(t=>t.number===e)??n?.find(t=>t.number===e)??r??i??null}function $t(e,t,n,r,i){let a=t===null?null:n;return{linkFilter:a,listPath:Ve(e,a??(e===`issues`&&!r?`all`:null),void 0,``,i)}}function en(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 tn({reason:e,refreshing:t,onRetry:n}){return(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(te,{}),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 nn({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)(rt,{to:t?`/github`:`/github?filter=all`,active:e===`issues`,onClick:()=>r(`issues`),children:[`Issues · `,n.issuesTotal??n.issues.length]}),(0,Y.jsxs)(rt,{to:`/github/prs`,active:e===`prs`,onClick:()=>r(`prs`),children:[`Pull requests · `,n.prsTotal??n.prs.length]})]})}function rn({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)(ne,{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-card-edge bg-card shadow-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)(hn,{options:r,colors:i,selected:n.labelFilter,onChange:n.setLabelFilter}),e===`issues`?(0,Y.jsx)(mt,{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 an(e,t){return e.kind===`pr`?t?.[e.number]??e.checks:e.checks}function on(e,t){return(0,Y.jsx)(yt,{item:e,view:t.view,filter:t.filter,narrows:t.narrows,colors:t.colors,expanded:t.expandedUrl===e.url,onToggle:()=>t.onToggle(e),queuedRunId:t.queued.get(e.url)??null,checks:an(e,t.checksMap),comments:t.commentsOf(e)})}function sn({view:e,rows:t,verdict:n,search:r,sidebar:i,list:a,paging:o}){let{items:s,searchHits:c}=r;return(0,Y.jsxs)(`section`,{ref:o.setListEl,"data-slot":`gh-list`,className:`relative flex w-full min-w-0 flex-col rounded-lg border border-card-edge bg-card shadow-card p-3`,children:[s.length===0?n&&(0,Y.jsx)(`div`,{"data-slot":`gh-empty`,className:`px-4 py-4 text-sm text-muted-foreground`,children:n}):(0,Y.jsx)(cn,{items:s,rows:t,paging:o}),o.pagingAvailable?(0,Y.jsx)(ln,{view:e,list:a,paging:o}):null,(0,Y.jsx)(un,{backedQuery:i.backedQuery,filterSearch:i.filterSearch}),s.length>0&&r.searchWanted&&n?(0,Y.jsx)(`div`,{"data-slot":`gh-search-status`,role:`status`,className:`px-4 py-4 text-sm text-muted-foreground`,children:n}):null,c.length>0?(0,Y.jsx)(dn,{hits:c,searchPayload:r.searchPayload,rows:t}):null]})}function cn({items:e,rows:t,paging:n}){let{setRowsEl:r,scrollOwner:i,listEl:a,scrollOwnerRef:o,startMargin:s}=n,c=(0,J.useRef)(null),l=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(l.current||!i)return;l.current=!0;let n=e.findIndex(e=>e.url===t.expandedUrl);n>=0&&c.current?.scrollToIndex(n,{align:`start`})},[i,e,t.expandedUrl]);let u=e.map((e,n)=>(0,Y.jsx)(`div`,{role:`listitem`,"data-slot":`gh-row-item`,"data-divided":n>0||void 0,children:on(e,t)},e.url));return(0,Y.jsx)(`div`,{ref:r,"data-slot":`gh-rows`,"data-virtualized":i?`true`:void 0,role:`list`,children:i?(0,Y.jsx)(Re,{ref:c,scrollRef:o,startMargin:s,children:u},i===a?`list`:`main`):u})}function ln({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 un({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 dn({hits:e,searchPayload:t,rows:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{i.current||(i.current=!0,(r.current?.querySelector(`[data-slot="gh-row"][aria-expanded="true"]`))?.scrollIntoView({block:`start`}))},[]),(0,Y.jsxs)(`div`,{"data-slot":`gh-search-hits`,children:[(0,Y.jsxs)(`p`,{className:`px-4 pt-2 pb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Found on GitHub`,t?.truncated?` (first matches)`:``]}),(0,Y.jsx)(`ul`,{ref:r,className:`flex flex-col gap-0.5 px-2 pb-2`,children:e.map(e=>(0,Y.jsx)(`li`,{children:on(e,n)},e.url))})]})}function fn({view:e,selected:t,selectedNumber:n,exact:r,repo:i,rows:a,listPath:o,changes:s,handToAgent:c}){let{exactWanted:l,exactItem:u}=r;return(0,Y.jsxs)(`section`,{"data-slot":`gh-detail`,className:`flex w-full min-w-0 flex-col rounded-lg border border-card-edge bg-card shadow-card`,children:[t?null:(0,Y.jsx)(`div`,{className:`px-4 pt-4 md:px-7 md:pt-5`,children:(0,Y.jsx)(tt,{backLink:{to:o}})}),t?(0,Y.jsx)(pn,{item:t,repo:i,rows:a,listPath:o,changes:s,handToAgent:c}):l&&u.isPending?(0,Y.jsx)(`div`,{"data-slot":`gh-detail-loading`,className:`flex 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 #${n}…`,subtitle:`It is not among the open items, so the tab is asking GitHub for it.`})}):l&&(u.isError||u.data?.available===!1)?(0,Y.jsx)(mn,{number:n,exact:r}):(0,Y.jsx)(vt,{view:e,number:n})]})}function pn({item:e,repo:t,rows:n,listPath:r,changes:i,handToAgent:a}){let{workflows:o,skillList:s,workflow:c,setWorkflow:l,selectedSkills:u,setSelectedSkills:d,engine:f,setEngine:p,queued:m,onQueued:h}=a,g=T().state?.focusHandoff===!0;return(0,J.useEffect)(()=>{g&&$()},[g,e.url]),(0,Y.jsx)(Ke,{item:e,comments:n.commentsOf(e),afterHeading:e.kind===`issue`?(0,Y.jsx)(it,{number:e.number,repo:t},e.url):void 0,backLink:{to:r},subNav:{filter:n.filter,narrows:n.narrows,changes:i},onRunAgent:$,headerAction:(0,Y.jsx)(Dt,{item:e,queuedRunId:m.get(e.url)??null}),colors:n.colors,checks:an(e,n.checksMap),children:(0,Y.jsx)(Ze,{item:e,workflows:o.data?.workflows??[],skills:s,workflow:c,onWorkflowChange:l,selectedSkills:u,onSkillsChange:d,engine:f,onEngineChange:p,queuedRunId:m.get(e.url)??null,onQueued:h},e.url)})}function mn({number:e,exact:t}){let{exactItem:n,retryingExact:r,retryExact:i}=t;return(0,Y.jsx)(W,{icon:(0,Y.jsx)(O,{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 hn({options:e,colors:t,selected:n,onChange:i}){let[a,o]=(0,J.useState)(!1),s=e=>i(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:r(`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)(M,{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)(ve,{children:[(0,Y.jsx)(me,{placeholder:`Filter labels…`}),(0,Y.jsxs)(_e,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Y.jsx)(ge,{children:`No labels.`}),n.length>0?(0,Y.jsxs)(he,{value:`__clear__`,onSelect:()=>i([]),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)(he,{value:e,onSelect:()=>s(e),className:`min-h-11`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`gh-label-dot`,className:`size-2.5 shrink-0 rounded-full ring-1 ring-foreground/30`,style:$e(t[e])}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Y.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e)})]})]})})]})}export{Jt as GithubRoute};
|