@wjarka/cezarion 0.18.0-dev.8161 → 0.18.0-dev.8167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{accounts-section-xFYT_zfY.js → accounts-section-CRiql0cT.js} +1 -1
  3. package/web/dist/assets/{activity-motion-OAYNqxZ2.js → activity-motion-Dic711r4.js} +1 -1
  4. package/web/dist/assets/{activity-route-cdDIR26F.js → activity-route-DkqFQfEX.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-B8yx4Ftt.js → agent-config-section-pDXHYHXz.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-BUJi0JBr.js → agent-defaults-section-D_d24TE0.js} +1 -1
  7. package/web/dist/assets/{appearance-L-Mcz7xt.js → appearance-BcCBqgn-.js} +1 -1
  8. package/web/dist/assets/{automations-route-DndFRPQ2.js → automations-route-fR3nMyuy.js} +1 -1
  9. package/web/dist/assets/{commit-diff-panel-uXKNbpAQ.js → commit-diff-panel-Ox2k_MeC.js} +1 -1
  10. package/web/dist/assets/{diff-DcmpXzlx.js → diff-B-6M-t3K.js} +2 -2
  11. package/web/dist/assets/{diff-view-Bu3mxoNK.js → diff-view-nrQTDxks.js} +1 -1
  12. package/web/dist/assets/{file-preview-DmLdg1Ak.js → file-preview-B3KVy73J.js} +1 -1
  13. package/web/dist/assets/{git-toolbar-CBMk5v-t.js → git-toolbar-TX4S_cYI.js} +1 -1
  14. package/web/dist/assets/github-DMMGSGqg.js +1 -0
  15. package/web/dist/assets/{global-activity-route-Rx7cgzpu.js → global-activity-route-c5c5Q00Y.js} +1 -1
  16. package/web/dist/assets/{index-CilVqe_c.js → index-DfmmHZB9.js} +4 -4
  17. package/web/dist/assets/{markdown-CoC8_Mxa.js → markdown-CH0W4B61.js} +1 -1
  18. package/web/dist/assets/{notifications-section-CRVfC723.js → notifications-section-bytadcE1.js} +1 -1
  19. package/web/dist/assets/{preview-pane-connected-BcePJL41.js → preview-pane-connected-Be0ZQ1QZ.js} +1 -1
  20. package/web/dist/assets/{projects-section-BzJOvGbU.js → projects-section-D2OikZvZ.js} +1 -1
  21. package/web/dist/assets/{prompt-templates-section-DCXEFZeZ.js → prompt-templates-section-BZQcqxyC.js} +1 -1
  22. package/web/dist/assets/{remote-settings-notice-B6gmSQmK.js → remote-settings-notice-B7vBsgJe.js} +1 -1
  23. package/web/dist/assets/{repo-git-f5cKDC-i.js → repo-git-4HLZT14I.js} +1 -1
  24. package/web/dist/assets/{report-reader-D_SwO-8H.js → report-reader-CmGgO12j.js} +1 -1
  25. package/web/dist/assets/{reports-CyP79G2S.js → reports-B-AxM1y5.js} +1 -1
  26. package/web/dist/assets/{run-header-CmEgf2OE.js → run-header-KmcjpBMq.js} +1 -1
  27. package/web/dist/assets/{settings-agent-picker-CIUuXcrv.js → settings-agent-picker-X-g0UKgD.js} +1 -1
  28. package/web/dist/assets/{settings-shell-DuQAKYA0.js → settings-shell-DEbkOTuH.js} +1 -1
  29. package/web/dist/assets/{skills-CBHa5_n1.js → skills-DkL4o5z5.js} +1 -1
  30. package/web/dist/assets/{task-changes-B-daTy0n.js → task-changes-DggkNS5B.js} +1 -1
  31. package/web/dist/assets/{task-commits-B8JcUxwa.js → task-commits-xhACNoGj.js} +1 -1
  32. package/web/dist/assets/{task-files-QGAAGN7K.js → task-files-CL76uaPp.js} +1 -1
  33. package/web/dist/assets/{task-github-item-BUQ-EaXP.js → task-github-item-CqID35v9.js} +1 -1
  34. package/web/dist/assets/{task-thread-BDXHF8cV.js → task-thread-BuX8KtlY.js} +1 -1
  35. package/web/dist/assets/{thread-state-CiVcAJSc.js → thread-state-dtADhBQ_.js} +1 -1
  36. package/web/dist/assets/{use-hand-to-agent-state-qYz6wj5e.js → use-hand-to-agent-state-BD10hMfn.js} +1 -1
  37. package/web/dist/assets/{workflows-CmaJn4ba.js → workflows-C2H-HfDa.js} +1 -1
  38. package/web/dist/assets/{workspace-tools-CJ8gOVwz.js → workspace-tools-Cyfz8V_L.js} +1 -1
  39. package/web/dist/assets/{worktrees-section-DmsaW6FZ.js → worktrees-section-Doo2MjMH.js} +1 -1
  40. package/web/dist/index.html +1 -1
  41. package/web/dist/assets/github-ktVA2Gmk.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{Lt as o,O as s,S as c,Xt as l,Zt as u,ci as d,i as f,w as p}from"./project-scope-context-DqBHMdSb.js";import{Z as m}from"./live-protocol-DteqtbyN.js";import{C as h,L as g,M as _,Mt as ee,U as v,Yt as y,at as b,ct as x,in as S,ot as C,st as te,t as w,vt as ne}from"./queries-DeeY9cGJ.js";import{g as re,h as ie}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as T}from"./tasks-table-_5cXATkO.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{A as D,C as O,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as k,s as me,u as he,v as ge,x as _e}from"./design-icons-CzEoMH9c.js";import{t as A}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-DqKjMToI.js";import{n as xe,r as Se}from"./diff-controls-BSWICnsb.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-CBMk5v-t.js";import{t as j}from"./info-DA1x_4bz.js";import{a as Ee,i as M}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-BSXiknFh.js";import{t as N}from"./button-BQ2y4XRB.js";import{i as P,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-CYJwJlJL.js";import{t as Fe}from"./status-dot-DtAOFiIi.js";import{t as I}from"./centered-state-V15AR_qo.js";import{$t as L,At as Ie,Bt as R,D as z,E as Le,Ft as Re,Gt as B,Hn as V,Ht as H,It as ze,Jn as Be,Kt as U,Lt as Ve,Mt as He,Nt as Ue,Ot as We,Pt as Ge,Rt as Ke,Ut as W,Vt as G,Wt as K,jt as qe,kt as Je,qt as q,tr as J,zt as Ye}from"./index-CilVqe_c.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-DcmpXzlx.js";import{t as Qe}from"./commit-diff-panel-uXKNbpAQ.js";var Y=e(t(),1);function $e(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(m.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=A(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),tt=A(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function nt(){let e=r(),t=b(),n=d(),i=$e({queryKey:w.repo})>0,o=t.data?.info?t.data:null,s=We(e,o,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:a(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:w.repo}),n.invalidateQueries({queryKey:w.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})]}),o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(qe,{scope:e,repo:o,info:o.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Je,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=_(),r=C(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),o=d(),s=S({mutationFn:e=>c({name:e}),onSuccess:async e=>{E(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([o.invalidateQueries({queryKey:w.repo}),o.invalidateQueries({queryKey:w.health})]),o.setQueryData(w.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),o.setQueryData(w.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>E(e.message,{tone:`danger`})}),[l,u]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),h=Q(e,r.data?.branches),g=m?h.filter(e=>e.toLowerCase().includes(m)):h;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(V,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[g.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:s.isPending,onClick:()=>s.mutate(e),children:[(0,X.jsx)(D,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),g.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&s.mutate(t,{onSuccess:()=>u(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(V,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>u(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||s.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=h({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:st[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function lt(){let e=te(),t=L(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof f&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>we(p),[p]),h=(0,Y.useMemo)(()=>p.some(Xe),[p]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(O,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:p,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=ie(),r=e.log,i=(0,Y.useMemo)(()=>Ke(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let a=ze(e,t),o=a&&a.behind>0?(0,X.jsx)(ft,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Ye(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ue(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(He,{checkout:n,returnFocus:i})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:x(e),sha:e,backTo:L()?`/git`:Ge,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=C(),t=ne(),n=r(),i=v(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:Re.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(Be,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:a,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=S({mutationFn:()=>p(e.runId),onSuccess:e=>{E(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:w.repoBranches}),n.invalidateQueries({queryKey:w.runs.all})},onError:e=>E(e instanceof f&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>E(`Copied ${e.name}`),()=>E(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=M(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Fe,{tone:e.runStatus&&gt[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=y(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>s({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;E(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:w.repo}),c()},onError:e=>E(e.message,{tone:`danger`})}),c=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&c(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[u,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),l&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(V,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(G,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=C(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],f=S({mutationFn:e=>s({names:e}),onSuccess:e=>{let t=e.refused.length;E(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:w.repo})},onError:e=>{n.invalidateQueries({queryKey:w.repo}),E(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=u.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(K,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(G,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:M(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=ee(),t=g().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>o(e,t.id),onError:e=>E(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),s=()=>Promise.all([r.invalidateQueries({queryKey:w.worktrees}),r.invalidateQueries({queryKey:w.repoBranches})]),c=S({mutationFn:e=>u(),onSuccess:(e,t)=>{s();let n=e.reclaimed.length,r=Math.max(0,t-n);E(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>E(e.message,{tone:`danger`})}),f=S({mutationFn:e=>l(e.runId),onSuccess:(e,t)=>{s(),E(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{s(),E(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:p,totalBytes:m,keep:h}=e.data,_=c.isPending||f.isPending,v=p.filter(e=>e.pastKeep),y=v.length>0,b=v.some(e=>e.sizeBytes===null)?null:v.reduce((e,t)=>e+(t.sizeBytes??0),0),x=y?b?`Reclaim ${T(b)} now`:`Reclaim ${v.length} now`:`Reclaim now`,C=m?T(m):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,C?` · ${C}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[h===0?`Retention is unlimited (`:`Retention keeps the newest ${h} finished checkout${h===1?``:`s`} (`,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),h===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:_||!y,title:y?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),x]})]}),p.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:p.map(e=>(0,X.jsx)(At,{worktree:e,keep:h,disabled:_,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>f.mutate(e)},e.runId))}),(0,X.jsx)(R,{open:i,onOpenChange:a,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(q,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(K,{children:[v.length,` finished worktree`,v.length===1?``:`s`,` beyond the keep limit`,b?` (${T(b)})`:``,` `,v.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(G,{"data-action":`worktrees-confirm`,onClick:()=>{c.mutate(v.length),a(!1)},children:x})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=kt(e,t),c=M(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:T(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=b(),r=L(),[i]=re();if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(Le,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let a=n.data.info;return a?(0,X.jsx)(Mt,{repo:n.data,info:a,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(D,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Ie(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ve(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Pt,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Pt({repo:e,info:t}){let n=Q(e,C().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt as RepoGitRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{Lt as o,O as s,S as c,Xt as l,Zt as u,ci as d,i as f,w as p}from"./project-scope-context-DqBHMdSb.js";import{Z as m}from"./live-protocol-DteqtbyN.js";import{C as h,L as g,M as _,Mt as ee,U as v,Yt as y,at as b,ct as x,in as S,ot as C,st as te,t as w,vt as ne}from"./queries-DeeY9cGJ.js";import{g as re,h as ie}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as T}from"./tasks-table-_5cXATkO.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{A as D,C as O,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as k,s as me,u as he,v as ge,x as _e}from"./design-icons-CzEoMH9c.js";import{t as A}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-DqKjMToI.js";import{n as xe,r as Se}from"./diff-controls-BSWICnsb.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-TX4S_cYI.js";import{t as j}from"./info-DA1x_4bz.js";import{a as Ee,i as M}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-BSXiknFh.js";import{t as N}from"./button-BQ2y4XRB.js";import{i as P,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-CYJwJlJL.js";import{t as Fe}from"./status-dot-DtAOFiIi.js";import{t as I}from"./centered-state-V15AR_qo.js";import{$t as L,At as Ie,Bt as R,D as z,E as Le,Ft as Re,Gt as B,Hn as V,Ht as H,It as ze,Jn as Be,Kt as U,Lt as Ve,Mt as He,Nt as Ue,Ot as We,Pt as Ge,Rt as Ke,Ut as W,Vt as G,Wt as K,jt as qe,kt as Je,qt as q,tr as J,zt as Ye}from"./index-DfmmHZB9.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-B-6M-t3K.js";import{t as Qe}from"./commit-diff-panel-Ox2k_MeC.js";var Y=e(t(),1);function $e(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(m.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=A(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),tt=A(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function nt(){let e=r(),t=b(),n=d(),i=$e({queryKey:w.repo})>0,o=t.data?.info?t.data:null,s=We(e,o,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:a(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:w.repo}),n.invalidateQueries({queryKey:w.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})]}),o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(qe,{scope:e,repo:o,info:o.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(Je,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=_(),r=C(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),o=d(),s=S({mutationFn:e=>c({name:e}),onSuccess:async e=>{E(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([o.invalidateQueries({queryKey:w.repo}),o.invalidateQueries({queryKey:w.health})]),o.setQueryData(w.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),o.setQueryData(w.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>E(e.message,{tone:`danger`})}),[l,u]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),h=Q(e,r.data?.branches),g=m?h.filter(e=>e.toLowerCase().includes(m)):h;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(V,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[g.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:s.isPending,onClick:()=>s.mutate(e),children:[(0,X.jsx)(D,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),g.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&s.mutate(t,{onSuccess:()=>u(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(V,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>u(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||s.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=h({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:st[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function lt(){let e=te(),t=L(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof f&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>we(p),[p]),h=(0,Y.useMemo)(()=>p.some(Xe),[p]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(O,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:p,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=ie(),r=e.log,i=(0,Y.useMemo)(()=>Ke(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let a=ze(e,t),o=a&&a.behind>0?(0,X.jsx)(ft,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Ye(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ue(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(He,{checkout:n,returnFocus:i})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:x(e),sha:e,backTo:L()?`/git`:Ge,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=C(),t=ne(),n=r(),i=v(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:Re.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(Be,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:a,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=S({mutationFn:()=>p(e.runId),onSuccess:e=>{E(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:w.repoBranches}),n.invalidateQueries({queryKey:w.runs.all})},onError:e=>E(e instanceof f&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>E(`Copied ${e.name}`),()=>E(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=M(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Fe,{tone:e.runStatus&&gt[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=y(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>s({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;E(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:w.repo}),c()},onError:e=>E(e.message,{tone:`danger`})}),c=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&c(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[u,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),l&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(V,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(G,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=C(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],f=S({mutationFn:e=>s({names:e}),onSuccess:e=>{let t=e.refused.length;E(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:w.repo})},onError:e=>{n.invalidateQueries({queryKey:w.repo}),E(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=u.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(K,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(G,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:M(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=ee(),t=g().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>o(e,t.id),onError:e=>E(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),s=()=>Promise.all([r.invalidateQueries({queryKey:w.worktrees}),r.invalidateQueries({queryKey:w.repoBranches})]),c=S({mutationFn:e=>u(),onSuccess:(e,t)=>{s();let n=e.reclaimed.length,r=Math.max(0,t-n);E(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>E(e.message,{tone:`danger`})}),f=S({mutationFn:e=>l(e.runId),onSuccess:(e,t)=>{s(),E(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{s(),E(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:p,totalBytes:m,keep:h}=e.data,_=c.isPending||f.isPending,v=p.filter(e=>e.pastKeep),y=v.length>0,b=v.some(e=>e.sizeBytes===null)?null:v.reduce((e,t)=>e+(t.sizeBytes??0),0),x=y?b?`Reclaim ${T(b)} now`:`Reclaim ${v.length} now`:`Reclaim now`,C=m?T(m):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,C?` · ${C}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[h===0?`Retention is unlimited (`:`Retention keeps the newest ${h} finished checkout${h===1?``:`s`} (`,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),h===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:_||!y,title:y?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[12px]`}),x]})]}),p.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:p.map(e=>(0,X.jsx)(At,{worktree:e,keep:h,disabled:_,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>f.mutate(e)},e.runId))}),(0,X.jsx)(R,{open:i,onOpenChange:a,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(q,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(K,{children:[v.length,` finished worktree`,v.length===1?``:`s`,` beyond the keep limit`,b?` (${T(b)})`:``,` `,v.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(G,{"data-action":`worktrees-confirm`,onClick:()=>{c.mutate(v.length),a(!1)},children:x})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=kt(e,t),c=M(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:T(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=b(),r=L(),[i]=re();if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(Le,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let a=n.data.info;return a?(0,X.jsx)(Mt,{repo:n.data,info:a,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(D,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Ie(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ve(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Pt,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Pt({repo:e,info:t}){let n=Q(e,C().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt as RepoGitRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{i as r,s as i}from"./project-scope-context-DqBHMdSb.js";import{c as a,x as o}from"./queries-DeeY9cGJ.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{c as h,i as g,l as _,o as v,s as y,t as b}from"./file-preview-DmLdg1Ak.js";import{t as x}from"./button-BQ2y4XRB.js";import{t as S}from"./centered-state-V15AR_qo.js";import{_ as C,g as w,h as T}from"./index-CilVqe_c.js";import{s as E}from"./markdown-CoC8_Mxa.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=C(T,!0),p=C(w,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=o(e,i||s||c?null:r),u=a(e,s||c?null:i),d=c&&n?{...n,data:void 0}:i?u:l;return{path:r,conflict:s,selected:r!==null||i!==null,result:d}}function L(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:a,onBack:o,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(x,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:o,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,g(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(x,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:a,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:i(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${g(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(b,{path:c.path,text:c.content??``})}):(0,O.jsx)(v,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof r&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(y,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(x,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{i as r,s as i}from"./project-scope-context-DqBHMdSb.js";import{c as a,x as o}from"./queries-DeeY9cGJ.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{c as h,i as g,l as _,o as v,s as y,t as b}from"./file-preview-B3KVy73J.js";import{t as x}from"./button-BQ2y4XRB.js";import{t as S}from"./centered-state-V15AR_qo.js";import{_ as C,g as w,h as T}from"./index-DfmmHZB9.js";import{s as E}from"./markdown-CH0W4B61.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=C(T,!0),p=C(w,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=o(e,i||s||c?null:r),u=a(e,s||c?null:i),d=c&&n?{...n,data:void 0}:i?u:l;return{path:r,conflict:s,selected:r!==null||i!==null,result:d}}function L(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:a,onBack:o,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(x,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:o,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,g(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(x,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:a,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:i(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${g(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(b,{path:c.path,text:c.content??``})}):(0,O.jsx)(v,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof r&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(y,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(x,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./utils-DSMR_WLb.js";import{Lr as i,ci as a,f as o,hn as s,hr as c,jt as l,zr as u}from"./project-scope-context-DqBHMdSb.js";import{B as d,F as f,I as p,J as m,N as h,W as g,Y as _,z as v}from"./live-protocol-DteqtbyN.js";import{t as y}from"./useInfiniteQuery-BswGDVd8.js";import{f as b,m as x}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as S,t as C}from"./ws-CKLbENkm.js";import{t as w}from"./button-BQ2y4XRB.js";import{t as T}from"./project-router-CYJwJlJL.js";import{Hn as E,b as D,gn as O}from"./index-CilVqe_c.js";import{t as k}from"./report-title-D4Mbu2Er.js";var A=e(t(),1),j=1e3,M=g().min(1).max(1024);d({q:g().max(j).optional(),before:M.optional(),limit:g().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var N=d({reports:h(d({id:m(),runId:m(),name:g(),title:g(),createdAt:_(),size:v().int().nonnegative(),taskTitle:g(),taskStatus:c}).strict()),nextCursor:M.nullable(),total:v().int().nonnegative()}).strict(),P=d({epoch:m(),generation:v().int().nonnegative(),metadataGeneration:v().int().nonnegative()}).strict(),F=d({runId:m(),taskTitle:g(),taskStatus:c}).strict(),I=f(`type`,[P.extend({type:p(`snapshot`)}),P.extend({type:p(`content`)}),P.extend({type:p(`metadata`),runs:h(F)})]),L=new WeakMap;function R(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var z=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=R(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function B(e,t){let n=L.get(e);n||(n=new Map,L.set(e,n));let r=n.get(t);return r||(r=new z(e,t),n.set(t,r)),r}async function V(e,t){let n=await o.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},l({signal:t}));return P.parse(await s(n,`/reports/state`))}function H(e){let t=B(a(),e);return(0,A.useEffect)(()=>{let n=C(`reports:project:${e}`,e=>{let n=I.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,a,o=()=>{if(i()===`finite`&&!r){a=new AbortController;let n=a.signal;V(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=S({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=P.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else i()!==`finite`&&(a?.abort(),r?.(),r=void 0)};o();let s=u(o);return()=>{s(),a?.abort(),r?.(),n()}},[t,e]),t}async function U(e,t,n,r){let i=await o.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,j),...n?{before:n}:{}}},l(r?{signal:r}:void 0));return N.parse(await s(i,`/reports`))}function W(e){let t=r(),n=H(t);return y({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>U(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var G=n(),K=new Map;function q(){let e=b(),t=x(),[n,r]=D(),i=(n.get(`q`)??``).slice(0,j),a=W(i),o=(0,A.useRef)(null),s=(0,A.useRef)(``),c=e.pathname+e.search,l=a.data?.pages.flatMap(e=>e.reports)??[];(0,A.useLayoutEffect)(()=>{if(!a.data||s.current===c)return;let n=K.get(c),r=e.state?.filesRestoreKey===c;if(!n||!o.current||t!==`POP`&&!r){s.current=c;return}let i=o.current.querySelector(`[data-report-id="${n.row}"]`);if(a.isFetchNextPageError){s.current=c,o.current.scrollTop=0;return}if((!i||a.data.pages.length<n.pages)&&a.hasNextPage){a.isFetchingNextPage||a.fetchNextPage();return}s.current=c,o.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[c,a.data,a.hasNextPage,a.isFetchingNextPage,a.isFetchNextPageError,a.fetchNextPage,e.state,t]);let u=t=>r(n=>(t?n.set(`q`,t.slice(0,j)):n.delete(`q`),K.delete(e.pathname+`?`+n.toString()),n));return(0,G.jsxs)(`section`,{"data-route":`reports`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border p-4`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Reports`}),(0,G.jsx)(E,{maxLength:j,"aria-label":`Search reports`,placeholder:`Search reports or source tasks`,value:i,onChange:e=>u(e.target.value),className:`min-h-11`})]}),(0,G.jsxs)(`div`,{ref:o,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable]`,children:[a.isPending?(0,G.jsx)(`p`,{role:`status`,children:`Loading reports…`}):a.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`p`,{children:`Could not load reports`}),(0,G.jsx)(`p`,{className:`text-sm text-soft-foreground`,children:a.error.message}),(0,G.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}):l.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-medium`,children:i?`No matching reports`:`No published reports yet`}),i?(0,G.jsx)(w,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>u(``),children:`Clear search`}):(0,G.jsxs)(`p`,{className:`text-sm text-soft-foreground`,children:[`Publish an HTML snapshot with `,(0,G.jsxs)(`code`,{children:[O(),` artifact publish`]}),` to list it here.`]})]}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,G.jsxs)(`li`,{"data-slot":`report-row`,className:`reports-row rounded-lg border border-border bg-card p-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 font-medium [overflow-wrap:anywhere]`,children:(0,G.jsx)(T,{"data-report-id":e.id,className:`reports-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:c,filesRestoreKey:c},onClick:()=>K.set(c,{scroll:o.current?.scrollTop??0,row:e.id,pages:a.data?.pages.length??1}),children:k(e)})}),(0,G.jsx)(T,{className:`reports-task text-sm text-accent-text underline [overflow-wrap:anywhere]`,to:`/tasks/${e.runId}`,children:e.taskTitle}),(0,G.jsx)(`time`,{className:`block text-xs text-soft-foreground`,dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]},e.id))}),a.hasNextPage?(0,G.jsx)(w,{variant:`outline`,className:`min-h-11`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Load more reports`}):null]})]})}export{q as ReportsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./utils-DSMR_WLb.js";import{Lr as i,ci as a,f as o,hn as s,hr as c,jt as l,zr as u}from"./project-scope-context-DqBHMdSb.js";import{B as d,F as f,I as p,J as m,N as h,W as g,Y as _,z as v}from"./live-protocol-DteqtbyN.js";import{t as y}from"./useInfiniteQuery-BswGDVd8.js";import{f as b,m as x}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as S,t as C}from"./ws-CKLbENkm.js";import{t as w}from"./button-BQ2y4XRB.js";import{t as T}from"./project-router-CYJwJlJL.js";import{Hn as E,b as D,gn as O}from"./index-DfmmHZB9.js";import{t as k}from"./report-title-D4Mbu2Er.js";var A=e(t(),1),j=1e3,M=g().min(1).max(1024);d({q:g().max(j).optional(),before:M.optional(),limit:g().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var N=d({reports:h(d({id:m(),runId:m(),name:g(),title:g(),createdAt:_(),size:v().int().nonnegative(),taskTitle:g(),taskStatus:c}).strict()),nextCursor:M.nullable(),total:v().int().nonnegative()}).strict(),P=d({epoch:m(),generation:v().int().nonnegative(),metadataGeneration:v().int().nonnegative()}).strict(),F=d({runId:m(),taskTitle:g(),taskStatus:c}).strict(),I=f(`type`,[P.extend({type:p(`snapshot`)}),P.extend({type:p(`content`)}),P.extend({type:p(`metadata`),runs:h(F)})]),L=new WeakMap;function R(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var z=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=R(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function B(e,t){let n=L.get(e);n||(n=new Map,L.set(e,n));let r=n.get(t);return r||(r=new z(e,t),n.set(t,r)),r}async function V(e,t){let n=await o.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},l({signal:t}));return P.parse(await s(n,`/reports/state`))}function H(e){let t=B(a(),e);return(0,A.useEffect)(()=>{let n=C(`reports:project:${e}`,e=>{let n=I.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,a,o=()=>{if(i()===`finite`&&!r){a=new AbortController;let n=a.signal;V(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=S({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=P.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else i()!==`finite`&&(a?.abort(),r?.(),r=void 0)};o();let s=u(o);return()=>{s(),a?.abort(),r?.(),n()}},[t,e]),t}async function U(e,t,n,r){let i=await o.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,j),...n?{before:n}:{}}},l(r?{signal:r}:void 0));return N.parse(await s(i,`/reports`))}function W(e){let t=r(),n=H(t);return y({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>U(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var G=n(),K=new Map;function q(){let e=b(),t=x(),[n,r]=D(),i=(n.get(`q`)??``).slice(0,j),a=W(i),o=(0,A.useRef)(null),s=(0,A.useRef)(``),c=e.pathname+e.search,l=a.data?.pages.flatMap(e=>e.reports)??[];(0,A.useLayoutEffect)(()=>{if(!a.data||s.current===c)return;let n=K.get(c),r=e.state?.filesRestoreKey===c;if(!n||!o.current||t!==`POP`&&!r){s.current=c;return}let i=o.current.querySelector(`[data-report-id="${n.row}"]`);if(a.isFetchNextPageError){s.current=c,o.current.scrollTop=0;return}if((!i||a.data.pages.length<n.pages)&&a.hasNextPage){a.isFetchingNextPage||a.fetchNextPage();return}s.current=c,o.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[c,a.data,a.hasNextPage,a.isFetchingNextPage,a.isFetchNextPageError,a.fetchNextPage,e.state,t]);let u=t=>r(n=>(t?n.set(`q`,t.slice(0,j)):n.delete(`q`),K.delete(e.pathname+`?`+n.toString()),n));return(0,G.jsxs)(`section`,{"data-route":`reports`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border p-4`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Reports`}),(0,G.jsx)(E,{maxLength:j,"aria-label":`Search reports`,placeholder:`Search reports or source tasks`,value:i,onChange:e=>u(e.target.value),className:`min-h-11`})]}),(0,G.jsxs)(`div`,{ref:o,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable]`,children:[a.isPending?(0,G.jsx)(`p`,{role:`status`,children:`Loading reports…`}):a.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`p`,{children:`Could not load reports`}),(0,G.jsx)(`p`,{className:`text-sm text-soft-foreground`,children:a.error.message}),(0,G.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}):l.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-medium`,children:i?`No matching reports`:`No published reports yet`}),i?(0,G.jsx)(w,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>u(``),children:`Clear search`}):(0,G.jsxs)(`p`,{className:`text-sm text-soft-foreground`,children:[`Publish an HTML snapshot with `,(0,G.jsxs)(`code`,{children:[O(),` artifact publish`]}),` to list it here.`]})]}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,G.jsxs)(`li`,{"data-slot":`report-row`,className:`reports-row rounded-lg border border-border bg-card p-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 font-medium [overflow-wrap:anywhere]`,children:(0,G.jsx)(T,{"data-report-id":e.id,className:`reports-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:c,filesRestoreKey:c},onClick:()=>K.set(c,{scroll:o.current?.scrollTop??0,row:e.id,pages:a.data?.pages.length??1}),children:k(e)})}),(0,G.jsx)(T,{className:`reports-task text-sm text-accent-text underline [overflow-wrap:anywhere]`,to:`/tasks/${e.runId}`,children:e.taskTitle}),(0,G.jsx)(`time`,{className:`block text-xs text-soft-foreground`,dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]},e.id))}),a.hasNextPage?(0,G.jsx)(w,{variant:`outline`,className:`min-h-11`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Load more reports`}):null]})]})}export{q as ReportsRoute};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Fn as a,Gn as o,Lt as s,Pn as c,Rt as l,Wn as u,ci as d,i as f,jn as p,k as m,mr as h,o as g,pr as _,qn as v,rr as y,tr as ee}from"./project-scope-context-DqBHMdSb.js";import{F as b,I as te,J as ne,L as x,M as re,R as S,U as C,Ut as w,Z as T,Zt as E,_t as D,gt as ie,in as O,nn as ae,q as oe,rn as se,t as ce,ut as le,vt as ue,y as de,z as fe}from"./queries-DeeY9cGJ.js";import{d as pe,h as me}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as he,d as ge,f as _e,g as ve,m as ye,o as be,p as xe,s as Se}from"./tasks-table-_5cXATkO.js";import{n as k}from"./toaster-Bo5vCbz-.js";import{A as Ce,F as we,a as Te,at as Ee,f as De,ft as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,p as Pe,q as Fe,t as Ie,v as A,x as Le}from"./design-icons-CzEoMH9c.js";import{t as j}from"./createLucideIcon-BHp8sXmF.js";import{t as Re}from"./app-window-CSHwDX9N.js";import{n as ze,r as Be,t as Ve}from"./open-in-menu-9Hic-2Jh.js";import{t as He}from"./info-DA1x_4bz.js";import{a as Ue,t as We}from"./format-BNCkW110.js";import{t as Ge}from"./message-square-B-MD-8rD.js";import{i as Ke,n as qe,t as M}from"./reference-chip-BSXiknFh.js";import{t as Je}from"./square-terminal-B6RYYieR.js";import{t as N}from"./button-BQ2y4XRB.js";import{a as P,i as F,l as I,n as L,p as R,r as z,t as B}from"./dropdown-menu-4e2iKSMT.js";import{i as Ye,r as Xe,t as Ze}from"./popover-BPgUYFyu.js";import{a as Qe,i as $e,o as et,r as tt,s as nt,t as rt}from"./dialog-BVF6dIeS.js";import{c as it,s as at,t as V}from"./project-router-CYJwJlJL.js";import"./attention-D8ku2yDQ.js";import{T as ot,f as H,u as st,x as ct}from"./task-groups-CC8zwSMv.js";import{t as lt}from"./status-dot-DtAOFiIi.js";import{$t as ut,An as dt,B as ft,Bt as U,Gn as pt,Gt as mt,Ht as ht,Kn as gt,Kt as _t,Qt as vt,R as yt,Ut as bt,Vt as xt,Wt as St,Xn as Ct,a as wt,dn as W,en as Tt,fn as G,jn as Et,kn as Dt,m as Ot,nn as kt,nr as At,o as jt,qt as Mt,r as Nt,rn as Pt,sn as Ft,yn as It,z as Lt}from"./index-CilVqe_c.js";import{r as Rt,t as zt}from"./markdown-CoC8_Mxa.js";import{i as Bt}from"./automation-format-CUP262Tk.js";import{t as Vt}from"./textarea-vJt9undk.js";import{t as K}from"./tab-link-Bc33InzJ.js";var Ht=j(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Ut=j(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Wt=j(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),q=e(t(),1),J=n();function Gt(e){let t=E();return O({mutationFn:t=>g(se(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>ae()),onError:e=>k(e.message,{tone:`danger`})})}function Kt(e){return e.archived?`Unarchive`:`Archive task`}function qt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,J.jsx)(U,{open:t,onOpenChange:n,children:(0,J.jsxs)(bt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,J.jsxs)(_t,{children:[(0,J.jsx)(Mt,{children:`Archive task?`}),(0,J.jsxs)(St,{children:[`Move “`,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,title:H(e),children:H(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,J.jsxs)(mt,{children:[(0,J.jsx)(ht,{children:`Cancel`}),(0,J.jsx)(xt,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Y({run:e,className:t,compactOnMobile:n=!1}){let[r,a]=(0,q.useState)(!1),o=Gt(e.id),s=Kt(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(N,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":s,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:o.isPending,className:i(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?o.mutate(!1):a(!0),children:[e.archived?(0,J.jsx)(At,{"aria-hidden":`true`}):(0,J.jsx)(Ie,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:i(n&&`max-md:sr-only`),children:s})]}),(0,J.jsx)(qt,{run:e,open:r,onOpenChange:a,onConfirm:()=>{o.mutate(!0),a(!1)}})]})}function Jt({run:e,action:t,prUrl:n,patch:i}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&r(n)?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,J.jsx)(N,{variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({autoMergePr:!1},{onError:e=>k(e.message,{tone:`danger`})}),children:i.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Yt({run:e,blocker:t,flags:n}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(V,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&r(t.pullRequestUrl)?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,J.jsx)(Y,{run:e}):null]})]})}function Xt({run:e}){let t=S(e.id),n=G(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,J.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,J.jsx)(Jt,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,J.jsx)(Yt,{run:e,blocker:i,flags:n}):null]})}var Zt=[`running`,`queued`,`waiting`];function Qt(e,{queuePosition:t,now:n=new Date}){let r=p(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Zt.includes(e.status)?en(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function $t(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function en(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:We(n,t)}}async function X(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function tn(e){let t=C(),n=T(),r=(0,q.useMemo)(()=>ve(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,q.useMemo)(()=>n===void 0?[]:r.filter(e=>he(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function nn(e){return O({mutationFn:()=>l(e.id),onError:e=>{if(e instanceof f&&e.command){X(e.command,`No terminal found — command copied to clipboard.`);return}k(e.message,{tone:`danger`})}})}function Z(e,t){let n=x(),r=ne(),i=w(),a=O({mutationFn:t=>s(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),o=It(),c=ot(e),l=o.runnersOn(e=>t&&c.sessionId!==void 0&&e===c.backend?c.profileId??`default`:o.repoAccount?.[e]).runners,u=e=>!r.isSuccess||!i.isSuccess||l.includes(e??`claude`);return{canResumeHere:t&&u(Ft(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=ze(e.id);return t===void 0||i.isSuccess&&u(t)}).map(t=>({target:t,...Pt(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function rn({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Z(e,t),o=w().data,s=W(e);return!r&&i.length===0&&!s?null:(0,J.jsxs)(J.Fragment,{children:[r||i.length>0?(0,J.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,J.jsxs)(N,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,J.jsx)(Je,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=Be(e,o);return(0,J.jsxs)(N,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,J.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,J.jsxs)(N,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,J.jsx)(A,{}),`Copy worktree path`]}):null]}):null,s?(0,J.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,J.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,J.jsxs)(N,{variant:`outline`,onClick:()=>void X(s,`Command copied to clipboard.`),children:[(0,J.jsx)(A,{}),`Copy resume command`]})]}):null]})}function an({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Z(e,t),o=W(e),s=e.worktreePath;if(!r&&i.length===0&&!o&&!s)return null;let c=`max-md:min-h-11`;return(0,J.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,J.jsx)(Ve,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,className:c,leading:r?(0,J.jsxs)(F,{"data-target":`terminal-resume`,onSelect:n,children:[(0,J.jsx)(Je,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,className:c,onClick:()=>void X(s,`Worktree path copied`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,className:c,onClick:()=>void X(o,`Command copied to clipboard.`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function on({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Z(e,t);return!a&&o.length===0?null:r?(0,J.jsx)(F,{onSelect:r,children:`Open in…`}):(0,J.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,J.jsx)(N,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,J.jsx)(Oe,{})})]}),e.worktreePath?(0,J.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(rn,{run:e,canResume:t,onResume:n})})]})}function sn({branch:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{k(`Could not copy branch. Select and copy: ${e}`)}};return(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,J.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function cn({run:e}){let t=C(),n=T(),i=r=>n===void 0?void 0:_e(n,e.id,r,t),a=(0,q.useMemo)(()=>ve(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,J.jsx)(M,{reference:t,to:i(t),taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,J.jsx)(Tt,{run:e,prNumber:t.number})},Se(t)));let l=ye(e);l&&r(l)&&!c.some(e=>e.url===l)&&o.push((0,J.jsx)(M,{reference:{kind:`PR`,url:l},taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,J.jsx)(M,{reference:t,to:i(t),taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},Se(t)));let d=ge(e,t);if(d&&r(d)&&!u.some(e=>e.url===d)){let t=be(d);s.push((0,J.jsx)(M,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?i({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,J.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,J.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function ln(){let e=at(),t=oe();return yt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var un=e=>e.map(e=>`${e.name}: ${Lt(e.url)}`).join(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Fn as a,Gn as o,Lt as s,Pn as c,Rt as l,Wn as u,ci as d,i as f,jn as p,k as m,mr as h,o as g,pr as _,qn as v,rr as y,tr as ee}from"./project-scope-context-DqBHMdSb.js";import{F as b,I as te,J as ne,L as x,M as re,R as S,U as C,Ut as w,Z as T,Zt as E,_t as D,gt as ie,in as O,nn as ae,q as oe,rn as se,t as ce,ut as le,vt as ue,y as de,z as fe}from"./queries-DeeY9cGJ.js";import{d as pe,h as me}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as he,d as ge,f as _e,g as ve,m as ye,o as be,p as xe,s as Se}from"./tasks-table-_5cXATkO.js";import{n as k}from"./toaster-Bo5vCbz-.js";import{A as Ce,F as we,a as Te,at as Ee,f as De,ft as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,p as Pe,q as Fe,t as Ie,v as A,x as Le}from"./design-icons-CzEoMH9c.js";import{t as j}from"./createLucideIcon-BHp8sXmF.js";import{t as Re}from"./app-window-CSHwDX9N.js";import{n as ze,r as Be,t as Ve}from"./open-in-menu-9Hic-2Jh.js";import{t as He}from"./info-DA1x_4bz.js";import{a as Ue,t as We}from"./format-BNCkW110.js";import{t as Ge}from"./message-square-B-MD-8rD.js";import{i as Ke,n as qe,t as M}from"./reference-chip-BSXiknFh.js";import{t as Je}from"./square-terminal-B6RYYieR.js";import{t as N}from"./button-BQ2y4XRB.js";import{a as P,i as F,l as I,n as L,p as R,r as z,t as B}from"./dropdown-menu-4e2iKSMT.js";import{i as Ye,r as Xe,t as Ze}from"./popover-BPgUYFyu.js";import{a as Qe,i as $e,o as et,r as tt,s as nt,t as rt}from"./dialog-BVF6dIeS.js";import{c as it,s as at,t as V}from"./project-router-CYJwJlJL.js";import"./attention-D8ku2yDQ.js";import{T as ot,f as H,u as st,x as ct}from"./task-groups-CC8zwSMv.js";import{t as lt}from"./status-dot-DtAOFiIi.js";import{$t as ut,An as dt,B as ft,Bt as U,Gn as pt,Gt as mt,Ht as ht,Kn as gt,Kt as _t,Qt as vt,R as yt,Ut as bt,Vt as xt,Wt as St,Xn as Ct,a as wt,dn as W,en as Tt,fn as G,jn as Et,kn as Dt,m as Ot,nn as kt,nr as At,o as jt,qt as Mt,r as Nt,rn as Pt,sn as Ft,yn as It,z as Lt}from"./index-DfmmHZB9.js";import{r as Rt,t as zt}from"./markdown-CH0W4B61.js";import{i as Bt}from"./automation-format-CUP262Tk.js";import{t as Vt}from"./textarea-vJt9undk.js";import{t as K}from"./tab-link-Bc33InzJ.js";var Ht=j(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Ut=j(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Wt=j(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),q=e(t(),1),J=n();function Gt(e){let t=E();return O({mutationFn:t=>g(se(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>ae()),onError:e=>k(e.message,{tone:`danger`})})}function Kt(e){return e.archived?`Unarchive`:`Archive task`}function qt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,J.jsx)(U,{open:t,onOpenChange:n,children:(0,J.jsxs)(bt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,J.jsxs)(_t,{children:[(0,J.jsx)(Mt,{children:`Archive task?`}),(0,J.jsxs)(St,{children:[`Move “`,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,title:H(e),children:H(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,J.jsxs)(mt,{children:[(0,J.jsx)(ht,{children:`Cancel`}),(0,J.jsx)(xt,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Y({run:e,className:t,compactOnMobile:n=!1}){let[r,a]=(0,q.useState)(!1),o=Gt(e.id),s=Kt(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(N,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":s,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:o.isPending,className:i(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?o.mutate(!1):a(!0),children:[e.archived?(0,J.jsx)(At,{"aria-hidden":`true`}):(0,J.jsx)(Ie,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:i(n&&`max-md:sr-only`),children:s})]}),(0,J.jsx)(qt,{run:e,open:r,onOpenChange:a,onConfirm:()=>{o.mutate(!0),a(!1)}})]})}function Jt({run:e,action:t,prUrl:n,patch:i}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&r(n)?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,J.jsx)(N,{variant:`outline`,disabled:i.isPending,onClick:()=>i.mutate({autoMergePr:!1},{onError:e=>k(e.message,{tone:`danger`})}),children:i.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Yt({run:e,blocker:t,flags:n}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(V,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&r(t.pullRequestUrl)?(0,J.jsx)(N,{variant:`outline`,asChild:!0,children:(0,J.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,J.jsx)(Y,{run:e}):null]})]})}function Xt({run:e}){let t=S(e.id),n=G(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,J.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,J.jsx)(Jt,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,J.jsx)(Yt,{run:e,blocker:i,flags:n}):null]})}var Zt=[`running`,`queued`,`waiting`];function Qt(e,{queuePosition:t,now:n=new Date}){let r=p(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Zt.includes(e.status)?en(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function $t(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function en(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:We(n,t)}}async function X(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function tn(e){let t=C(),n=T(),r=(0,q.useMemo)(()=>ve(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,q.useMemo)(()=>n===void 0?[]:r.filter(e=>he(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function nn(e){return O({mutationFn:()=>l(e.id),onError:e=>{if(e instanceof f&&e.command){X(e.command,`No terminal found — command copied to clipboard.`);return}k(e.message,{tone:`danger`})}})}function Z(e,t){let n=x(),r=ne(),i=w(),a=O({mutationFn:t=>s(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),o=It(),c=ot(e),l=o.runnersOn(e=>t&&c.sessionId!==void 0&&e===c.backend?c.profileId??`default`:o.repoAccount?.[e]).runners,u=e=>!r.isSuccess||!i.isSuccess||l.includes(e??`claude`);return{canResumeHere:t&&u(Ft(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=ze(e.id);return t===void 0||i.isSuccess&&u(t)}).map(t=>({target:t,...Pt(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function rn({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Z(e,t),o=w().data,s=W(e);return!r&&i.length===0&&!s?null:(0,J.jsxs)(J.Fragment,{children:[r||i.length>0?(0,J.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,J.jsxs)(N,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,J.jsx)(Je,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=Be(e,o);return(0,J.jsxs)(N,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,J.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,J.jsxs)(N,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,J.jsx)(A,{}),`Copy worktree path`]}):null]}):null,s?(0,J.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,J.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,J.jsxs)(N,{variant:`outline`,onClick:()=>void X(s,`Command copied to clipboard.`),children:[(0,J.jsx)(A,{}),`Copy resume command`]})]}):null]})}function an({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Z(e,t),o=W(e),s=e.worktreePath;if(!r&&i.length===0&&!o&&!s)return null;let c=`max-md:min-h-11`;return(0,J.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,J.jsx)(Ve,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,className:c,leading:r?(0,J.jsxs)(F,{"data-target":`terminal-resume`,onSelect:n,children:[(0,J.jsx)(Je,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,className:c,onClick:()=>void X(s,`Worktree path copied`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,className:c,onClick:()=>void X(o,`Command copied to clipboard.`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function on({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Z(e,t);return!a&&o.length===0?null:r?(0,J.jsx)(F,{onSelect:r,children:`Open in…`}):(0,J.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,J.jsx)(N,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,J.jsx)(Oe,{})})]}),e.worktreePath?(0,J.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(rn,{run:e,canResume:t,onResume:n})})]})}function sn({branch:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{k(`Could not copy branch. Select and copy: ${e}`)}};return(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,J.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function cn({run:e}){let t=C(),n=T(),i=r=>n===void 0?void 0:_e(n,e.id,r,t),a=(0,q.useMemo)(()=>ve(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,J.jsx)(M,{reference:t,to:i(t),taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,J.jsx)(Tt,{run:e,prNumber:t.number})},Se(t)));let l=ye(e);l&&r(l)&&!c.some(e=>e.url===l)&&o.push((0,J.jsx)(M,{reference:{kind:`PR`,url:l},taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,J.jsx)(M,{reference:t,to:i(t),taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},Se(t)));let d=ge(e,t);if(d&&r(d)&&!u.some(e=>e.url===d)){let t=be(d);s.push((0,J.jsx)(M,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?i({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:H(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,J.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,J.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function ln(){let e=at(),t=oe();return yt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var un=e=>e.map(e=>`${e.name}: ${Lt(e.url)}`).join(`
2
2
  `);function dn(e){return ln().length>0||e.notify===!0}function fn({run:e}){let t=ln(),n=t.length>0,r=te(e.id),[i,a]=(0,q.useState)(null),o=e.notify===!0;return!n&&!o?null:(0,J.jsxs)(J.Fragment,{children:[o?(0,J.jsxs)(B,{children:[(0,J.jsx)(R,{asChild:!0,children:(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"data-slot":`notifying-chip`,className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":n?`Notifying ${ft(t)} — webhook actions`:`Notifying — webhook actions`,title:n?un(t):void 0,children:[(0,J.jsx)(lt,{tone:`success`}),(0,J.jsx)(`span`,{children:`Notifying`}),(0,J.jsx)(Me,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,J.jsxs)(z,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[n?(0,J.jsx)(P,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-[11px] font-normal text-muted-foreground`,children:t.map(e=>(0,J.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:Lt(e.url),children:e.name},e.id))}):null,n?(0,J.jsxs)(F,{className:`min-h-11`,onSelect:()=>a(`note`),children:[(0,J.jsx)(Ge,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,J.jsxs)(F,{variant:`destructive`,className:`min-h-11`,disabled:r.isPending,onSelect:()=>r.mutate({notify:!1},{onSuccess:()=>k(`Stopped notifying the webhook`),onError:e=>k(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),children:[(0,J.jsx)(Ht,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`handoff`,className:`size-11 px-0 md:h-[30px] md:w-auto md:px-2.5`,"aria-label":`Hand off to webhook`,onClick:()=>a(`handoff`),children:[(0,J.jsx)(pt,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),n?(0,J.jsx)(pn,{mode:i,targets:t,pending:r.isPending,onOpenChange:e=>!e&&a(null),onSubmit:e=>r.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{a(null),k(i===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>k(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null]})}function pn({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let a=(0,q.useId)(),o=(0,q.useId)(),[s,c]=(0,q.useState)(``);(0,q.useEffect)(()=>{e!==null&&c(``)},[e]);let l=e===`note`,u=ft(t);return(0,J.jsx)(rt,{open:e!==null,onOpenChange:e=>{e||c(``),r(e)},children:(0,J.jsx)(tt,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,J.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(s.trim())},children:[(0,J.jsxs)(et,{className:`text-left`,children:[(0,J.jsx)(nt,{children:l?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,J.jsx)($e,{children:(0,J.jsx)(`span`,{"data-webhook-destination":``,title:un(t),children:l?`${u} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${u} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:a,className:`text-[13px] font-medium`,children:`Note`}),(0,J.jsx)(Vt,{id:a,"data-slot":`handoff-note`,"aria-describedby":o,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:s,onChange:e=>c(e.target.value)}),(0,J.jsxs)(`p`,{id:o,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,J.jsx)(He,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,J.jsxs)(Qe,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:h-11 max-sm:[&>button]:w-full`,children:[(0,J.jsx)(N,{type:`button`,variant:`ghost`,className:`sm:h-9`,onClick:()=>r(!1),children:`Cancel`}),(0,J.jsxs)(N,{type:`submit`,variant:`contrast`,className:`sm:h-9`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,J.jsx)(pt,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function mn({runId:e,children:t}){let n=pe(),r=(0,q.useMemo)(()=>({runId:e}),[e]);return n?(0,J.jsx)(hn,{runId:e,children:t}):(0,J.jsx)(Rt.Provider,{value:r,children:t})}function hn({runId:e,children:t}){let{projectId:n}=me(),r=(0,q.useMemo)(()=>({runId:e,...n?{projectId:n}:{}}),[e,n]);return(0,J.jsx)(Rt.Provider,{value:r,children:t})}function gn(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function _n(e){return typeof e==`object`&&!!e&&!(0,q.isValidElement)(e)&&`keep`in e}function vn({slot:e,icon:t,title:n,meta:r,summary:a,aside:o,open:s,onToggle:c,className:l,children:u}){let d=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,J.jsx)(`span`,{className:i(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),a??(_n(r)?(0,J.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,J.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,J.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,J.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,J.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,J.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:i(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,o,(0,J.jsx)(Me,{"aria-hidden":!0,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!o&&`ms-auto`,s&&`rotate-180`)})]}):(0,J.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,o]}),f&&s?(0,J.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function Q(e){return _(e.delegation)}function $(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function yn(e){let t=e.delegation,n=Q(e),r=D(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=$(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function bn(e){let t=D(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>ct(e.status))}function xn({run:e,open:t,onToggle:n}){let r=D(e.id),a=ue(),s=ut(),c=e.delegation,l=new Map(r.data?.workers.map(e=>[e.workerId,e])),d=$(c,r.data),f=u(e)??o(e),p=f?Sn(e,f):void 0,m=e=>a.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),h=e=>{let t=m(e);return t?H(t):`worker ${e.slice(0,8)}`};return(0,J.jsx)(vn,{slot:`workers`,icon:(0,J.jsx)(Ce,{className:`size-4`}),title:`Workers`,meta:Cn({ids:d,workers:l,desktop:s,query:r}),aside:r.data?.capacity?(0,J.jsx)(An,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,J.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,J.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,f?(0,J.jsx)(Dn,{wait:f,dependencyLabel:p}):null,d.length>0?(0,J.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:d.map(t=>{let n=l.get(t),a=m(t),o=n?Tn(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,J.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,J.jsxs)(V,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,J.jsx)(wn,{status:n?.status}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate`,children:a?H(a):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,J.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,h(n.supervisorRunId)]}):null]}),(0,J.jsx)(`span`,{className:i(`max-w-[45%] shrink-0 truncate text-xs`,En(n?.status)),children:o}),(0,J.jsx)(Te,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,J.jsx)(Mn,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,J.jsx)(In,{state:n.destroy}):null]},t)})}):Q(e)&&r.isSuccess?(0,J.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,J.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,J.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,J.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,J.jsx)(N,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function Sn(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return a(e)??c(n.role,t,`requestIds`in t&&v(n,t.requestIds))}function Cn({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function wn({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,J.jsx)(De,{"aria-hidden":!0,className:i(t,`text-success`)}):e===`failed`?(0,J.jsx)(ke,{"aria-hidden":!0,className:i(t,`text-danger`)}):e===`cancelled`?(0,J.jsx)(Ae,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,J.jsx)(Ue,{role:`status`,"aria-label":`Worker running`,className:i(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,J.jsx)(Ne,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}function Tn(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function En(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Dn({wait:e,dependencyLabel:t}){return(0,J.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,J.jsxs)(J.Fragment,{children:[` `,`Deadline: `,(0,J.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function On(e){return e.delegation?.role===`worker`&&o(e)?.phase===`wake-pending`}function kn({run:e}){let t=o(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,J.jsx)(Dn,{wait:t,dependencyLabel:c(`worker`,t)}):null}function An({capacity:e}){return(0,J.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var jn=new Set([`review`,`done`,`failed`,`cancelled`]);function Mn({parentRunId:e,worker:t}){let n=de(e),[r,i]=(0,q.useState)(!1);if(!jn.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof f?n.error.work:void 0;return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`break-words text-xs`,children:h(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,J.jsx)(N,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,J.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${Pn(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,J.jsx)(N,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var Nn=(e,t,n)=>`${e} ${e===1?t:n}`;function Pn(e){return[...e.uncommittedFiles?[Nn(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Nn(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Fn(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function In({state:e}){if(!Fn(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,J.jsx)(Ln,{at:t.nextAt});return(0,J.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,J.jsxs)(J.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,J.jsxs)(J.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Ln({at:e}){let t=vt(3e4);return(0,J.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Bt(t,Date.parse(e))})}function Rn({id:e}){return(0,J.jsxs)(V,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,J.jsx)(je,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function zn({id:e}){let t=le(e),n=t.data?H(t.data):e;return(0,J.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,J.jsxs)(V,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,J.jsx)(je,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,J.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,J.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,J.jsx)(N,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var Bn=3,Vn=(e,t)=>e.kind===t.kind&&e.number===t.number;function Hn(e,t,n=Bn){let r=t?e.findIndex(e=>Vn(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var Un=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function Wn({tab:e}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e.kind===`pr`?we:Pe,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,J.jsx)(qe,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function Gn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function Kn({servers:e}){let t=Ot();if(t===null)return null;let n=t.agentLive===!0,r=e[0],i=e.length+ +!!n===1?r?{port:r.port}:{agent:!0}:{};return(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"data-slot":`preview-toggle`,className:`max-md:h-11`,"aria-pressed":t.open,onClick:()=>t.openPane(i),children:[(0,J.jsx)(Re,{"aria-hidden":`true`}),Gn(e,n),t.live?(0,J.jsx)(lt,{tone:`success`,"aria-label":`Preview is live`}):null]})}function qn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function Jn({run:e,compact:t=!1}){if(e.delegation?.role!==`worker`)return null;let n=e.delegation.supervisorRunId??e.delegation.parentRunId;return t?(0,J.jsx)(Rn,{id:n}):(0,J.jsx)(zn,{id:n})}function Yn(e,t,n,r){return!e.archiveBlocker&&t.archive&&(n!==`session`||!kt(e,r))?(0,J.jsx)(Y,{run:e}):null}function Xn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,J.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function Zn({shown:e,run:t,archiveButton:n,previewToggle:r}){let i=dn(t);return e&&(n||r||i)?(0,J.jsxs)(`div`,{"data-slot":`run-mobile-actions`,className:`flex flex-wrap items-center gap-2 pt-2`,children:[n,r,(0,J.jsx)(fn,{run:t})]}):null}function Qn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,q.useRef)(null),c=n?`${n.kind}#${n.number}`:null;return(0,q.useEffect)(()=>{!c||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[c,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,J.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,className:`mt-3 flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-3.5 max-md:[&>a]:text-[13.5px]`,children:[(0,J.jsx)(K,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:a,children:`Commits`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,J.jsx)(K,{to:Un(e.id,t),active:n!==null&&Vn(t,n),replace:a,children:(0,J.jsx)(Wn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,J.jsxs)(B,{children:[(0,J.jsxs)(R,{"data-slot":`run-tabs-more`,"aria-label":`${i.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,i.length]}),(0,J.jsx)(z,{align:`end`,children:i.map(t=>(0,J.jsx)(F,{asChild:!0,children:(0,J.jsx)(V,{to:Un(e.id,t),replace:a,children:(0,J.jsx)(Wn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function $n({run:e,tab:t=`session`,onMarkedUnread:n}){let r=p(e),a=G(e),o=bn(e),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),d=er(e,n),f=ue(),m=re(),h=Qt(e,{queuePosition:e.status===`queued`?st(f.data??[]).get(e.id):void 0}),g=Et(),_=dt(),v=g!==null&&!_?g:null,y=v!==null,{referenceProjectId:ee,repoBase:b,requests:te}=tn(e),ne=(0,q.useMemo)(()=>xe(e,b),[e,b]),x=typeof t==`object`?t:null,{inline:S,overflow:C}=Hn(ne,x),w=m.data?.capabilities?.preview===!0,T=e.worktreePath&&w?(0,J.jsx)(Kn,{servers:e.previewServers??[]}):null,E=(0,J.jsx)(ir,{run:e,actions:d,onOpenChooser:()=>u(!0),onToggleNotes:()=>c(e=>!e)}),D=Yn(e,a,t,o);return(0,J.jsx)(Ke,{projectId:ee,repoBase:b,requests:te,children:(0,J.jsxs)(`header`,{"data-slot":`run-header`,className:i(`relative z-20 bg-background px-[18px] md:px-9 md:pt-7`,y?`pt-0`:`pt-[18px]`,t===`session`&&`md:sticky md:top-0`),children:[(0,J.jsx)(Xn,{run:e}),(0,J.jsx)(Xt,{run:e}),(0,J.jsxs)(`div`,{className:`w-full`,children:[(0,J.jsx)(Jn,{run:e}),v?(0,J.jsxs)(Dt,{slot:v,children:[(0,J.jsx)(rr,{run:e}),(0,J.jsx)(Jn,{run:e,compact:!0}),E]}):(0,J.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,J.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:qn(e.delegation)}),(0,J.jsx)(nr,{run:e}),(0,J.jsx)(Nt,{dot:r.tone,shape:r.shape,pulse:r.pulse,className:`max-md:hidden`,children:$t(h)}),(0,J.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[D,T,(0,J.jsx)(fn,{run:e}),E]})]}),(0,J.jsx)(Zn,{shown:v!==null,run:e,archiveButton:D,previewToggle:T}),(0,J.jsx)(Qn,{run:e,tab:t,activeItem:x,inlineItemTabs:S,overflowItemTabs:C,phoneBar:y,isDesktop:_}),s?(0,J.jsx)(sr,{runId:e.id,onClose:()=>c(!1)}):null,l?(0,J.jsx)(on,{run:e,canResume:G(e).terminal,onResume:()=>d.terminal.mutate(),onClose:()=>u(!1)}):null]}),(0,J.jsx)(or,{run:e,actions:d})]})})}function er(e,t){let n=d(),r=it(),[i,a]=(0,q.useState)(null),o=()=>n.invalidateQueries({queryKey:ce.runs.all}),s=e=>k(e.message,{tone:`danger`}),c=fe(),l={isPending:c.isPending,mutate:()=>c.mutate({id:e.id,pinned:!e.pinned})},u=b();return{pin:l,markUnread:{isPending:u.isPending,mutate:()=>{t?.(),u.mutate(e.id,{onError:s})}},delete:O({mutationFn:()=>m(e.id),onSuccess:()=>{o(),r(`/`)},onError:s}),terminal:nn(e),confirming:i,setConfirming:a}}function tr(e){let t=S(e.id),n=H(e);return{title:n,editor:jt(n,e=>t.mutate({title:e},{onError:e=>k(e.message,{tone:`danger`})}))}}function nr({run:e}){let{title:t,editor:n}=tr(e);return n.editing?(0,J.jsx)(wt,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,J.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,J.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,J.jsx)(gt,{className:`size-3.5`,"aria-hidden":`true`})})]})}function rr({run:e}){let{title:t,editor:n}=tr(e);return(0,J.jsxs)(Ze,{open:n.editing,onOpenChange:e=>{e?n.begin():n.commit()},children:[(0,J.jsx)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-px`,children:(0,J.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,title:e.task,children:t})}),(0,J.jsx)(Ye,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,className:`flex size-11 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,J.jsx)(gt,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(Xe,{align:`end`,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},children:(0,J.jsx)(wt,{editor:n,className:`text-[16px] font-semibold`})})]})}function ir({run:e,actions:t,onToggleNotes:n,onOpenChooser:r}){let i=G(e),a=W(e),o=S(e.id),s=(0,q.useId)();return(0,J.jsxs)(B,{children:[(0,J.jsx)(R,{asChild:!0,children:(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,J.jsx)(Le,{"aria-hidden":`true`})})}),(0,J.jsxs)(z,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,J.jsx)(P,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),(0,J.jsxs)(F,{onSelect:n,children:[(0,J.jsx)(Ct,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,J.jsx)(on,{run:e,canResume:i.terminal,onResume:()=>t.terminal.mutate(),onOpen:r}),a?(0,J.jsxs)(F,{onSelect:()=>void X(a,`Command copied to clipboard.`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),` Copy resume command`]}):null,i.markUnread?(0,J.jsxs)(F,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,J.jsx)(Ut,{"aria-hidden":`true`}),` Mark unread`]}):null,i.pin?(0,J.jsxs)(L,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,J.jsx)(Wt,{"aria-hidden":`true`}):(0,J.jsx)(Fe,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,(0,J.jsx)(I,{}),(0,J.jsx)(P,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,J.jsx)(L,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:o.isPending,onCheckedChange:e=>o.mutate({archiveWhenDone:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,J.jsx)(L,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:o.isPending,"aria-describedby":s,onCheckedChange:e=>o.mutate({autoMergePr:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,J.jsx)(`p`,{id:s,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,J.jsx)(ar,{run:e,patch:o}),i.deleteRun?(0,J.jsx)(I,{}):null,i.deleteRun?(0,J.jsxs)(F,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,J.jsx)(Ee,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})}function ar({run:e,patch:t}){let n=(0,q.useId)(),r=(0,q.useId)(),i=(0,q.useId)(),a=e=>k(e.message,{tone:`danger`});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(I,{}),(0,J.jsx)(P,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,J.jsx)(L,{"data-slot":`allow-workers`,className:`min-h-11`,checked:y(e),disabled:t.isPending,"aria-describedby":`${n} ${i}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:a}),children:`Allow Squawk workers`}),(0,J.jsx)(`p`,{id:n,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`}),(0,J.jsx)(L,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:ee(e),disabled:t.isPending,"aria-describedby":`${r} ${i}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:a}),children:`Allow task messaging`}),(0,J.jsx)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,J.jsx)(`p`,{id:i,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function or({run:e,actions:t}){let n=t.confirming;return(0,J.jsx)(U,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,J.jsxs)(bt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,J.jsxs)(_t,{children:[(0,J.jsx)(Mt,{className:`text-danger`,children:`Delete task permanently?`}),(0,J.jsx)(St,{children:(0,J.jsxs)(J.Fragment,{children:[`Delete “`,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,title:H(e),children:H(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!h(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,J.jsxs)(mt,{children:[(0,J.jsx)(ht,{children:`Cancel`}),(0,J.jsx)(xt,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function sr({runId:e,onClose:t}){let n=ie(e);return(0,J.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 rounded-xl border border-border bg-card p-6`,children:[(0,J.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,J.jsx)(N,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,J.jsx)(Oe,{})})]}),n.isPending?(0,J.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,J.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,J.jsx)(mn,{runId:e,children:(0,J.jsx)(zt,{children:n.data})}):(0,J.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-3`,children:[(0,J.jsx)(N,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void X(n.data??``,`Notes copied`),children:`Copy notes`}),(0,J.jsx)(N,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{tn as _,Fn as a,bn as c,gn as d,mn as f,nn as g,an as h,kn as i,yn as l,cn as m,In as n,On as o,sn as p,xn as r,Q as s,$n as t,vn as u,Qt as v,Y as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{br as i,ci as a,f as o,hn as s}from"./project-scope-context-DqBHMdSb.js";import{Lt as c,M as l,Nt as u,Ut as d,in as f,zt as p}from"./queries-DeeY9cGJ.js";import{t as m}from"./useQuery-IS5tPlew.js";import{it as h,l as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{a as v,i as y,o as b,r as x,s as S,t as C}from"./dialog-BVF6dIeS.js";import{Hn as w}from"./index-CilVqe_c.js";var T=e(t(),1),E=n();function D(e,t){return c(t).flatMap(t=>{let n=e.filter(e=>e.provider===t.id);return n.length<2?[{runner:t,account:null,label:t.pickerLabel,desc:t.pickerDescription,missing:!1}]:n.map(e=>({runner:t,account:e.isDefault?null:e.id,label:`${t.pickerLabel} · ${e.label}`,desc:e.exists?e.configDir:`${e.configDir} — folder not created yet`,missing:!e.exists,...e.isDefault||e.status===void 0?{}:{accountStatus:e.status.status}}))})}var O=(e,t)=>e.length>p(t).length;function k(e,t,n){let r=i(e.data,t),a=r!==void 0&&r.status!==`not-installed`&&(n??r.status)===`connected`,o=!e.isPending&&!e.isError&&r?.enabled===!0&&a;return{providerConnected:o,providerReason:e.isPending?`Checking provider authentication…`:e.isError?`Provider authentication could not be verified.`:r?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:o?void 0:`Connect this provider before selecting it.`}}function A({rows:e,runner:t,accountFor:n,providerStatus:i,disabled:a=!1,accountDisabled:o=!1,onPick:s}){let c=d().data,l=c===void 0,u=O(e,c);return(0,E.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default runner`,"data-slot":`agents-runner`,className:r(`gap-0.5 rounded-md border border-border bg-card p-0.5`,u?`flex max-w-md flex-col`:`inline-flex w-fit`),children:e.map(c=>{let{providerConnected:d,providerReason:f}=k(i,c.runner.id,c.accountStatus),p=e.filter(e=>e.runner.id===c.runner.id).length>1,m=c.runner.id===t&&c.account===n(c.runner.id);return(0,E.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":m,"data-value":c.runner.id,"data-account":c.account??``,title:f??c.desc,disabled:a||l||!d||p&&o,onClick:()=>s(c.runner.id,c.account,p),className:r(`rounded-sm px-3 py-1.5 text-left font-mono text-[13px] font-medium transition-colors disabled:opacity-50`,m?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[c.label,u?(0,E.jsx)(`span`,{"data-slot":c.missing?`agents-account-missing`:`agents-account-dir`,"data-runner":c.runner.id,className:`ml-2 font-sans text-[11px] text-soft-foreground`,children:c.desc}):null]},`${c.runner.id}:${c.account??``}`)})})}async function j(e,t){return s(await o.api.v1.providers[`sign-in`].start.$post({json:{provider:e,...t?{profileId:t}:{}}}),`/providers/sign-in/start`)}async function M(e){return s(await o.api.v1.providers[`sign-in`][`:id`].$get({param:{id:e}}),`/providers/sign-in/:id`)}async function N(e,t){return s(await o.api.v1.providers[`sign-in`][`:id`].redirect.$post({param:{id:e},json:{redirectUrl:t}}),`/providers/sign-in/:id/redirect`)}async function P(e){return s(await o.api.v1.providers[`sign-in`][`:id`].$delete({param:{id:e}}),`/providers/sign-in/:id`)}function F(e,t){let n=a(),[r,i]=(0,T.useState)(!1),[o,s]=(0,T.useState)(null),[c,l]=(0,T.useState)(``),d=(0,T.useRef)(null),p=(0,T.useRef)(!0),h=(0,T.useRef)(0),g=()=>{h.current++,v.current=!1;let e=d.current;d.current=null,e?.state===`waiting`&&P(e.id).catch(()=>{}),s(null),l(``),i(!1)};(0,T.useEffect)(()=>(p.current=!0,()=>{p.current=!1,h.current++;let e=d.current;e?.state===`waiting`&&P(e.id).catch(()=>{})}),[]);let _=f({mutationFn:n=>j(e,t).then(e=>({result:e,generation:n})),retry:!1,onSuccess:({result:e,generation:t})=>{if(!p.current||!v.current||t!==h.current){P(e.id).catch(()=>{});return}d.current=e,s(e)}}),v=(0,T.useRef)(r);v.current=r;let y=m({queryKey:[`browser-sign-in`,o?.id],queryFn:()=>M(o.id),enabled:r&&o?.state===`waiting`,retry:!1,refetchInterval:e=>e.state.error||e.state.data?.state&&e.state.data.state!==`waiting`?!1:1e3,gcTime:0}),b=y.data??o,x=f({mutationFn:()=>N(o.id,c),retry:!1,onSuccess:()=>{l(``),y.refetch()}});return(0,T.useEffect)(()=>{b?.state===`connected`&&(d.current=b,s(b),Promise.all([n.invalidateQueries({queryKey:u.agentProfiles}),n.invalidateQueries({queryKey:u.providerStatus}),n.invalidateQueries({queryKey:u.models(e)})]))},[b,n,e]),{open:r,result:b,redirect:c,setRedirect:l,start:_,replay:x,status:y,error:_.error??x.error??y.error,close:g,connect:()=>{i(!0),v.current=!0,_.reset(),x.reset(),_.mutate(++h.current)}}}function I(){return`Open the sign-in link in your browser. After Google consent, the page shows a code. Copy that code, or the full address of that page, and paste it below.`}function L({provider:e,profileId:t,label:n}){let{open:r,result:i,redirect:a,setRedirect:o,start:s,replay:c,status:u,error:d,close:f,connect:p}=F(e,t);return l().data?.capabilities?.settingsAdmin===!0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(_,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:s.isPending,onClick:p,children:`Connect`}),(0,E.jsx)(C,{open:r,onOpenChange:e=>{e||f()},children:(0,E.jsxs)(x,{children:[(0,E.jsxs)(b,{children:[(0,E.jsxs)(S,{children:[`Sign in to `,n]}),(0,E.jsx)(y,{children:`Use a personal Google account. Business and agent-platform sign-in are not supported.`})]}),s.isPending?(0,E.jsx)(`p`,{role:`status`,children:`Preparing sign-in…`}):null,i?.state===`waiting`?(0,E.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,E.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-action underline`,children:`Open Google sign-in`}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,E.jsx)(I,{})}),(0,E.jsxs)(`label`,{className:`grid gap-2`,children:[`Code or page address`,(0,E.jsx)(w,{type:`text`,autoComplete:`off`,spellCheck:!1,value:a,onChange:e=>o(e.target.value)})]}),(0,E.jsx)(_,{disabled:!a.trim()||c.isPending,onClick:()=>c.mutate(),children:`Complete sign-in`})]}):null,i?.state===`connected`?(0,E.jsx)(`p`,{role:`status`,children:`Connected.`}):null,i?.state===`failed`?(0,E.jsx)(`p`,{role:`alert`,children:i.error}):null,i?.state===`cancelled`?(0,E.jsx)(`p`,{role:`status`,children:`Sign-in cancelled. Close this window and Connect again.`}):null,d?(0,E.jsx)(`p`,{role:`alert`,children:d.message}):null,u.isError&&i?.state===`waiting`?(0,E.jsx)(_,{onClick:()=>void u.refetch(),children:`Retry status`}):null,(0,E.jsx)(v,{children:(0,E.jsx)(_,{variant:`outline`,onClick:f,children:i?.state===`connected`?`Done`:`Cancel`})})]})})]}):null}function R(e){let t=(0,T.useRef)(null),n=e.rows.find(t=>t.runner.id===e.runner&&t.account===e.accountFor(t.runner.id));return(0,E.jsxs)(`details`,{ref:t,className:`settings-agent-picker`,children:[(0,E.jsxs)(`summary`,{children:[(0,E.jsx)(h,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1`,children:(n?.label??e.runner).replace(/^codex/,`Codex`).replace(/^claude/,`Claude Code`)}),(0,E.jsx)(g,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})]}),(0,E.jsx)(A,{...e,onPick:(...n)=>{e.onPick(...n),t.current&&(t.current.open=!1)}})]})}export{k as a,O as i,L as n,D as r,R as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{br as i,ci as a,f as o,hn as s}from"./project-scope-context-DqBHMdSb.js";import{Lt as c,M as l,Nt as u,Ut as d,in as f,zt as p}from"./queries-DeeY9cGJ.js";import{t as m}from"./useQuery-IS5tPlew.js";import{it as h,l as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{a as v,i as y,o as b,r as x,s as S,t as C}from"./dialog-BVF6dIeS.js";import{Hn as w}from"./index-DfmmHZB9.js";var T=e(t(),1),E=n();function D(e,t){return c(t).flatMap(t=>{let n=e.filter(e=>e.provider===t.id);return n.length<2?[{runner:t,account:null,label:t.pickerLabel,desc:t.pickerDescription,missing:!1}]:n.map(e=>({runner:t,account:e.isDefault?null:e.id,label:`${t.pickerLabel} · ${e.label}`,desc:e.exists?e.configDir:`${e.configDir} — folder not created yet`,missing:!e.exists,...e.isDefault||e.status===void 0?{}:{accountStatus:e.status.status}}))})}var O=(e,t)=>e.length>p(t).length;function k(e,t,n){let r=i(e.data,t),a=r!==void 0&&r.status!==`not-installed`&&(n??r.status)===`connected`,o=!e.isPending&&!e.isError&&r?.enabled===!0&&a;return{providerConnected:o,providerReason:e.isPending?`Checking provider authentication…`:e.isError?`Provider authentication could not be verified.`:r?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:o?void 0:`Connect this provider before selecting it.`}}function A({rows:e,runner:t,accountFor:n,providerStatus:i,disabled:a=!1,accountDisabled:o=!1,onPick:s}){let c=d().data,l=c===void 0,u=O(e,c);return(0,E.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default runner`,"data-slot":`agents-runner`,className:r(`gap-0.5 rounded-md border border-border bg-card p-0.5`,u?`flex max-w-md flex-col`:`inline-flex w-fit`),children:e.map(c=>{let{providerConnected:d,providerReason:f}=k(i,c.runner.id,c.accountStatus),p=e.filter(e=>e.runner.id===c.runner.id).length>1,m=c.runner.id===t&&c.account===n(c.runner.id);return(0,E.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":m,"data-value":c.runner.id,"data-account":c.account??``,title:f??c.desc,disabled:a||l||!d||p&&o,onClick:()=>s(c.runner.id,c.account,p),className:r(`rounded-sm px-3 py-1.5 text-left font-mono text-[13px] font-medium transition-colors disabled:opacity-50`,m?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[c.label,u?(0,E.jsx)(`span`,{"data-slot":c.missing?`agents-account-missing`:`agents-account-dir`,"data-runner":c.runner.id,className:`ml-2 font-sans text-[11px] text-soft-foreground`,children:c.desc}):null]},`${c.runner.id}:${c.account??``}`)})})}async function j(e,t){return s(await o.api.v1.providers[`sign-in`].start.$post({json:{provider:e,...t?{profileId:t}:{}}}),`/providers/sign-in/start`)}async function M(e){return s(await o.api.v1.providers[`sign-in`][`:id`].$get({param:{id:e}}),`/providers/sign-in/:id`)}async function N(e,t){return s(await o.api.v1.providers[`sign-in`][`:id`].redirect.$post({param:{id:e},json:{redirectUrl:t}}),`/providers/sign-in/:id/redirect`)}async function P(e){return s(await o.api.v1.providers[`sign-in`][`:id`].$delete({param:{id:e}}),`/providers/sign-in/:id`)}function F(e,t){let n=a(),[r,i]=(0,T.useState)(!1),[o,s]=(0,T.useState)(null),[c,l]=(0,T.useState)(``),d=(0,T.useRef)(null),p=(0,T.useRef)(!0),h=(0,T.useRef)(0),g=()=>{h.current++,v.current=!1;let e=d.current;d.current=null,e?.state===`waiting`&&P(e.id).catch(()=>{}),s(null),l(``),i(!1)};(0,T.useEffect)(()=>(p.current=!0,()=>{p.current=!1,h.current++;let e=d.current;e?.state===`waiting`&&P(e.id).catch(()=>{})}),[]);let _=f({mutationFn:n=>j(e,t).then(e=>({result:e,generation:n})),retry:!1,onSuccess:({result:e,generation:t})=>{if(!p.current||!v.current||t!==h.current){P(e.id).catch(()=>{});return}d.current=e,s(e)}}),v=(0,T.useRef)(r);v.current=r;let y=m({queryKey:[`browser-sign-in`,o?.id],queryFn:()=>M(o.id),enabled:r&&o?.state===`waiting`,retry:!1,refetchInterval:e=>e.state.error||e.state.data?.state&&e.state.data.state!==`waiting`?!1:1e3,gcTime:0}),b=y.data??o,x=f({mutationFn:()=>N(o.id,c),retry:!1,onSuccess:()=>{l(``),y.refetch()}});return(0,T.useEffect)(()=>{b?.state===`connected`&&(d.current=b,s(b),Promise.all([n.invalidateQueries({queryKey:u.agentProfiles}),n.invalidateQueries({queryKey:u.providerStatus}),n.invalidateQueries({queryKey:u.models(e)})]))},[b,n,e]),{open:r,result:b,redirect:c,setRedirect:l,start:_,replay:x,status:y,error:_.error??x.error??y.error,close:g,connect:()=>{i(!0),v.current=!0,_.reset(),x.reset(),_.mutate(++h.current)}}}function I(){return`Open the sign-in link in your browser. After Google consent, the page shows a code. Copy that code, or the full address of that page, and paste it below.`}function L({provider:e,profileId:t,label:n}){let{open:r,result:i,redirect:a,setRedirect:o,start:s,replay:c,status:u,error:d,close:f,connect:p}=F(e,t);return l().data?.capabilities?.settingsAdmin===!0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(_,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:s.isPending,onClick:p,children:`Connect`}),(0,E.jsx)(C,{open:r,onOpenChange:e=>{e||f()},children:(0,E.jsxs)(x,{children:[(0,E.jsxs)(b,{children:[(0,E.jsxs)(S,{children:[`Sign in to `,n]}),(0,E.jsx)(y,{children:`Use a personal Google account. Business and agent-platform sign-in are not supported.`})]}),s.isPending?(0,E.jsx)(`p`,{role:`status`,children:`Preparing sign-in…`}):null,i?.state===`waiting`?(0,E.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,E.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-action underline`,children:`Open Google sign-in`}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,E.jsx)(I,{})}),(0,E.jsxs)(`label`,{className:`grid gap-2`,children:[`Code or page address`,(0,E.jsx)(w,{type:`text`,autoComplete:`off`,spellCheck:!1,value:a,onChange:e=>o(e.target.value)})]}),(0,E.jsx)(_,{disabled:!a.trim()||c.isPending,onClick:()=>c.mutate(),children:`Complete sign-in`})]}):null,i?.state===`connected`?(0,E.jsx)(`p`,{role:`status`,children:`Connected.`}):null,i?.state===`failed`?(0,E.jsx)(`p`,{role:`alert`,children:i.error}):null,i?.state===`cancelled`?(0,E.jsx)(`p`,{role:`status`,children:`Sign-in cancelled. Close this window and Connect again.`}):null,d?(0,E.jsx)(`p`,{role:`alert`,children:d.message}):null,u.isError&&i?.state===`waiting`?(0,E.jsx)(_,{onClick:()=>void u.refetch(),children:`Retry status`}):null,(0,E.jsx)(v,{children:(0,E.jsx)(_,{variant:`outline`,onClick:f,children:i?.state===`connected`?`Done`:`Cancel`})})]})})]}):null}function R(e){let t=(0,T.useRef)(null),n=e.rows.find(t=>t.runner.id===e.runner&&t.account===e.accountFor(t.runner.id));return(0,E.jsxs)(`details`,{ref:t,className:`settings-agent-picker`,children:[(0,E.jsxs)(`summary`,{children:[(0,E.jsx)(h,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1`,children:(n?.label??e.runner).replace(/^codex/,`Codex`).replace(/^claude/,`Claude Code`)}),(0,E.jsx)(g,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})]}),(0,E.jsx)(A,{...e,onPick:(...n)=>{e.onPick(...n),t.current&&(t.current.open=!1)}})]})}export{k as a,O as i,L as n,D as r,R as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Cn as r,On as i,Tn as a,kn as o,wn as s}from"./project-scope-context-DqBHMdSb.js";import{At as c,Ot as l,q as u,rt as d,v as f,wt as p}from"./queries-DeeY9cGJ.js";import{n as m,p as h,r as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as _}from"./toaster-Bo5vCbz-.js";import{l as v,u as y}from"./design-icons-CzEoMH9c.js";import{t as b}from"./createLucideIcon-BHp8sXmF.js";import{t as x}from"./button-BQ2y4XRB.js";import{n as ee,r as S,t as te}from"./collapsible-BEV4FO-1.js";import{t as C}from"./switch-Bv2Zf1uU.js";import{t as w}from"./badge-D9JrXe0o.js";import{n as T,s as E,t as D}from"./project-router-CYJwJlJL.js";import"./attention-D8ku2yDQ.js";import{Hn as O,Rn as ne,dt as re,ft as k,pt as A,z as j}from"./index-CilVqe_c.js";import{t as ie}from"./textarea-vJt9undk.js";import{ArchiveOnMergeField as ae}from"./archive-on-merge-field-BJoirmK5.js";import{a as oe,i as se,n as ce,t as le}from"./projects-section-BzJOvGbU.js";import{t as M}from"./settings-field-Bl6WuvGX.js";import{t as ue}from"./project-location-YHLlezCN.js";var de=b(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),N=e(t(),1),P={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},F=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),I={name:``,description:``,url:``,token:``,tasks:!0,triggers:i,agent:!1};function L(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??i,agent:e.agent}}var R=e=>o.filter(t=>e.includes(t));function z(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...F(e.triggers,i)?{}:{triggers:R(e.triggers)},agent:e.agent}}function B(e,t){let n={},r=e.name.trim(),a=e.description.trim(),o=e.url.trim();return r!==t.name&&(n.name=r),a!==(t.description??``)&&(n.description=a),o!==t.url&&(n.url=o),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),F(e.triggers,t.triggers??i)||(n.triggers=R(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var V=n(),H=`flex flex-col gap-1 text-[13px]`,U=`text-[11px] text-muted-foreground`;function W({draft:e,onChange:t,tokenSet:n}){let i=(0,N.useId)(),c=(0,N.useId)(),l=(0,N.useId)(),u=(0,N.useId)(),d=(0,N.useId)(),f=(0,N.useId)(),p=(0,N.useId)(),m=(0,N.useId)(),h=(0,N.useId)(),g=(0,N.useId)();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:i,className:U,children:`Name`}),(0,V.jsx)(O,{id:i,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:u,className:U,children:`URL`}),(0,V.jsx)(O,{id:u,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:a,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:c,className:U,children:`Description`}),(0,V.jsx)(ie,{id:c,"data-slot":`webhook-description`,"aria-describedby":l,rows:2,maxLength:r,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,V.jsx)(`span`,{id:l,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:d,className:U,children:`Token`}),(0,V.jsx)(O,{id:d,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:s,"aria-describedby":f,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,V.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(C,{id:p,"aria-describedby":m,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:`Task notifications`}),(0,V.jsx)(`span`,{id:m,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,V.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,V.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:o.map(n=>(0,V.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,V.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:P[n].label}),(0,V.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:P[n].hint})]})]},n))}),(0,V.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(C,{id:h,"aria-describedby":g,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:h,className:`font-medium`,children:`Let agents send reports`}),(0,V.jsx)(`span`,{id:g,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var G=`max-sm:h-11`,K=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),fe=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function q({feedback:e}){return e?(0,V.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var J=`rounded-md border border-border bg-background`,Y=`flex flex-col gap-3 border-bs border-border p-3`;function pe({projectId:e,webhook:t,defaultOpen:n=!1}){let r=l(),i=d(),a=p(),[o,s]=(0,N.useState)(n),[c,u]=(0,N.useState)(()=>L(t)),[f,m]=(0,N.useState)(null),h=B(c,t),g=Object.keys(h).length>0,y=c.name.trim()!==``&&c.url.trim()!==``,b=r.isPending||i.isPending||a.isPending,C={projectId:e,webhookId:t.id},T=e=>r.mutate({...C,...h},{onSuccess:()=>{u(e=>({...e,token:``})),e?e():_(`${c.name.trim()} saved`)},onError:e=>m(K(e,`Save`))}),E=()=>a.mutate(C,{onSuccess:e=>m(fe(e)),onError:e=>m({tone:`danger`,text:e.message})});return(0,V.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:J,children:(0,V.jsxs)(te,{open:o,onOpenChange:s,children:[(0,V.jsx)(S,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,V.jsx)(w,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,V.jsx)(w,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,V.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:j(t.url)})]}),(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,V.jsx)(ee,{children:(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,className:Y,onSubmit:e=>{e.preventDefault(),m(null),y&&g&&T()},children:[(0,V.jsx)(W,{draft:c,tokenSet:t.tokenSet,onChange:e=>u(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-save`,disabled:b||!y||!g,children:`Save`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`outline`,"data-action":`webhook-test`,disabled:b||!y,onClick:()=>{m(null),g?T(E):E()},children:`Send test`}),t.tokenSet?(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:b,onClick:()=>r.mutate({...C,token:``},{onSuccess:()=>_(`Webhook token cleared`),onError:e=>m({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:b,onClick:()=>i.mutate(C,{onSuccess:()=>_(`${t.name} removed`),onError:e=>m({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,V.jsx)(q,{feedback:f})]})})]})})}function me({projectId:e,onCreated:t,onCancel:n}){let r=f(),[i,a]=(0,N.useState)(I),[o,s]=(0,N.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,V.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:J,children:[(0,V.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:Y,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...z(i)},{onSuccess:({webhook:e})=>{_(`${e.name} created`),t(e)},onError:e=>s(K(e,`Create`))})},children:[(0,V.jsx)(W,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,V.jsx)(q,{feedback:o})]})]})}function he({project:e}){let t=e.webhooks??[],[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),o=t.length>=16;return(0,V.jsx)(M,{title:`Webhooks`,hint:`A webhook gets a POST from Squawk. Tasks can send their status to it, and agents can send it reports.`,children:(0,V.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,V.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,V.jsx)(pe,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,V.jsx)(me,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,V.jsx)(de,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,V.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function X(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Z(){let e=E(),t=u(),n=c();if(t.isPending)return(0,V.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,V.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,i=r?.projects.find(t=>t.id===e);return!r||!i?null:(0,V.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,V.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,V.jsx)(ue,{}),(0,V.jsx)(ge,{project:i}),(0,V.jsx)(M,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,V.jsx)(le,{project:i,workspaceMax:n.data.resources.maxParallel}):(0,V.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,V.jsx)(he,{project:i},i.id)]}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(_e,{project:i,bootProject:r.bootProject})})]})}function ge({project:e}){return(0,V.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,V.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,V.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,V.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[ce[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,V.jsxs)(`dd`,{className:`mt-1`,children:[X(e.addedAt),(0,V.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,V.jsx)(`dd`,{className:`mt-1`,children:X(e.lastOpenedAt)})]})]})}function _e({project:e,bootProject:t}){let[n,r]=(0,N.useState)(null),i=oe(),a=h(),o=e.id===t;return(0,V.jsxs)(M,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,V.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:`Squawk is serving this project — it re-registers itself at every start.`}):null]}),(0,V.jsx)(se,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function ve(e){return e===`global`?{Link:m,NavLink:g}:{Link:D,NavLink:T}}function Q({scope:e,title:t,mobileTitle:n}){let r=ne().name;return(0,V.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,V.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,V.jsx)(`span`,{className:`md:hidden`,children:n}),(0,V.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,V.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function $({scope:e,activeId:t}){let{NavLink:n}=ve(e),r=A(e);return(0,V.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,V.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,V.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,V.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,V.jsx)(n,{to:k(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function ye({section:e,scope:t}){let n=e.component;return(0,V.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:t,activeId:e.id}),(0,V.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,V.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,V.jsx)(n,{})]})]})]})}function be(){return(0,V.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:`project`,activeId:null}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,V.jsx)(Z,{}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(ae,{})}),(0,V.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,V.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:A(`project`).map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(D,{to:k(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,V.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,V.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,V.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,V.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,V.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,V.jsx)(m,{to:re,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}export{be as SettingsIndexRoute,ye as SettingsSectionRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Cn as r,On as i,Tn as a,kn as o,wn as s}from"./project-scope-context-DqBHMdSb.js";import{At as c,Ot as l,q as u,rt as d,v as f,wt as p}from"./queries-DeeY9cGJ.js";import{n as m,p as h,r as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as _}from"./toaster-Bo5vCbz-.js";import{l as v,u as y}from"./design-icons-CzEoMH9c.js";import{t as b}from"./createLucideIcon-BHp8sXmF.js";import{t as x}from"./button-BQ2y4XRB.js";import{n as ee,r as S,t as te}from"./collapsible-BEV4FO-1.js";import{t as C}from"./switch-Bv2Zf1uU.js";import{t as w}from"./badge-D9JrXe0o.js";import{n as T,s as E,t as D}from"./project-router-CYJwJlJL.js";import"./attention-D8ku2yDQ.js";import{Hn as O,Rn as ne,dt as re,ft as k,pt as A,z as j}from"./index-DfmmHZB9.js";import{t as ie}from"./textarea-vJt9undk.js";import{ArchiveOnMergeField as ae}from"./archive-on-merge-field-BJoirmK5.js";import{a as oe,i as se,n as ce,t as le}from"./projects-section-D2OikZvZ.js";import{t as M}from"./settings-field-Bl6WuvGX.js";import{t as ue}from"./project-location-YHLlezCN.js";var de=b(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),N=e(t(),1),P={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},F=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),I={name:``,description:``,url:``,token:``,tasks:!0,triggers:i,agent:!1};function L(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??i,agent:e.agent}}var R=e=>o.filter(t=>e.includes(t));function z(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...F(e.triggers,i)?{}:{triggers:R(e.triggers)},agent:e.agent}}function B(e,t){let n={},r=e.name.trim(),a=e.description.trim(),o=e.url.trim();return r!==t.name&&(n.name=r),a!==(t.description??``)&&(n.description=a),o!==t.url&&(n.url=o),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),F(e.triggers,t.triggers??i)||(n.triggers=R(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var V=n(),H=`flex flex-col gap-1 text-[13px]`,U=`text-[11px] text-muted-foreground`;function W({draft:e,onChange:t,tokenSet:n}){let i=(0,N.useId)(),c=(0,N.useId)(),l=(0,N.useId)(),u=(0,N.useId)(),d=(0,N.useId)(),f=(0,N.useId)(),p=(0,N.useId)(),m=(0,N.useId)(),h=(0,N.useId)(),g=(0,N.useId)();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:i,className:U,children:`Name`}),(0,V.jsx)(O,{id:i,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:u,className:U,children:`URL`}),(0,V.jsx)(O,{id:u,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:a,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:c,className:U,children:`Description`}),(0,V.jsx)(ie,{id:c,"data-slot":`webhook-description`,"aria-describedby":l,rows:2,maxLength:r,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,V.jsx)(`span`,{id:l,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,V.jsxs)(`div`,{className:H,children:[(0,V.jsx)(`label`,{htmlFor:d,className:U,children:`Token`}),(0,V.jsx)(O,{id:d,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:s,"aria-describedby":f,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,V.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(C,{id:p,"aria-describedby":m,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:p,className:`font-medium`,children:`Task notifications`}),(0,V.jsx)(`span`,{id:m,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,V.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,V.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:o.map(n=>(0,V.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,V.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:P[n].label}),(0,V.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:P[n].hint})]})]},n))}),(0,V.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,V.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,V.jsx)(C,{id:h,"aria-describedby":g,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,V.jsx)(`label`,{htmlFor:h,className:`font-medium`,children:`Let agents send reports`}),(0,V.jsx)(`span`,{id:g,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var G=`max-sm:h-11`,K=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),fe=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function q({feedback:e}){return e?(0,V.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var J=`rounded-md border border-border bg-background`,Y=`flex flex-col gap-3 border-bs border-border p-3`;function pe({projectId:e,webhook:t,defaultOpen:n=!1}){let r=l(),i=d(),a=p(),[o,s]=(0,N.useState)(n),[c,u]=(0,N.useState)(()=>L(t)),[f,m]=(0,N.useState)(null),h=B(c,t),g=Object.keys(h).length>0,y=c.name.trim()!==``&&c.url.trim()!==``,b=r.isPending||i.isPending||a.isPending,C={projectId:e,webhookId:t.id},T=e=>r.mutate({...C,...h},{onSuccess:()=>{u(e=>({...e,token:``})),e?e():_(`${c.name.trim()} saved`)},onError:e=>m(K(e,`Save`))}),E=()=>a.mutate(C,{onSuccess:e=>m(fe(e)),onError:e=>m({tone:`danger`,text:e.message})});return(0,V.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:J,children:(0,V.jsxs)(te,{open:o,onOpenChange:s,children:[(0,V.jsx)(S,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,V.jsx)(w,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,V.jsx)(w,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,V.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:j(t.url)})]}),(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,V.jsx)(ee,{children:(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,className:Y,onSubmit:e=>{e.preventDefault(),m(null),y&&g&&T()},children:[(0,V.jsx)(W,{draft:c,tokenSet:t.tokenSet,onChange:e=>u(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-save`,disabled:b||!y||!g,children:`Save`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`outline`,"data-action":`webhook-test`,disabled:b||!y,onClick:()=>{m(null),g?T(E):E()},children:`Send test`}),t.tokenSet?(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:b,onClick:()=>r.mutate({...C,token:``},{onSuccess:()=>_(`Webhook token cleared`),onError:e=>m({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:b,onClick:()=>i.mutate(C,{onSuccess:()=>_(`${t.name} removed`),onError:e=>m({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,V.jsx)(q,{feedback:f})]})})]})})}function me({projectId:e,onCreated:t,onCancel:n}){let r=f(),[i,a]=(0,N.useState)(I),[o,s]=(0,N.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,V.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:J,children:[(0,V.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,V.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:Y,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...z(i)},{onSuccess:({webhook:e})=>{_(`${e.name} created`),t(e)},onError:e=>s(K(e,`Create`))})},children:[(0,V.jsx)(W,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(x,{type:`submit`,size:`sm`,className:G,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,V.jsx)(x,{type:`button`,size:`sm`,className:G,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,V.jsx)(q,{feedback:o})]})]})}function he({project:e}){let t=e.webhooks??[],[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),o=t.length>=16;return(0,V.jsx)(M,{title:`Webhooks`,hint:`A webhook gets a POST from Squawk. Tasks can send their status to it, and agents can send it reports.`,children:(0,V.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,V.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,V.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,V.jsx)(pe,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,V.jsx)(me,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,V.jsx)(de,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,V.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function X(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Z(){let e=E(),t=u(),n=c();if(t.isPending)return(0,V.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(t.isError)return(0,V.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,t.error.message]});let r=t.data,i=r?.projects.find(t=>t.id===e);return!r||!i?null:(0,V.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,V.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,V.jsx)(ue,{}),(0,V.jsx)(ge,{project:i}),(0,V.jsx)(M,{title:`Max parallel tasks`,hint:n.data?`The workspace limit (${n.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:n.data?(0,V.jsx)(le,{project:i,workspaceMax:n.data.resources.maxParallel}):(0,V.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,V.jsx)(he,{project:i},i.id)]}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(_e,{project:i,bootProject:r.bootProject})})]})}function ge({project:e}){return(0,V.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,V.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,V.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,V.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[ce[e.status],e.status===`missing`?` — remove it below, or restore the folder`:null]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,V.jsxs)(`dd`,{className:`mt-1`,children:[X(e.addedAt),(0,V.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,V.jsx)(`dd`,{className:`mt-1`,children:X(e.lastOpenedAt)})]})]})}function _e({project:e,bootProject:t}){let[n,r]=(0,N.useState)(null),i=oe(),a=h(),o=e.id===t;return(0,V.jsxs)(M,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,V.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:`Squawk is serving this project — it re-registers itself at every start.`}):null]}),(0,V.jsx)(se,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function ve(e){return e===`global`?{Link:m,NavLink:g}:{Link:D,NavLink:T}}function Q({scope:e,title:t,mobileTitle:n}){let r=ne().name;return(0,V.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,V.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,V.jsx)(`span`,{className:`md:hidden`,children:n}),(0,V.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,V.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function $({scope:e,activeId:t}){let{NavLink:n}=ve(e),r=A(e);return(0,V.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,V.jsxs)(`summary`,{children:[r.find(e=>e.id===t)?.title??`General`,(0,V.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,V.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,V.jsx)(n,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,r.map(t=>(0,V.jsx)(n,{to:k(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function ye({section:e,scope:t}){let n=e.component;return(0,V.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:t,activeId:e.id}),(0,V.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,V.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,V.jsx)(n,{})]})]})]})}function be(){return(0,V.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,V.jsx)(Q,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,V.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,V.jsx)($,{scope:`project`,activeId:null}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,V.jsx)(Z,{}),(0,V.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,V.jsx)(ae,{})}),(0,V.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,V.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:A(`project`).map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(D,{to:k(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,V.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,V.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,V.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,V.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,V.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,V.jsx)(m,{to:re,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}export{be as SettingsIndexRoute,ye as SettingsSectionRoute};