@hearsay-tools/squawk 0.19.0-dev.9065 → 0.19.0-dev.9069

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 (75) hide show
  1. package/dist/delegation/transport.d.ts +78 -78
  2. package/dist/features/automations/automations-routes.d.ts +150 -150
  3. package/dist/features/hosts/routes.d.ts +44 -44
  4. package/dist/server/models-routes.d.ts +12 -12
  5. package/dist/server/project-settings-routes.d.ts +107 -107
  6. package/dist/server/projects-routes.d.ts +73 -73
  7. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  8. package/dist/server/repo-routes.d.ts +52 -52
  9. package/dist/server/reports-api.d.ts +2 -2
  10. package/dist/server/runners-routes.d.ts +10 -10
  11. package/dist/server/runs-routes.d.ts +335 -335
  12. package/dist/server/server.d.ts +1190 -1190
  13. package/dist/server/workspace-routes.d.ts +85 -85
  14. package/package.json +4 -4
  15. package/web/dist/assets/{accounts-section-CdmTsc7W.js → accounts-section-CiO5OMkx.js} +1 -1
  16. package/web/dist/assets/{activity-motion-CrFzRrI5.js → activity-motion-D2RZtcZk.js} +1 -1
  17. package/web/dist/assets/{activity-route-CGRkPwJP.js → activity-route-D7WKghms.js} +1 -1
  18. package/web/dist/assets/{agent-config-section-C6I_sRta.js → agent-config-section-DW7oAwLi.js} +1 -1
  19. package/web/dist/assets/{agent-defaults-section-CiOFMcep.js → agent-defaults-section-BsfycjfC.js} +1 -1
  20. package/web/dist/assets/{appearance-CBX1qOwx.js → appearance-D-a_UJUm.js} +1 -1
  21. package/web/dist/assets/{archive-on-merge-field-BzxW7NJS.js → archive-on-merge-field-RMn227ry.js} +1 -1
  22. package/web/dist/assets/{ask-card-CKD_gFDN.js → ask-card-DP9b-lI-.js} +1 -1
  23. package/web/dist/assets/{automations-route-CoSNUId5.js → automations-route-_Pv3FEnT.js} +1 -1
  24. package/web/dist/assets/{commit-list-CCgF6z16.js → commit-list-FjUd56tK.js} +1 -1
  25. package/web/dist/assets/{diff-BcseHLlM.js → diff-ZyKzQmlr.js} +2 -2
  26. package/web/dist/assets/{diff-controls-DhD4a7Z4.js → diff-controls-DHvk5BOR.js} +1 -1
  27. package/web/dist/assets/{diff-view--Nv4Px8F.js → diff-view-wHArQrRv.js} +1 -1
  28. package/web/dist/assets/{discard-changes-dialog-CD2HMH7E.js → discard-changes-dialog-u_8VAiFD.js} +1 -1
  29. package/web/dist/assets/{file-preview-BwrymAy7.js → file-preview-DbDhvIx2.js} +1 -1
  30. package/web/dist/assets/{git-toolbar-CYgIbgOf.js → git-toolbar-Bjvqzoo_.js} +1 -1
  31. package/web/dist/assets/{github-CtYRNNDH.js → github-DZyhI-94.js} +1 -1
  32. package/web/dist/assets/{global-activity-route-BXAhhLrt.js → global-activity-route-B20p5-qQ.js} +1 -1
  33. package/web/dist/assets/index-C8nM086t.css +1 -0
  34. package/web/dist/assets/{index-CXvWnyZg.js → index-TOx-AA67.js} +4 -4
  35. package/web/dist/assets/{markdown-BAmUNyiK.js → markdown-Ce0jEzBL.js} +1 -1
  36. package/web/dist/assets/{option-select-BxFrlK_-.js → option-select-BUpASY9Q.js} +1 -1
  37. package/web/dist/assets/{preferences-section-ByeO0I87.js → preferences-section-Cayq_QJk.js} +1 -1
  38. package/web/dist/assets/{preview-pane-connected-CJy9Miri.js → preview-pane-connected-C6q9f2y-.js} +1 -1
  39. package/web/dist/assets/{project-location-Cq1K7hXN.js → project-location-QEQeyIDW.js} +1 -1
  40. package/web/dist/assets/{projects-section-P0RuBn2c.js → projects-section-Ws3Kp5ky.js} +1 -1
  41. package/web/dist/assets/{prompt-templates-section-ChqZ2Gl4.js → prompt-templates-section-CfyNaD_K.js} +1 -1
  42. package/web/dist/assets/{remote-settings-notice-DYOP5Yxe.js → remote-settings-notice-DEs9jV72.js} +1 -1
  43. package/web/dist/assets/{repo-git-DcZTZ70-.js → repo-git-DpqwxFN6.js} +1 -1
  44. package/web/dist/assets/{report-reader-D0ud2uIA.js → report-reader-mwLAF_a8.js} +1 -1
  45. package/web/dist/assets/{reports-BNO0jrQI.js → reports-CN8KHXFF.js} +1 -1
  46. package/web/dist/assets/{resources-section-CQkpzv63.js → resources-section-BzYmdxRV.js} +1 -1
  47. package/web/dist/assets/{review-notes-drafts-B_Mb82AK.js → review-notes-drafts-D9s8XFRQ.js} +1 -1
  48. package/web/dist/assets/{review-panel-DcEmHodb.js → review-panel-Ds3S11Go.js} +1 -1
  49. package/web/dist/assets/{review-strip-En21aXDx.js → review-strip-BFq2VP2u.js} +1 -1
  50. package/web/dist/assets/run-header-788Dmvef.css +1 -0
  51. package/web/dist/assets/{run-header-DE0wTSnO.js → run-header-Bedua8do.js} +2 -2
  52. package/web/dist/assets/{select--dGOlrzM.js → select-CGjqNwut.js} +1 -1
  53. package/web/dist/assets/{session-context-section-b4-i_DSE.js → session-context-section-D0e8HLzL.js} +1 -1
  54. package/web/dist/assets/{settings-agent-picker-BhyVKLRu.js → settings-agent-picker-hFnntaW2.js} +1 -1
  55. package/web/dist/assets/{settings-save-bar-9D1QPg_P.js → settings-save-bar-DmONROMw.js} +1 -1
  56. package/web/dist/assets/{settings-shell-Ct4CWWvw.js → settings-shell-DjfeA3BW.js} +1 -1
  57. package/web/dist/assets/{sidebar-section-azclPE--.js → sidebar-section-DHJR37sv.js} +1 -1
  58. package/web/dist/assets/{skills-BizIiogS.js → skills-CFRO_xLW.js} +1 -1
  59. package/web/dist/assets/{task-changes-DjB5jujp.js → task-changes-BuNxS6PG.js} +1 -1
  60. package/web/dist/assets/{task-commits-cDkfIAvD.js → task-commits--1qJdD-O.js} +1 -1
  61. package/web/dist/assets/{task-file-scope-DLVI8zBp.js → task-file-scope-CFMwJrto.js} +1 -1
  62. package/web/dist/assets/{task-files-BVbjuEaL.js → task-files-CwH0b_vv.js} +1 -1
  63. package/web/dist/assets/{task-github-item-DW5Rl7Me.js → task-github-item-BezEGvZC.js} +1 -1
  64. package/web/dist/assets/{task-thread-DTLhAQbe.js → task-thread-T_RG916v.js} +2 -2
  65. package/web/dist/assets/{thread-state-VRKiUyJj.js → thread-state-zzV37Hgs.js} +1 -1
  66. package/web/dist/assets/{use-finish-run-BK7gmbXh.js → use-finish-run-CyV1CCkZ.js} +1 -1
  67. package/web/dist/assets/{use-hand-to-agent-state-pINTYkY9.js → use-hand-to-agent-state-Ci2rVhws.js} +1 -1
  68. package/web/dist/assets/use-path-bases-Cimv7R-0.js +1 -0
  69. package/web/dist/assets/{workflows-D2h67tAS.js → workflows-B9NzpaaA.js} +1 -1
  70. package/web/dist/assets/{workspace-tools-uIbmvTfR.js → workspace-tools-C0K5dFxy.js} +1 -1
  71. package/web/dist/assets/{worktrees-section-Cm1pcQ9g.js → worktrees-section-D48xLdpr.js} +1 -1
  72. package/web/dist/index.html +2 -2
  73. package/web/dist/assets/index-BUmO8olN.css +0 -1
  74. package/web/dist/assets/run-header-V9BxPSvn.css +0 -1
  75. package/web/dist/assets/use-path-bases-D1yBeTzY.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{o as r,p as i,s as a}from"./dist-C_rn70hE.js";import{A as o,C as s,Kt as c,S as l,T as u,U as d,Ut as f,bt as p,nt as m,un as h,w as g}from"./queries-CchoEEzj.js";import{B as ee,Rn as _,T as v,f as y,n as b,ut as x,vi as S,w as C,z as te,zt as ne}from"./toaster-zMN8cNZQ.js";import{Z as w}from"./live-protocol-DMhTnCmf.js";import{g as T,h as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{c as D,f as O,i as re,t as k}from"./reference-chip-z7dZJVH-.js";import{D as ie,F as A,I as ae,M as oe,N as se,P as ce,Q as le,S as ue,X as de,Z as fe,c as pe,ct as me,d as he,j as ge,l as _e,n as ve,st as ye,w as be,y as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./createLucideIcon-BHp8sXmF.js";import{n as Ce,t as we}from"./circle-x-7nTlobAF.js";import{_ as Te}from"./nav-row-styles-CgP5uNp4.js";import{i as Ee,r as De,t as Oe}from"./git-toolbar-CYgIbgOf.js";import{t as j}from"./info-DA1x_4bz.js";import{t as ke}from"./loader-circle-CPBhhDbB.js";import{a as Ae,i as je,n as Me,r as Ne}from"./diff-controls-DhD4a7Z4.js";import{t as M}from"./button-C8jUIs8Q.js";import{i as N,l as Pe,p as Fe,r as Ie,t as Le}from"./dropdown-menu-DjtKUK8F.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./dialog-DRZuXvul.js";import{t as P}from"./project-router-j0uBi7Ep.js";import{t as Ge}from"./status-dot-BXf-Ubd0.js";import{c as Ke,d as qe,f as Je,m as F,n as Ye,s as Xe,t as Ze}from"./page-shell-Dky5crRl.js";import{a as Qe,o as $e}from"./format-BU7D3IfE.js";import{t as et}from"./control-locations-kCPVEtOM.js";import{t as I}from"./centered-state-BgSV4e79.js";import{$t as tt,Bn as nt,Bt as rt,Cr as L,Gt as it,Hn as at,Ht as ot,In as st,Jt as ct,Kt as lt,M as ut,N as R,Qt as dt,Ut as ft,Vn as pt,Vt as mt,Wt as ht,Xt as gt,Yt as z,Zt as _t,an as B,cn as V,en as vt,in as H,mr as yt,nn as U,on as W,qt as G,rn as K,sn as q,sr as bt,tn as J,xr as xt}from"./index-CXvWnyZg.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-BcseHLlM.js";import{t as wt}from"./change-counts-wqSYI3W8.js";import{t as Tt}from"./code-workbench-CUkiQ1pF.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-CCgF6z16.js";var Y=e(t(),1);function At(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=Se(`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`}]]),Mt=Se(`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=i(),t=l(),n=S(),a=At({queryKey:f.repo})>0,o=t.data?.info?t.data:null,s=rt(e,o,`screen`);return(0,X.jsx)(qe,{route:`repo-git`,density:o?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ke,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:a,onClick:()=>{n.invalidateQueries({queryKey:f.repo}),n.invalidateQueries({queryKey:f.worktrees})},children:(0,X.jsx)(fe,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,a&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(ft,{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)(mt,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ke,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:G(i())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(de,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=lt(i()),a=G(i()),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=o.trim(),d=Pt(u),f=d??c;return(0,X.jsx)(We,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(He,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!u||d||a)&&(l(null),r.mutate(u,{onSuccess:n,onError:e=>l(e.message)}))},children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Ue,{children:`New branch`}),(0,X.jsxs)(ze,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(Be,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(bt,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:o,"aria-invalid":f?!0:void 0,"aria-describedby":f?`new-branch-name-hint`:void 0,onChange:e=>{s(e.target.value),l(null)}}),f?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":d?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:f}):null]}),(0,X.jsxs)(Re,{children:[(0,X.jsx)(M,{type:`button`,variant:`outline`,className:`min-h-11`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(M,{type:`submit`,variant:`primary`,className:`min-h-11`,"data-action":`create-branch`,disabled:!u||d!==null||a,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=s(),a=new Map((n.data?.branches??[]).map(e=>[e.name,e])),o=n.data?.base??e.baseBranch??t.branch,c=lt(i(),e=>b(e.message,{tone:`danger`})),l=G(i()),[u,d]=(0,Y.useState)(``),f=u.trim().toLowerCase(),p=Gt(e,n.data?.branches),m=f?p.filter(e=>e.toLowerCase().includes(f)):p;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,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 size-4 text-muted-foreground`}),(0,X.jsx)(bt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:u,onChange:e=>d(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 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:[m.map(e=>{let n=e===t.branch,i=a.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(P,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:r(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:o}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(M,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:l,onClick:()=>c.mutate(e),children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),m.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,u.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:ae,className:`border-success/40 text-semantic-green`},draft:{icon:A,className:`border-border text-muted-foreground`},merged:{icon:se,className:`border-merged-strong/35 text-merged-text`},closed:{icon:ce,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],i=(0,X.jsxs)(`span`,{className:r(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),o=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:r(o,`group focus-visible:outline-2 focus-visible:outline-ring`),children:i}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:o,children:i})}function Ht({checks:e}){let t=e===`passing`?Ce:e===`failing`?we:xt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:r(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:r(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,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:Ut[e.class]})}function Gt(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 Kt(){let e=g(),t=F(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof _&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>De(f),[f]),m=(0,Y.useMemo)(()=>f.some(St),[f]),h=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(be,{size:16}):(0,X.jsx)(me,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(be,{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)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(Oe,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[m&&o?(0,X.jsx)(je,{}):null,m?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(Ae,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Ne,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:m&&o}),(0,X.jsx)(Me,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:m?s:void 0,disabled:m&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ee,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:h,wrap:i,preview:o,loadFileText:e=>Et(()=>v(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=E(),r=F(),i=e.log,a=(0,Y.useMemo)(()=>vt(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=gt(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(oe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:r(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(P,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:tt(e.when,e.at),children:dt(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=r(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(P,{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:r(n,`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)(se,{"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)(pe,{"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:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=it(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"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:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] 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)(ke,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ve,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(ht,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:u(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>C(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:u(e),sha:e,backTo:ct,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>C(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(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 tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=s(),t=m(),n=i(),r=p(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(me,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),l=c.reduce((e,t)=>e+t.rows.length,0),u=tn(e.data.branches),d=u>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[u,` finished task`,u===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,u===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(P,{to:z.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,f=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(re,{projectId:n,repoBase:r,requests:c.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-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),d,c.length===0?(0,X.jsx)(Ze,{icon:(0,X.jsx)(yt,{size:16}),title:u>0?`Nothing else waiting to land`:`Everything landed`,description:u>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.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:z.cleanup,children:`Check cleanup`})}),(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?f.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-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),l<=3?(0,X.jsx)(Ye,{summary:`${l} ${l===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:z.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:a,onClose:()=>o(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:r(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({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-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({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-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(k,{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)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=S(),i=e.class===`orphan`,a=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!i&&e.runId!==null&&!a,s=h({mutationFn:()=>x(e.runId),onSuccess:e=>{b(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:f.repoBranches}),n.invalidateQueries({queryKey:f.runs.all})},onError:e=>b(e instanceof _&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{b(`Copied ${e.name}`),u.current!==null&&clearTimeout(u.current),l(!0),u.current=setTimeout(()=>l(!1),2e3)},()=>b(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] 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)(P,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:r(p,`hidden border border-border bg-card 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:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,i?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:d,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,X.jsx)(_e,{"aria-hidden":`true`}):(0,X.jsx)(xe,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Le,{children:[(0,X.jsx)(Fe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm 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)(ue,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(N,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(P,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(N,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(N,{className:r(!i&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Pe,{className:`md:hidden`}),(0,X.jsx)(N,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Qe(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;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)(Te,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ge,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium 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] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(P,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=c(D(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=h({mutationFn:e=>y({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;b(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:f.repo}),s()},onError:e=>b(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(J,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(H,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(q,{children:[(0,X.jsxs)(V,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(B,{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:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(at,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&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)(bt,{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)(W,{children:[(0,X.jsx)(K,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(U,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=s(),n=S(),[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],d=h({mutationFn:e=>y({names:e}),onSuccess:e=>{let t=e.refused.length;b(`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:f.repo})},onError:e=>{n.invalidateQueries({queryKey:f.repo}),b(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-xs 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||d.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)(ye,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{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)(J,{open:a,onOpenChange:o,children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsxs)(V,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(B,{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)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsxs)(U,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:i,open:a,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":a,"aria-controls":s,disabled:i.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,` · `,i.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),i.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:r(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}):null]}),a?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:i.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-xs`,children:[(0,X.jsx)(nt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(P,{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)(pt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${O(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?O(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${O(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(B,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${O(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsx)(U,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(J,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(B,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${O(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsx)(U,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(J,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(B,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep it`}),(0,X.jsx)(U,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=o(),t=d().data?.targets.find(e=>e.id===`finder`),n=h({mutationFn:e=>ne(e,t.id),onError:e=>b(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),p=()=>Promise.all([r.invalidateQueries({queryKey:f.worktrees}),r.invalidateQueries({queryKey:f.repoBranches})]),m=h({mutationFn:({runIds:e})=>ee(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{p(),b(gn(e.reclaimed.length,t,!!n))},onError:e=>b(e.message,{tone:`danger`})}),g=h({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{p(),b(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{p(),b(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:_,totalBytes:v,keep:y}=e.data,x=m.isPending||g.isPending,C=_.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),E=w.length>0,D=$(w),re=$(C),k=_n(w.length,D),ie=vn(C.length,re,E),A=v?O(v):null,ae=bn(y);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`,A?` · ${A}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[ae.prefix,(0,X.jsx)(P,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:et(`worktrees`,` › `)}),ae.suffix,` `,`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:x||!E,title:yn(E,T.length),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)(L,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:x,onDiscard:()=>c(C)}):null,_.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:_.map(e=>(0,X.jsx)(En,{worktree:e,keep:y,disabled:x,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?u(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:w.length,cleanBytes:D,reclaimLabel:k,onConfirmClean:()=>{m.mutate({expected:w.length}),a(!1)},discardBatch:s,onCloseDiscardBatch:()=>c(null),onConfirmDiscardBatch:e=>{m.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:l,onCloseRow:()=>u(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:i,opening:a,onReclaim:o}){let s=Tn(e,t),c=Qe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${$e(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:r(`text-xs`,u),children:s.label}),p=`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`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;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-xs 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-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:O(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),i?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:a,onClick:i,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:r(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=l(),r=F(),[i]=T(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(ut,{});if(n.isError)return(0,X.jsx)(Xe,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(R,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(me,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(Xe,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(R,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(ge,{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 kn({repo:e,info:t,section:n}){let r=Dn(n),i=s(),a=An(n),o=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Xe,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Je(o),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(R,{}),header:{title:a?.title??ot(n,t.branch),headerSlot:`repo-header`,subtitle:a?(0,X.jsxs)(X.Fragment,{children:[`Commit `,a.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=E(),n=F(),r=e===`main`&&!n?t:void 0,i=u(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({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?` · ${_t(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)(Mn,{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 Mn({repo:e,info:t}){let n=Gt(e,s().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On 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{o as r,p as i,s as a}from"./dist-C_rn70hE.js";import{A as o,C as s,Kt as c,S as l,T as u,U as d,Ut as f,bt as p,nt as m,un as h,w as g}from"./queries-CchoEEzj.js";import{B as ee,Rn as _,T as v,f as y,n as b,ut as x,vi as S,w as C,z as te,zt as ne}from"./toaster-zMN8cNZQ.js";import{Z as w}from"./live-protocol-DMhTnCmf.js";import{g as T,h as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{c as D,f as O,i as re,t as k}from"./reference-chip-z7dZJVH-.js";import{D as ie,F as A,I as ae,M as oe,N as se,P as ce,Q as le,S as ue,X as de,Z as fe,c as pe,ct as me,d as he,j as ge,l as _e,n as ve,st as ye,w as be,y as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./createLucideIcon-BHp8sXmF.js";import{n as Ce,t as we}from"./circle-x-7nTlobAF.js";import{_ as Te}from"./nav-row-styles-CgP5uNp4.js";import{i as Ee,r as De,t as Oe}from"./git-toolbar-Bjvqzoo_.js";import{t as j}from"./info-DA1x_4bz.js";import{t as ke}from"./loader-circle-CPBhhDbB.js";import{a as Ae,i as je,n as Me,r as Ne}from"./diff-controls-DHvk5BOR.js";import{t as M}from"./button-C8jUIs8Q.js";import{i as N,l as Pe,p as Fe,r as Ie,t as Le}from"./dropdown-menu-DjtKUK8F.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./dialog-DRZuXvul.js";import{t as P}from"./project-router-j0uBi7Ep.js";import{t as Ge}from"./status-dot-BXf-Ubd0.js";import{c as Ke,d as qe,f as Je,m as F,n as Ye,s as Xe,t as Ze}from"./page-shell-Dky5crRl.js";import{a as Qe,o as $e}from"./format-BU7D3IfE.js";import{t as et}from"./control-locations-kCPVEtOM.js";import{t as I}from"./centered-state-BgSV4e79.js";import{$t as tt,Bn as nt,Bt as rt,Cr as L,Gt as it,Hn as at,Ht as ot,In as st,Jt as ct,Kt as lt,M as ut,N as R,Qt as dt,Ut as ft,Vn as pt,Vt as mt,Wt as ht,Xt as gt,Yt as z,Zt as _t,an as B,cn as V,en as vt,in as H,mr as yt,nn as U,on as W,qt as G,rn as K,sn as q,sr as bt,tn as J,xr as xt}from"./index-TOx-AA67.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-ZyKzQmlr.js";import{t as wt}from"./change-counts-wqSYI3W8.js";import{t as Tt}from"./code-workbench-CUkiQ1pF.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-FjUd56tK.js";var Y=e(t(),1);function At(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=Se(`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`}]]),Mt=Se(`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=i(),t=l(),n=S(),a=At({queryKey:f.repo})>0,o=t.data?.info?t.data:null,s=rt(e,o,`screen`);return(0,X.jsx)(qe,{route:`repo-git`,density:o?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ke,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:a,onClick:()=>{n.invalidateQueries({queryKey:f.repo}),n.invalidateQueries({queryKey:f.worktrees})},children:(0,X.jsx)(fe,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,a&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(ft,{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)(mt,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ke,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:G(i())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(de,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=lt(i()),a=G(i()),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=o.trim(),d=Pt(u),f=d??c;return(0,X.jsx)(We,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(He,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!u||d||a)&&(l(null),r.mutate(u,{onSuccess:n,onError:e=>l(e.message)}))},children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Ue,{children:`New branch`}),(0,X.jsxs)(ze,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(Be,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(bt,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:o,"aria-invalid":f?!0:void 0,"aria-describedby":f?`new-branch-name-hint`:void 0,onChange:e=>{s(e.target.value),l(null)}}),f?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":d?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:f}):null]}),(0,X.jsxs)(Re,{children:[(0,X.jsx)(M,{type:`button`,variant:`outline`,className:`min-h-11`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(M,{type:`submit`,variant:`primary`,className:`min-h-11`,"data-action":`create-branch`,disabled:!u||d!==null||a,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=s(),a=new Map((n.data?.branches??[]).map(e=>[e.name,e])),o=n.data?.base??e.baseBranch??t.branch,c=lt(i(),e=>b(e.message,{tone:`danger`})),l=G(i()),[u,d]=(0,Y.useState)(``),f=u.trim().toLowerCase(),p=Gt(e,n.data?.branches),m=f?p.filter(e=>e.toLowerCase().includes(f)):p;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,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 size-4 text-muted-foreground`}),(0,X.jsx)(bt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:u,onChange:e=>d(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 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:[m.map(e=>{let n=e===t.branch,i=a.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(P,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:r(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:o}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(M,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:l,onClick:()=>c.mutate(e),children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),m.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,u.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:ae,className:`border-success/40 text-semantic-green`},draft:{icon:A,className:`border-border text-muted-foreground`},merged:{icon:se,className:`border-merged-strong/35 text-merged-text`},closed:{icon:ce,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],i=(0,X.jsxs)(`span`,{className:r(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),o=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:r(o,`group focus-visible:outline-2 focus-visible:outline-ring`),children:i}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:o,children:i})}function Ht({checks:e}){let t=e===`passing`?Ce:e===`failing`?we:xt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:r(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:r(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,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:Ut[e.class]})}function Gt(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 Kt(){let e=g(),t=F(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof _&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>De(f),[f]),m=(0,Y.useMemo)(()=>f.some(St),[f]),h=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(be,{size:16}):(0,X.jsx)(me,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(be,{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)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(Oe,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[m&&o?(0,X.jsx)(je,{}):null,m?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(Ae,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Ne,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:m&&o}),(0,X.jsx)(Me,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:m?s:void 0,disabled:m&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ee,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:h,wrap:i,preview:o,loadFileText:e=>Et(()=>v(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=E(),r=F(),i=e.log,a=(0,Y.useMemo)(()=>vt(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=gt(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(oe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:r(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(P,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:tt(e.when,e.at),children:dt(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=r(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(P,{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:r(n,`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)(se,{"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)(pe,{"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:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=it(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"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:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] 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)(ke,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ve,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(ht,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:u(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>C(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:u(e),sha:e,backTo:ct,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>C(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(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 tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=s(),t=m(),n=i(),r=p(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(me,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),l=c.reduce((e,t)=>e+t.rows.length,0),u=tn(e.data.branches),d=u>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[u,` finished task`,u===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,u===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(P,{to:z.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,f=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(re,{projectId:n,repoBase:r,requests:c.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-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),d,c.length===0?(0,X.jsx)(Ze,{icon:(0,X.jsx)(yt,{size:16}),title:u>0?`Nothing else waiting to land`:`Everything landed`,description:u>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.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:z.cleanup,children:`Check cleanup`})}),(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?f.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-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),l<=3?(0,X.jsx)(Ye,{summary:`${l} ${l===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(P,{to:z.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:a,onClose:()=>o(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:r(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({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-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({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-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(k,{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)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=S(),i=e.class===`orphan`,a=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!i&&e.runId!==null&&!a,s=h({mutationFn:()=>x(e.runId),onSuccess:e=>{b(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:f.repoBranches}),n.invalidateQueries({queryKey:f.runs.all})},onError:e=>b(e instanceof _&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{b(`Copied ${e.name}`),u.current!==null&&clearTimeout(u.current),l(!0),u.current=setTimeout(()=>l(!1),2e3)},()=>b(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] 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)(P,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:r(p,`hidden border border-border bg-card 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:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,i?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:d,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,X.jsx)(_e,{"aria-hidden":`true`}):(0,X.jsx)(xe,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Le,{children:[(0,X.jsx)(Fe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm 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)(ue,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(N,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(P,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(N,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(N,{className:r(!i&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Pe,{className:`md:hidden`}),(0,X.jsx)(N,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Qe(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;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)(Te,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ge,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium 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] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(P,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=c(D(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=h({mutationFn:e=>y({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;b(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:f.repo}),s()},onError:e=>b(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(J,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(H,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(q,{children:[(0,X.jsxs)(V,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(B,{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:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(at,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&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)(bt,{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)(W,{children:[(0,X.jsx)(K,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(U,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=s(),n=S(),[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],d=h({mutationFn:e=>y({names:e}),onSuccess:e=>{let t=e.refused.length;b(`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:f.repo})},onError:e=>{n.invalidateQueries({queryKey:f.repo}),b(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-xs 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||d.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)(ye,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{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)(J,{open:a,onOpenChange:o,children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsxs)(V,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(B,{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)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsxs)(U,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:i,open:a,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":a,"aria-controls":s,disabled:i.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,` · `,i.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),i.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:r(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}):null]}),a?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:i.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-xs`,children:[(0,X.jsx)(nt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(P,{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)(pt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${O(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?O(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${O(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(B,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${O(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsx)(U,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(J,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(B,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${O(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep them`}),(0,X.jsx)(U,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(J,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(H,{children:[(0,X.jsxs)(q,{children:[(0,X.jsx)(V,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(B,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(K,{children:`Keep it`}),(0,X.jsx)(U,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=o(),t=d().data?.targets.find(e=>e.id===`finder`),n=h({mutationFn:e=>ne(e,t.id),onError:e=>b(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),p=()=>Promise.all([r.invalidateQueries({queryKey:f.worktrees}),r.invalidateQueries({queryKey:f.repoBranches})]),m=h({mutationFn:({runIds:e})=>ee(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{p(),b(gn(e.reclaimed.length,t,!!n))},onError:e=>b(e.message,{tone:`danger`})}),g=h({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{p(),b(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{p(),b(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:_,totalBytes:v,keep:y}=e.data,x=m.isPending||g.isPending,C=_.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),E=w.length>0,D=$(w),re=$(C),k=_n(w.length,D),ie=vn(C.length,re,E),A=v?O(v):null,ae=bn(y);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`,A?` · ${A}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[ae.prefix,(0,X.jsx)(P,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:et(`worktrees`,` › `)}),ae.suffix,` `,`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:x||!E,title:yn(E,T.length),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)(L,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:x,onDiscard:()=>c(C)}):null,_.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:_.map(e=>(0,X.jsx)(En,{worktree:e,keep:y,disabled:x,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?u(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:w.length,cleanBytes:D,reclaimLabel:k,onConfirmClean:()=>{m.mutate({expected:w.length}),a(!1)},discardBatch:s,onCloseDiscardBatch:()=>c(null),onConfirmDiscardBatch:e=>{m.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:l,onCloseRow:()=>u(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:i,opening:a,onReclaim:o}){let s=Tn(e,t),c=Qe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${$e(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:r(`text-xs`,u),children:s.label}),p=`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`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;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-xs 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-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:O(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),i?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:a,onClick:i,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:r(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=l(),r=F(),[i]=T(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(ut,{});if(n.isError)return(0,X.jsx)(Xe,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(R,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(me,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(Xe,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(R,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(ge,{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 kn({repo:e,info:t,section:n}){let r=Dn(n),i=s(),a=An(n),o=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Xe,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Je(o),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(R,{}),header:{title:a?.title??ot(n,t.branch),headerSlot:`repo-header`,subtitle:a?(0,X.jsxs)(X.Fragment,{children:[`Commit `,a.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=E(),n=F(),r=e===`main`&&!n?t:void 0,i=u(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({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?` · ${_t(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)(Mn,{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 Mn({repo:e,info:t}){let n=Gt(e,s().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On 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{M as r,z as i}from"./queries-CchoEEzj.js";import{Rn as a,it as o}from"./toaster-zMN8cNZQ.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{ct as p,r as m}from"./design-icons-QbNMZniQ.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-BwrymAy7.js";import{t as b}from"./button-C8jUIs8Q.js";import{t as x}from"./centered-state-BgSV4e79.js";import{r as S}from"./html-report-BX3msvci.js";import{Vn as C,b as w,v as T,y as E}from"./index-CXvWnyZg.js";import{t as D}from"./html-report-frame-Ck76gKfA.js";var O=e(t(),1),k=n();function A(){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=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){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 P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=w(T,!0),p=w(E,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.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,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.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,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(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 L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=i(e,o||s||c?null:a),u=r(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!S(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.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,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(C,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.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:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.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,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!S(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.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,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.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,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P 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{M as r,z as i}from"./queries-CchoEEzj.js";import{Rn as a,it as o}from"./toaster-zMN8cNZQ.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{ct as p,r as m}from"./design-icons-QbNMZniQ.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-DbDhvIx2.js";import{t as b}from"./button-C8jUIs8Q.js";import{t as x}from"./centered-state-BgSV4e79.js";import{r as S}from"./html-report-BX3msvci.js";import{Vn as C,b as w,v as T,y as E}from"./index-TOx-AA67.js";import{t as D}from"./html-report-frame-Ck76gKfA.js";var O=e(t(),1),k=n();function A(){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=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){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 P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=w(T,!0),p=w(E,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.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,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.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,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(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 L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=i(e,o||s||c?null:a),u=r(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!S(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.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,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(C,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.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:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.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,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!S(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.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,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.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,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P 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{o as r,p as i}from"./dist-C_rn70hE.js";import{Lt as a,M as o,st as s}from"./queries-CchoEEzj.js";import{Bn as c,Cr as l,Gr as u,Hn as d,gi as f,oi as p,qr as m,vi as h,zn as g}from"./toaster-zMN8cNZQ.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Q as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./arrow-up-right-DKGzsMqY.js";import{t as k}from"./chevron-right-BENZ-1ZN.js";import{t as A}from"./eye-B8okNWXU.js";import{t as j}from"./button-C8jUIs8Q.js";import{t as M}from"./project-router-j0uBi7Ep.js";import{f as N,i as ee,n as te,r as ne,t as P,u as F}from"./page-shell-Dky5crRl.js";import{t as I}from"./use-search-params-writer-ClMScnNe.js";import{Dn as L,Vn as R,gr as z,sr as B}from"./index-CXvWnyZg.js";import{t as V}from"./report-title-D4Mbu2Er.js";import{t as H}from"./html-report-frame-Ck76gKfA.js";var U=e(t(),1),W=1e3,G=S().min(1).max(1024);_({q:S().max(W).optional(),before:G.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var K=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:l}).strict()),nextCursor:G.nullable(),total:w().int().nonnegative()}).strict(),q=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),J=_({runId:b(),taskTitle:S(),taskStatus:l}).strict(),Y=v(`type`,[q.extend({type:y(`snapshot`)}),q.extend({type:y(`content`)}),q.extend({type:y(`metadata`),runs:x(J)})]),X=new WeakMap;function re(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 ie=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=re(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 ae(e,t){let n=X.get(e);n||(n=new Map,X.set(e,n));let r=n.get(t);return r||(r=new ie(e,t),n.set(t,r)),r}async function oe(e,t){let n=await g.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},c({signal:t}));return q.parse(await d(n,`/reports/state`))}function se(e){let t=ae(h(),e);return(0,U.useEffect)(()=>{let n=a(`reports:project:${e}`,e=>{let n=Y.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,o=()=>{if(u()===`finite`&&!r){i=new AbortController;let n=i.signal;oe(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=q.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else u()!==`finite`&&(i?.abort(),r?.(),r=void 0)};o();let c=m(o);return()=>{c(),i?.abort(),r?.(),n()}},[t,e]),t}async function ce(e,t,n,r){let i=await g.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,W),...n?{before:n}:{}}},c(r?{signal:r}:void 0));return K.parse(await d(i,`/reports`))}function Z(e){let t=i(),n=se(t);return p({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>ce(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Q=n(),$=new Map;function le(){let e=T(),t=E(),[n,i]=I(),a=(n.get(`q`)??``).slice(0,W),o=Z(a),s=(0,U.useRef)(null),c=(0,U.useRef)(null),l=(0,U.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{$.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,U.useState)(null),h=ee(s);(0,U.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=$.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>i(n=>(t?n.set(`q`,t.slice(0,W)):n.delete(`q`),$.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:N(d.length);return(0,Q.jsx)(F,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Q.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Q.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(B,{maxLength:W,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(P,{icon:(0,Q.jsx)(z,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Q.jsxs)(Q.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Q.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[L(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Q.jsx)(j,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Q.jsx)(M,{to:`/new`,children:`Start a task`})})})}):(0,Q.jsx)(ne,{list:(0,Q.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Q.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:r(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Q.jsx)(z,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Q.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:V(e),children:(0,Q.jsx)(M,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:V(e)})})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Q.jsx)(M,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Q.jsx)(R,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${V(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Q.jsx)(k,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Q.jsx)(te,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Q.jsx)(ue,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function ue({report:e,restoreKey:t,onOpenReader:n}){let r=(0,U.useContext)(f)!==void 0;return(0,Q.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${V(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:V(e)}),(0,Q.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Q.jsx)(R,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Q.jsxs)(M,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Q.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Q.jsx)(de,{report:e}):(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function de({report:e}){let t=o(e.runId,e.id);if(t.isPending)return(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Q.jsx)(`p`,{children:t.error.message}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Q.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Q.jsx)(H,{html:n.content,title:V(e),className:`min-h-0 flex-1`})}export{le 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{o as r,p as i}from"./dist-C_rn70hE.js";import{Lt as a,M as o,st as s}from"./queries-CchoEEzj.js";import{Bn as c,Cr as l,Gr as u,Hn as d,gi as f,oi as p,qr as m,vi as h,zn as g}from"./toaster-zMN8cNZQ.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Q as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./arrow-up-right-DKGzsMqY.js";import{t as k}from"./chevron-right-BENZ-1ZN.js";import{t as A}from"./eye-B8okNWXU.js";import{t as j}from"./button-C8jUIs8Q.js";import{t as M}from"./project-router-j0uBi7Ep.js";import{f as N,i as ee,n as te,r as ne,t as P,u as F}from"./page-shell-Dky5crRl.js";import{t as I}from"./use-search-params-writer-ClMScnNe.js";import{Dn as L,Vn as R,gr as z,sr as B}from"./index-TOx-AA67.js";import{t as V}from"./report-title-D4Mbu2Er.js";import{t as H}from"./html-report-frame-Ck76gKfA.js";var U=e(t(),1),W=1e3,G=S().min(1).max(1024);_({q:S().max(W).optional(),before:G.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var K=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:l}).strict()),nextCursor:G.nullable(),total:w().int().nonnegative()}).strict(),q=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),J=_({runId:b(),taskTitle:S(),taskStatus:l}).strict(),Y=v(`type`,[q.extend({type:y(`snapshot`)}),q.extend({type:y(`content`)}),q.extend({type:y(`metadata`),runs:x(J)})]),X=new WeakMap;function re(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 ie=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=re(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 ae(e,t){let n=X.get(e);n||(n=new Map,X.set(e,n));let r=n.get(t);return r||(r=new ie(e,t),n.set(t,r)),r}async function oe(e,t){let n=await g.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},c({signal:t}));return q.parse(await d(n,`/reports/state`))}function se(e){let t=ae(h(),e);return(0,U.useEffect)(()=>{let n=a(`reports:project:${e}`,e=>{let n=Y.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,o=()=>{if(u()===`finite`&&!r){i=new AbortController;let n=i.signal;oe(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=q.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else u()!==`finite`&&(i?.abort(),r?.(),r=void 0)};o();let c=m(o);return()=>{c(),i?.abort(),r?.(),n()}},[t,e]),t}async function ce(e,t,n,r){let i=await g.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,W),...n?{before:n}:{}}},c(r?{signal:r}:void 0));return K.parse(await d(i,`/reports`))}function Z(e){let t=i(),n=se(t);return p({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>ce(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Q=n(),$=new Map;function le(){let e=T(),t=E(),[n,i]=I(),a=(n.get(`q`)??``).slice(0,W),o=Z(a),s=(0,U.useRef)(null),c=(0,U.useRef)(null),l=(0,U.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{$.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,U.useState)(null),h=ee(s);(0,U.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=$.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>i(n=>(t?n.set(`q`,t.slice(0,W)):n.delete(`q`),$.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:N(d.length);return(0,Q.jsx)(F,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Q.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Q.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(B,{maxLength:W,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Q.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(P,{icon:(0,Q.jsx)(z,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Q.jsxs)(Q.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Q.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[L(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Q.jsx)(j,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Q.jsx)(M,{to:`/new`,children:`Start a task`})})})}):(0,Q.jsx)(ne,{list:(0,Q.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Q.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:r(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Q.jsx)(z,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Q.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:V(e),children:(0,Q.jsx)(M,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:V(e)})})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Q.jsx)(M,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Q.jsx)(R,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${V(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Q.jsx)(k,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(j,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Q.jsx)(te,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Q.jsx)(ue,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function ue({report:e,restoreKey:t,onOpenReader:n}){let r=(0,U.useContext)(f)!==void 0;return(0,Q.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${V(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:V(e)}),(0,Q.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Q.jsx)(R,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Q.jsxs)(M,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Q.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Q.jsx)(de,{report:e}):(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function de({report:e}){let t=o(e.runId,e.id);if(t.isPending)return(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Q.jsx)(`p`,{children:t.error.message}),(0,Q.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Q.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Q.jsx)(H,{html:n.content,title:V(e),className:`min-h-0 flex-1`})}export{le as ReportsRoute};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Ft as t}from"./queries-CchoEEzj.js";import{n}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{A as r}from"./design-icons-QbNMZniQ.js";import{t as i}from"./switch-CAKeV99j.js";import{t as a}from"./centered-state-BgSV4e79.js";import{t as o}from"./option-select-BxFrlK_-.js";import{n as s}from"./save-cue-CpHgT93o.js";import{n as c,t as l}from"./settings-field-Bhh8I9fJ.js";import{t as u}from"./use-workspace-config-save-9jm9qV6u.js";import{r as d}from"./settings-save-bar-9D1QPg_P.js";import{n as f}from"./saved-draft-BwzBc-_Y.js";var p=e(),m=1,h=16,g=16,_=1,v=60,y=5,b=256;function x(){let e=t();return e.isPending?(0,p.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,p.jsx)(a,{icon:(0,p.jsx)(r,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,p.jsx)(S,{config:e.data})}function S({config:e}){let t=u(),n=s(),r=s(),a=s(),o=s(),l=s(),m=(e,n)=>t.mutate(e,{onSuccess:n}),h=e.resources.monitoringWakeIntervalMinutes??null,g=h===null?`park`:`interval`,[x,S]=f(String(h??y)),D=Number(x),O=!Number.isInteger(D)||D<_||D>v,k=g===`interval`&&O,j=e=>m({resources:{monitoringWakeIntervalMinutes:e===`park`?null:y}},()=>{S(String(y)),a.flash()});d({dirty:h!==null&&x!==String(h),invalid:O,busy:t.isPending,save:()=>t.mutateAsync({resources:{monitoringWakeIntervalMinutes:D}}),discard:()=>S(String(h??y))});let M=e.resources.autoResumeOnUsageLimit??!0,N=e=>m({resources:{autoResumeOnUsageLimit:e}},o.flash),P=e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``,[F,I]=f(P),L=F.trim()===``?0:Number(F),R=F.trim()!==``&&(!Number.isInteger(L)||L<b);d({dirty:(e.resources.memoryLimitMb??0)!==(R?-1:L),invalid:R,busy:t.isPending,save:()=>t.mutateAsync({resources:{memoryLimitMb:L===0?null:L}}),discard:()=>I(P)});let z=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0};return(0,p.jsxs)(`div`,{"data-slot":`resources-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,p.jsx)(C,{maxParallel:e.resources.maxParallel,onSelect:e=>m({resources:{maxParallel:e}},n.flash),disabled:t.isPending,saved:n.saved}),(0,p.jsx)(w,{maxParallel:e.resources.maxParallel,maxMonitoringSessions:e.resources.maxMonitoringSessions,onSelect:e=>m({resources:{maxMonitoringSessions:e}},r.flash),disabled:t.isPending,saved:r.saved}),(0,p.jsx)(T,{wakeMode:g,setWakeMode:j,wakeInterval:x,setWakeInterval:S,showInvalid:k,saved:a.saved,saveIsPending:t.isPending}),(0,p.jsx)(c,{title:`Auto-resume after a usage limit`,hint:`Resumes eligible tasks at the reset time the provider reports. Saves automatically.`,saved:o.saved,children:(0,p.jsx)(i,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:M,disabled:t.isPending,onCheckedChange:N})}),(0,p.jsx)(E,{memory:F,setMemory:I,memoryInvalid:R,saveIsPending:t.isPending}),(0,p.jsx)(A,{composerDefaults:z,saveComposerDefault:(e,t)=>m({composerDefaults:{[e]:t===`inherit`?null:t===`on`}},l.flash),saveIsPending:t.isPending,saved:l.saved})]})}function C({maxParallel:e,onSelect:t,disabled:r,saved:i}){return(0,p.jsxs)(c,{title:`Max parallel tasks`,hint:`Limits how many tasks run at once. Saves automatically.`,saved:i,children:[(0,p.jsx)(o,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e,disabled:r,onValueChange:e=>t(Number(e)),className:`settings-select w-28 max-w-full bg-card`,options:O(m,h)}),(0,p.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need a different limit for one project?`,` `,(0,p.jsx)(n,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:`Configure per-project limits`}),`.`]})]})}function w({maxParallel:e,maxMonitoringSessions:t,onSelect:n,disabled:r,saved:i}){return(0,p.jsxs)(c,{title:`Extra monitoring sessions`,hint:`Extra slots reserved for monitoring sessions. Saves automatically.`,saved:i,children:[(0,p.jsx)(o,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:t??2,disabled:r,onValueChange:e=>n(Number(e)),className:`settings-select w-28 max-w-full bg-card`,options:O(0,g)}),(0,p.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Capacity: `,e,` active + `,t??2,` monitoring. 0 shares the active slots.`]})]})}function T({wakeMode:e,setWakeMode:t,wakeInterval:n,setWakeInterval:r,showInvalid:a,saved:o,saveIsPending:s}){return(0,p.jsxs)(c,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,saved:o,children:[(0,p.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(i,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:e===`interval`,disabled:s,onCheckedChange:e=>t(e?`interval`:`park`)}),e===`interval`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full ${l}`,children:`Wake interval`}),(0,p.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:_,max:v,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:n,disabled:s,onChange:e=>r(e.target.value),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`minutes`})]}):null]}),a?(0,p.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-xs text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):null]})}function E({memory:e,setMemory:t,memoryInvalid:n,saveIsPending:r}){return(0,p.jsxs)(c,{title:`Per-task memory limit`,hint:`Applies to newly started tasks. Leave blank for no limit.`,children:[(0,p.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:b,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:e,disabled:r,placeholder:`no limit`,onChange:e=>t(e.target.value),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`MiB`})]}),n?(0,p.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number of at least `,b,` MiB, or leave empty for no limit.`]}):null]})}var D=[{value:`inherit`,label:`Inherit environment`},{value:`on`,label:`On`},{value:`off`,label:`Off`}];function O(e,t){return Array.from({length:t-e+1},(t,n)=>({value:String(e+n),label:String(e+n)}))}function k(e){return e===null?`inherit`:e?`on`:`off`}function A({composerDefaults:e,saveComposerDefault:t,saveIsPending:n,saved:r}){return(0,p.jsxs)(c,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,saved:r,children:[(0,p.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,p.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,p.jsx)(`span`,{className:l,children:`Autonomous by default`}),(0,p.jsx)(o,{"aria-label":`Autonomous by default`,value:k(e.autonomous),disabled:n,onValueChange:e=>t(`autonomous`,e),className:`settings-select max-w-full bg-card`,options:D}),(0,p.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:e.inheritedAutonomous?`On`:`Off`]})]}),(0,p.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,p.jsx)(`span`,{className:l,children:`Use a worktree by default`}),(0,p.jsx)(o,{"aria-label":`Use a worktree by default`,value:k(e.worktree),disabled:n,onValueChange:e=>t(`worktree`,e),className:`settings-select max-w-full bg-card`,options:D}),(0,p.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedWorktree?`On`:`Off`]})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated. Saves automatically.`})]})}export{x as ResourcesSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Ft as t}from"./queries-CchoEEzj.js";import{n}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{A as r}from"./design-icons-QbNMZniQ.js";import{t as i}from"./switch-CAKeV99j.js";import{t as a}from"./centered-state-BgSV4e79.js";import{t as o}from"./option-select-BUpASY9Q.js";import{n as s}from"./save-cue-CpHgT93o.js";import{n as c,t as l}from"./settings-field-Bhh8I9fJ.js";import{t as u}from"./use-workspace-config-save-9jm9qV6u.js";import{r as d}from"./settings-save-bar-DmONROMw.js";import{n as f}from"./saved-draft-BwzBc-_Y.js";var p=e(),m=1,h=16,g=16,_=1,v=60,y=5,b=256;function x(){let e=t();return e.isPending?(0,p.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,p.jsx)(a,{icon:(0,p.jsx)(r,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,p.jsx)(S,{config:e.data})}function S({config:e}){let t=u(),n=s(),r=s(),a=s(),o=s(),l=s(),m=(e,n)=>t.mutate(e,{onSuccess:n}),h=e.resources.monitoringWakeIntervalMinutes??null,g=h===null?`park`:`interval`,[x,S]=f(String(h??y)),D=Number(x),O=!Number.isInteger(D)||D<_||D>v,k=g===`interval`&&O,j=e=>m({resources:{monitoringWakeIntervalMinutes:e===`park`?null:y}},()=>{S(String(y)),a.flash()});d({dirty:h!==null&&x!==String(h),invalid:O,busy:t.isPending,save:()=>t.mutateAsync({resources:{monitoringWakeIntervalMinutes:D}}),discard:()=>S(String(h??y))});let M=e.resources.autoResumeOnUsageLimit??!0,N=e=>m({resources:{autoResumeOnUsageLimit:e}},o.flash),P=e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``,[F,I]=f(P),L=F.trim()===``?0:Number(F),R=F.trim()!==``&&(!Number.isInteger(L)||L<b);d({dirty:(e.resources.memoryLimitMb??0)!==(R?-1:L),invalid:R,busy:t.isPending,save:()=>t.mutateAsync({resources:{memoryLimitMb:L===0?null:L}}),discard:()=>I(P)});let z=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0};return(0,p.jsxs)(`div`,{"data-slot":`resources-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,p.jsx)(C,{maxParallel:e.resources.maxParallel,onSelect:e=>m({resources:{maxParallel:e}},n.flash),disabled:t.isPending,saved:n.saved}),(0,p.jsx)(w,{maxParallel:e.resources.maxParallel,maxMonitoringSessions:e.resources.maxMonitoringSessions,onSelect:e=>m({resources:{maxMonitoringSessions:e}},r.flash),disabled:t.isPending,saved:r.saved}),(0,p.jsx)(T,{wakeMode:g,setWakeMode:j,wakeInterval:x,setWakeInterval:S,showInvalid:k,saved:a.saved,saveIsPending:t.isPending}),(0,p.jsx)(c,{title:`Auto-resume after a usage limit`,hint:`Resumes eligible tasks at the reset time the provider reports. Saves automatically.`,saved:o.saved,children:(0,p.jsx)(i,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:M,disabled:t.isPending,onCheckedChange:N})}),(0,p.jsx)(E,{memory:F,setMemory:I,memoryInvalid:R,saveIsPending:t.isPending}),(0,p.jsx)(A,{composerDefaults:z,saveComposerDefault:(e,t)=>m({composerDefaults:{[e]:t===`inherit`?null:t===`on`}},l.flash),saveIsPending:t.isPending,saved:l.saved})]})}function C({maxParallel:e,onSelect:t,disabled:r,saved:i}){return(0,p.jsxs)(c,{title:`Max parallel tasks`,hint:`Limits how many tasks run at once. Saves automatically.`,saved:i,children:[(0,p.jsx)(o,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e,disabled:r,onValueChange:e=>t(Number(e)),className:`settings-select w-28 max-w-full bg-card`,options:O(m,h)}),(0,p.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need a different limit for one project?`,` `,(0,p.jsx)(n,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:`Configure per-project limits`}),`.`]})]})}function w({maxParallel:e,maxMonitoringSessions:t,onSelect:n,disabled:r,saved:i}){return(0,p.jsxs)(c,{title:`Extra monitoring sessions`,hint:`Extra slots reserved for monitoring sessions. Saves automatically.`,saved:i,children:[(0,p.jsx)(o,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:t??2,disabled:r,onValueChange:e=>n(Number(e)),className:`settings-select w-28 max-w-full bg-card`,options:O(0,g)}),(0,p.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Capacity: `,e,` active + `,t??2,` monitoring. 0 shares the active slots.`]})]})}function T({wakeMode:e,setWakeMode:t,wakeInterval:n,setWakeInterval:r,showInvalid:a,saved:o,saveIsPending:s}){return(0,p.jsxs)(c,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,saved:o,children:[(0,p.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(i,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:e===`interval`,disabled:s,onCheckedChange:e=>t(e?`interval`:`park`)}),e===`interval`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full ${l}`,children:`Wake interval`}),(0,p.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:_,max:v,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:n,disabled:s,onChange:e=>r(e.target.value),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`minutes`})]}):null]}),a?(0,p.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-xs text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):null]})}function E({memory:e,setMemory:t,memoryInvalid:n,saveIsPending:r}){return(0,p.jsxs)(c,{title:`Per-task memory limit`,hint:`Applies to newly started tasks. Leave blank for no limit.`,children:[(0,p.jsxs)(`div`,{"data-reports-dirty":``,className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:b,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:e,disabled:r,placeholder:`no limit`,onChange:e=>t(e.target.value),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,p.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`MiB`})]}),n?(0,p.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number of at least `,b,` MiB, or leave empty for no limit.`]}):null]})}var D=[{value:`inherit`,label:`Inherit environment`},{value:`on`,label:`On`},{value:`off`,label:`Off`}];function O(e,t){return Array.from({length:t-e+1},(t,n)=>({value:String(e+n),label:String(e+n)}))}function k(e){return e===null?`inherit`:e?`on`:`off`}function A({composerDefaults:e,saveComposerDefault:t,saveIsPending:n,saved:r}){return(0,p.jsxs)(c,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,saved:r,children:[(0,p.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,p.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,p.jsx)(`span`,{className:l,children:`Autonomous by default`}),(0,p.jsx)(o,{"aria-label":`Autonomous by default`,value:k(e.autonomous),disabled:n,onValueChange:e=>t(`autonomous`,e),className:`settings-select max-w-full bg-card`,options:D}),(0,p.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:e.inheritedAutonomous?`On`:`Off`]})]}),(0,p.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:grid-cols-1`,children:[(0,p.jsx)(`span`,{className:l,children:`Use a worktree by default`}),(0,p.jsx)(o,{"aria-label":`Use a worktree by default`,value:k(e.worktree),disabled:n,onValueChange:e=>t(`worktree`,e),className:`settings-select max-w-full bg-card`,options:D}),(0,p.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Inherited: `,e.inheritedWorktree?`On`:`Off`]})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated. Saves automatically.`})]})}export{x as ResourcesSection};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{Tn as n}from"./index-CXvWnyZg.js";var r=e(t(),1),i={open:!1,notes:``},a=new Map,o=new Set,s=null;function c(){let e=[...a.values()].some(e=>e.notes.trim()!==``);e&&s===null&&(s=n()),!e&&s!==null&&(s(),s=null);for(let e of o)e()}function l(e){return o.add(e),()=>{o.delete(e)}}function u(e){return a.get(e)??i}function d(e,t){let n={...u(e),...t};!n.open&&n.notes===``?a.delete(e):a.set(e,n),c()}function f(e){a.delete(e)&&c()}function p(e){let t=(0,r.useSyncExternalStore)(l,()=>u(e)),n=(0,r.useCallback)(t=>d(e,t),[e]),i=(0,r.useCallback)(()=>f(e),[e]);return{...t,update:n,clear:i}}export{d as n,p as r,u as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{Tn as n}from"./index-TOx-AA67.js";var r=e(t(),1),i={open:!1,notes:``},a=new Map,o=new Set,s=null;function c(){let e=[...a.values()].some(e=>e.notes.trim()!==``);e&&s===null&&(s=n()),!e&&s!==null&&(s(),s=null);for(let e of o)e()}function l(e){return o.add(e),()=>{o.delete(e)}}function u(e){return a.get(e)??i}function d(e,t){let n={...u(e),...t};!n.open&&n.notes===``?a.delete(e):a.set(e,n),c()}function f(e){a.delete(e)&&c()}function p(e){let t=(0,r.useSyncExternalStore)(l,()=>u(e)),n=(0,r.useCallback)(t=>d(e,t),[e]),i=(0,r.useCallback)(()=>f(e),[e]);return{...t,update:n,clear:i}}export{d as n,p as r,u as t};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./review-strip-En21aXDx.js";import{t as a}from"./eye-B8okNWXU.js";import{n as o}from"./centered-state-BgSV4e79.js";import{t as s}from"./run-diff-BvGvPk3g.js";var c=e({AcceptCelebration:()=>h,ReviewGateBanner:()=>d,ReviewPanel:()=>f,prefersReducedMotion:()=>p}),l=t(n(),1),u=r();function d({run:e,projectId:t,onResolved:n}){return(0,u.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex flex-col gap-2 rounded-xl border border-info/35 bg-info/10 px-3.5 py-2.5`,children:[(0,u.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,u.jsx)(a,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,u.jsxs)(`p`,{className:`min-w-0 break-words text-[13px] leading-relaxed`,children:[(0,u.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,u.jsx)(`span`,{className:`block text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,u.jsx)(i,{run:e,projectId:t,onResolved:n})]})}function f({run:e,projectId:t,onResolved:n,showDiff:r=!0}){return(0,u.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-2.5`,children:[(0,u.jsx)(d,{run:e,projectId:t,onResolved:n}),r?(0,u.jsx)(s,{runId:e.id,projectId:t}):null]})}function p(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var m=1500;function h({status:e}){let t=(0,l.useRef)(e),[n,r]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||p())return;r(!0);let i=setTimeout(()=>r(!1),m);return()=>clearTimeout(i)},[e]),n?(0,u.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,u.jsx)(o,{}),(0,u.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,u.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}export{c as n,f as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./review-strip-BFq2VP2u.js";import{t as a}from"./eye-B8okNWXU.js";import{n as o}from"./centered-state-BgSV4e79.js";import{t as s}from"./run-diff-BvGvPk3g.js";var c=e({AcceptCelebration:()=>h,ReviewGateBanner:()=>d,ReviewPanel:()=>f,prefersReducedMotion:()=>p}),l=t(n(),1),u=r();function d({run:e,projectId:t,onResolved:n}){return(0,u.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex flex-col gap-2 rounded-xl border border-info/35 bg-info/10 px-3.5 py-2.5`,children:[(0,u.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,u.jsx)(a,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,u.jsxs)(`p`,{className:`min-w-0 break-words text-[13px] leading-relaxed`,children:[(0,u.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,u.jsx)(`span`,{className:`block text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,u.jsx)(i,{run:e,projectId:t,onResolved:n})]})}function f({run:e,projectId:t,onResolved:n,showDiff:r=!0}){return(0,u.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-2.5`,children:[(0,u.jsx)(d,{run:e,projectId:t,onResolved:n}),r?(0,u.jsx)(s,{runId:e.id,projectId:t}):null]})}function p(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var m=1500;function h({status:e}){let t=(0,l.useRef)(e),[n,r]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||p())return;r(!0);let i=setTimeout(()=>r(!1),m);return()=>clearTimeout(i)},[e]),n?(0,u.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,u.jsx)(o,{}),(0,u.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,u.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}export{c as n,f as t};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i,s as a}from"./dist-C_rn70hE.js";import{Ut as o,ct as s,ln as c,un as l}from"./queries-CchoEEzj.js";import{Rn as u,ct as d,n as f,ut as p,vi as m}from"./toaster-zMN8cNZQ.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{I as g,l as _,y as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./createLucideIcon-BHp8sXmF.js";import{t as b}from"./external-link-BE6y205O.js";import{t as x}from"./eye-B8okNWXU.js";import{t as S}from"./button-C8jUIs8Q.js";import{t as C}from"./project-router-j0uBi7Ep.js";import{S as w,at as T,mn as E,zn as D}from"./index-CXvWnyZg.js";import{t as O}from"./textarea-vEsJAUAV.js";import{n as k,t as A}from"./use-finish-run-BK7gmbXh.js";import{r as j,t as M}from"./review-notes-drafts-B_Mb82AK.js";var N=y(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),P=e({ReviewActions:()=>R,ReviewStrip:()=>L}),F=t(n(),1),I=r();function L({run:e,projectId:t}){let n=w(e);return(0,I.jsx)(`section`,{"data-slot":`review-strip`,"aria-label":`Review the changes`,className:`sticky bottom-0 z-20 shrink-0 border-t border-info/35 bg-background`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 bg-info/10 px-4 py-2 md:flex-row md:items-start md:gap-4 md:px-9`,children:[(0,I.jsxs)(`p`,{"data-slot":`review-evidence`,className:`flex min-h-11 min-w-0 shrink-0 items-center gap-2 text-xs text-muted-foreground max-md:hidden`,children:[(0,I.jsx)(x,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Needs review`}),n.diff?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-diff`,className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.diff.files,` `,n.diff.files===1?`file`:`files`,(0,I.jsx)(D,{stat:n.diff})]}):null,n.checks?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-checks`,className:i(`flex items-center gap-1.5`,n.checks.failed&&`font-medium text-semantic-red`),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.checks.label]}):null]}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(R,{run:e,projectId:t,reviewLink:!1})})]})})}function R({run:e,projectId:t,onResolved:n,reviewLink:r=!0}){let i=s(),v=m(),y=(0,F.useRef)(null),w=j(e.id),{notes:D,open:P,clear:L}=w,R=e=>w.update({notes:e}),[B,V]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),W=A(e.id,{projectId:t,onSuccess:()=>{L(),n?.()}}),G=k(e,null,t),K=()=>v.invalidateQueries({queryKey:o.runs.all}),q=l({mutationFn:async n=>G.canContinue?d(c(e.id,{projectId:t}),{text:`Review feedback:\n${n}`,runner:G.runnerOverride}):null,onMutate:()=>c(e.id,{projectId:t}),onSuccess:(t,r,a)=>{t!==null&&(M(e.id).notes.trim()===r&&L(),i.invalidateAfter(`continue`,a),n?.())},onError:e=>f(e.message,{tone:`danger`})}),J=l({mutationFn:()=>p(e.id,t),onSuccess:e=>{f(`Draft PR created — ${e.url}`),L(),K(),n?.()},onError:e=>{e instanceof u&&e.manual!==void 0&&U(e.manual),f(e.message,{tone:`danger`})}}),Y=()=>{if(!P){w.update({open:!0}),requestAnimationFrame(()=>y.current?.focus());return}let e=D.trim();if(e.length===0){V(`Write what to change first.`),y.current?.focus();return}V(null),q.mutate(e)};return(0,I.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[G.canContinue?null:(0,I.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:G.reason}),G.providerPending?null:(0,I.jsx)(C,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button]:min-h-11 [&_a]:min-h-11`,children:[r?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:t?(0,I.jsxs)(h,{to:`/p/${encodeURIComponent(t)}/tasks/${encodeURIComponent(e.id)}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]}):(0,I.jsxs)(C,{to:`/tasks/${e.id}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]})}):null,(0,I.jsxs)(S,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:G.reason??(P?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":G.canContinue?void 0:`review-provider-guidance`,"aria-expanded":P,"aria-controls":P?`review-notes`:void 0,disabled:q.isPending||!G.canContinue,onClick:Y,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),P?`Send back with notes`:`Send back`]}),a(e.pullRequestUrl)?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,I.jsx)(b,{"aria-hidden":`true`}),`PR ↗`]})}):(0,I.jsxs)(S,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:J.isPending,onClick:()=>J.mutate(),children:[(0,I.jsx)(g,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,I.jsxs)(S,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:E(`review`),disabled:W.isPending,onClick:()=>W.mutate(),children:[(0,I.jsx)(_,{"aria-hidden":`true`}),`Accept`]}):null]}),P?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(O,{ref:y,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,"aria-invalid":B!==null||void 0,"aria-describedby":B===null?void 0:`review-notes-error`,placeholder:`Notes for the agent — what should change?`,rows:1,value:D,onChange:e=>{let t=e.target.value;R(t),B!==null&&t.trim().length>0&&V(null)},onKeyDown:e=>{T(e)&&(e.preventDefault(),Y())},className:`max-h-[min(24dvh,180px)] min-h-11 overflow-y-auto overscroll-contain text-base md:text-[13px]`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[B===null?(0,I.jsx)(`span`,{}):(0,I.jsx)(`p`,{id:`review-notes-error`,"data-slot":`review-notes-error`,role:`alert`,className:`text-xs font-medium text-semantic-red`,children:B}),(0,I.jsx)(S,{"data-slot":`review-notes-cancel`,variant:`ghost`,size:`sm`,className:`min-h-11`,title:`Fold the notes box and drop the notes`,onClick:()=>{V(null),L()},children:`Cancel`})]})]}):null,H===null?null:(0,I.jsx)(z,{command:H})]})}function z({command:e}){return(0,I.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>f(`Command copied to clipboard.`)).catch(()=>f(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-xs text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,I.jsx)(v,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}export{P as n,R as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i,s as a}from"./dist-C_rn70hE.js";import{Ut as o,ct as s,ln as c,un as l}from"./queries-CchoEEzj.js";import{Rn as u,ct as d,n as f,ut as p,vi as m}from"./toaster-zMN8cNZQ.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{I as g,l as _,y as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./createLucideIcon-BHp8sXmF.js";import{t as b}from"./external-link-BE6y205O.js";import{t as x}from"./eye-B8okNWXU.js";import{t as S}from"./button-C8jUIs8Q.js";import{t as C}from"./project-router-j0uBi7Ep.js";import{S as w,at as T,mn as E,zn as D}from"./index-TOx-AA67.js";import{t as O}from"./textarea-vEsJAUAV.js";import{n as k,t as A}from"./use-finish-run-CyV1CCkZ.js";import{r as j,t as M}from"./review-notes-drafts-D9s8XFRQ.js";var N=y(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),P=e({ReviewActions:()=>R,ReviewStrip:()=>L}),F=t(n(),1),I=r();function L({run:e,projectId:t}){let n=w(e);return(0,I.jsx)(`section`,{"data-slot":`review-strip`,"aria-label":`Review the changes`,className:`sticky bottom-0 z-20 shrink-0 border-t border-info/35 bg-background`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 bg-info/10 px-4 py-2 md:flex-row md:items-start md:gap-4 md:px-9`,children:[(0,I.jsxs)(`p`,{"data-slot":`review-evidence`,className:`flex min-h-11 min-w-0 shrink-0 items-center gap-2 text-xs text-muted-foreground max-md:hidden`,children:[(0,I.jsx)(x,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Needs review`}),n.diff?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-diff`,className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.diff.files,` `,n.diff.files===1?`file`:`files`,(0,I.jsx)(D,{stat:n.diff})]}):null,n.checks?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-checks`,className:i(`flex items-center gap-1.5`,n.checks.failed&&`font-medium text-semantic-red`),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.checks.label]}):null]}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(R,{run:e,projectId:t,reviewLink:!1})})]})})}function R({run:e,projectId:t,onResolved:n,reviewLink:r=!0}){let i=s(),v=m(),y=(0,F.useRef)(null),w=j(e.id),{notes:D,open:P,clear:L}=w,R=e=>w.update({notes:e}),[B,V]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),W=A(e.id,{projectId:t,onSuccess:()=>{L(),n?.()}}),G=k(e,null,t),K=()=>v.invalidateQueries({queryKey:o.runs.all}),q=l({mutationFn:async n=>G.canContinue?d(c(e.id,{projectId:t}),{text:`Review feedback:\n${n}`,runner:G.runnerOverride}):null,onMutate:()=>c(e.id,{projectId:t}),onSuccess:(t,r,a)=>{t!==null&&(M(e.id).notes.trim()===r&&L(),i.invalidateAfter(`continue`,a),n?.())},onError:e=>f(e.message,{tone:`danger`})}),J=l({mutationFn:()=>p(e.id,t),onSuccess:e=>{f(`Draft PR created — ${e.url}`),L(),K(),n?.()},onError:e=>{e instanceof u&&e.manual!==void 0&&U(e.manual),f(e.message,{tone:`danger`})}}),Y=()=>{if(!P){w.update({open:!0}),requestAnimationFrame(()=>y.current?.focus());return}let e=D.trim();if(e.length===0){V(`Write what to change first.`),y.current?.focus();return}V(null),q.mutate(e)};return(0,I.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[G.canContinue?null:(0,I.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:G.reason}),G.providerPending?null:(0,I.jsx)(C,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button]:min-h-11 [&_a]:min-h-11`,children:[r?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:t?(0,I.jsxs)(h,{to:`/p/${encodeURIComponent(t)}/tasks/${encodeURIComponent(e.id)}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]}):(0,I.jsxs)(C,{to:`/tasks/${e.id}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]})}):null,(0,I.jsxs)(S,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:G.reason??(P?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":G.canContinue?void 0:`review-provider-guidance`,"aria-expanded":P,"aria-controls":P?`review-notes`:void 0,disabled:q.isPending||!G.canContinue,onClick:Y,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),P?`Send back with notes`:`Send back`]}),a(e.pullRequestUrl)?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,I.jsx)(b,{"aria-hidden":`true`}),`PR ↗`]})}):(0,I.jsxs)(S,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:J.isPending,onClick:()=>J.mutate(),children:[(0,I.jsx)(g,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,I.jsxs)(S,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:E(`review`),disabled:W.isPending,onClick:()=>W.mutate(),children:[(0,I.jsx)(_,{"aria-hidden":`true`}),`Accept`]}):null]}),P?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(O,{ref:y,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,"aria-invalid":B!==null||void 0,"aria-describedby":B===null?void 0:`review-notes-error`,placeholder:`Notes for the agent — what should change?`,rows:1,value:D,onChange:e=>{let t=e.target.value;R(t),B!==null&&t.trim().length>0&&V(null)},onKeyDown:e=>{T(e)&&(e.preventDefault(),Y())},className:`max-h-[min(24dvh,180px)] min-h-11 overflow-y-auto overscroll-contain text-base md:text-[13px]`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[B===null?(0,I.jsx)(`span`,{}):(0,I.jsx)(`p`,{id:`review-notes-error`,"data-slot":`review-notes-error`,role:`alert`,className:`text-xs font-medium text-semantic-red`,children:B}),(0,I.jsx)(S,{"data-slot":`review-notes-cancel`,variant:`ghost`,size:`sm`,className:`min-h-11`,title:`Fold the notes box and drop the notes`,onClick:()=>{V(null),L()},children:`Cancel`})]})]}):null,H===null?null:(0,I.jsx)(z,{command:H})]})}function z({command:e}){return(0,I.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>f(`Command copied to clipboard.`)).catch(()=>f(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-xs text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,I.jsx)(v,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}export{P as n,R as t};
@@ -0,0 +1 @@
1
+ [data-slot=task-confirmation]{border-radius:12px;padding:24px}[data-slot=task-confirmation] [data-slot=alert-dialog-title]{font-size:20px;font-weight:500}[data-slot=task-confirmation] [data-slot=alert-dialog-description]{font-size:13px;line-height:1.6}@media (width<=767px){[data-slot=notes-panel],.task-action-panel{padding:18px}}[data-slot=run-actions-menu] [role^=menuitem]>svg{display:none}@media (hover:hover) and (pointer:fine){[data-slot=parent-task-link]:hover{color:var(--foreground);text-underline-offset:.2em;text-decoration:underline}}@media (width<=767px){[data-slot=run-title-row]{grid-template-columns:minmax(0,1fr) auto auto;gap:6px;display:grid}[data-slot=run-title-row] [data-slot=session-kind]{grid-area:1/1}[data-slot=run-title-row]>.group{grid-area:2/1/auto/-1;max-width:100%}[data-slot=run-title-row]>.group h1{font-size:20px;line-height:1.4}[data-slot=run-title-row]>span:last-child{grid-area:1/3}}[data-slot=notes-panel] .thread-markdown{color:var(--muted-foreground);font-size:13px;line-height:1.6}[data-slot=notes-panel] .thread-markdown :is(h1,h2,h3){color:var(--foreground);margin-block:20px 8px;font-size:16px;font-weight:400;line-height:1.5}[data-slot=notes-panel]>div:first-child h2,.task-action-panel h2{font-size:18px;font-weight:400}[data-slot=notes-panel] button,.task-action-panel button{font-size:13px;font-weight:400}.task-action-panel h3{font-size:16px;font-weight:400}[data-slot=run-tabs]{gap:calc(var(--spacing) * 6)}[data-slot=run-tabs]>a,[data-slot=run-tabs]>[data-slot=run-tabs-more]{height:44px;padding-inline:4px;font-size:12px;font-weight:400}[data-slot=run-tabs]>a[aria-current=page]{color:var(--foreground);border-block-end-color:var(--accent-text)}@media (width<=767px){[data-slot=run-tabs]{gap:calc(var(--spacing) * 2)}[data-slot=run-tabs]>:is(a,button){min-inline-size:44px}[data-slot=run-tabs][data-overflow-end]{-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 24px),#0000);mask-image:linear-gradient(90deg,#000 calc(100% - 24px),#0000)}}[data-slot=run-tabs]{margin-block-start:calc(var(--spacing) * 3)}[data-slot=run-tabs]>a[aria-current=page]{font-weight:600}@media (width<=767px){[data-slot=run-tabs][data-phone-bar]{margin-block-start:0}[data-slot=run-tabs][data-phone-bar]>a,[data-slot=run-tabs][data-phone-bar]>[data-slot=run-tabs-more]{color:var(--soft-foreground);font-weight:500}[data-slot=run-tabs][data-phone-bar]>a[aria-current=page]{color:var(--foreground);border-block-end-color:var(--accent-text);border-block-end-width:2px;font-weight:600}[data-slot=run-tabs][data-phone-bar]>a [data-slot=tab-count]{color:var(--soft-foreground);font-size:12px}}@media (width>=768px){[data-slot=run-header]{padding-block-start:calc(var(--spacing) * 5.5)}[data-slot=run-title-row]{flex-wrap:nowrap;align-items:center;gap:12px;display:flex}[data-slot=run-title-row]>.group{flex:0 auto;min-inline-size:0;max-inline-size:none}[data-slot=run-title-row]>[data-slot=run-status-slot]{flex:1;justify-content:flex-end;display:flex}[data-slot=run-title-row] h1{letter-spacing:-.7px;font-size:25px}[data-slot=run-title-row]>span:last-child{margin-inline-start:0}}[data-slot=run-header]{container-type:inline-size}@container (width<=960px){[data-slot=run-title-row]:has(>span:last-child>:nth-child(3)){flex-wrap:wrap;row-gap:8px}[data-slot=run-title-row]:has(>span:last-child>:nth-child(3))>.group{flex:100%}[data-slot=run-title-row]:has(>span:last-child>:nth-child(3))>[data-slot=run-status-slot]{justify-content:flex-start}[data-slot=run-title-row]:has(>span:last-child>:nth-child(3))>span:last-child{margin-inline-start:auto}}@container (width<=560px){[data-slot=run-tabs]:not([data-phone-bar]){margin-block-start:6px}[data-slot=run-title-row]{flex-wrap:wrap;gap:6px 8px}[data-slot=run-title-row]>.group{flex:100%}[data-slot=run-title-row]>[data-slot=run-status-slot]{justify-content:flex-start}[data-slot=run-title-row]>span:last-child{flex-wrap:wrap;gap:6px;margin-inline-start:0}}@container (width<=240px){[data-slot=run-title-row]{flex-wrap:wrap;display:flex}[data-slot=run-title-row]>.group{flex-basis:100%;order:1}}[data-mobile-session-bar=true] [data-slot=run-activity-trigger-mobile]{border-block-start:0;flex:1 0 auto;max-inline-size:100%;overflow:clip}[data-mobile-session-bar=true] [data-slot=run-activity-trigger-mobile] [data-slot=run-activity-status]{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (prefers-reduced-motion:no-preference){[data-slot=run-tabs]{scroll-behavior:smooth}}