@wjarka/cezarion 0.18.0-dev.7379 → 0.18.0-dev.7381

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 (42) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-Ctg50eXm.js → activity-motion-BOQUCeCr.js} +1 -1
  3. package/web/dist/assets/{activity-route-CIrBgiGz.js → activity-route-BHLXl8oV.js} +1 -1
  4. package/web/dist/assets/{agent-accounts-Bxqcccek.js → agent-accounts-CrhI2D79.js} +1 -1
  5. package/web/dist/assets/attention-CJrUOS56.js +1 -0
  6. package/web/dist/assets/{commit-diff-panel-OWVorWVw.js → commit-diff-panel-BaxN0Drk.js} +1 -1
  7. package/web/dist/assets/{diff-BvBs4Gxp.js → diff-DsC9nsup.js} +2 -2
  8. package/web/dist/assets/{diff-view-CSrp8jyv.js → diff-view-DrIsymRS.js} +1 -1
  9. package/web/dist/assets/{file-preview-B6mM_dbK.js → file-preview-Bg9lwYd3.js} +1 -1
  10. package/web/dist/assets/{git-toolbar-CvG0gvVf.js → git-toolbar-BIMZxkIR.js} +1 -1
  11. package/web/dist/assets/{github-Dra1J1Oi.js → github-DLMIlW2E.js} +1 -1
  12. package/web/dist/assets/{global-activity-route-8H2KkpXH.js → global-activity-route-DLAEr5L8.js} +1 -1
  13. package/web/dist/assets/{index-aCWAgBiE.js → index-8QnR_MBI.js} +4 -4
  14. package/web/dist/assets/{markdown-D4ZGAuSC.js → markdown-C24Y3Ede.js} +1 -1
  15. package/web/dist/assets/{picker-pill-B6QPSEUZ.js → picker-pill-Dl5RK9pn.js} +1 -1
  16. package/web/dist/assets/{preview-pane-connected-Bhb5eJ5Z.js → preview-pane-connected-BB6fiNz4.js} +1 -1
  17. package/web/dist/assets/{project-router-0DHZ1s8l.js → project-router-4acCokGM.js} +1 -1
  18. package/web/dist/assets/{project-scope-context-qMCI2vmR.js → project-scope-context-DhjdxoB5.js} +1 -1
  19. package/web/dist/assets/{prompt-template-menu-_WK10gNW.js → prompt-template-menu-cd6UuIt4.js} +1 -1
  20. package/web/dist/assets/{queries-DFchmPfl.js → queries-DQWq3QYH.js} +1 -1
  21. package/web/dist/assets/{reference-chip-BJe4UIpL.js → reference-chip-S5_xQP1E.js} +1 -1
  22. package/web/dist/assets/{repo-git-DAhDX80l.js → repo-git-j1M9sjeL.js} +1 -1
  23. package/web/dist/assets/{report-reader-DsYm5b9J.js → report-reader-CH91jPJm.js} +1 -1
  24. package/web/dist/assets/{reports-BosE8lj8.js → reports-DJnKG8OO.js} +1 -1
  25. package/web/dist/assets/{run-header-DBbM_xNy.js → run-header-Bfg4NPUu.js} +1 -1
  26. package/web/dist/assets/{skills-BHAGfLNq.js → skills-CdKwxQx-.js} +1 -1
  27. package/web/dist/assets/{tab-link-lVQ2eOeD.js → tab-link-lLkoaQwJ.js} +1 -1
  28. package/web/dist/assets/{task-changes-Jg7Xzrfa.js → task-changes-jdt_D-1I.js} +1 -1
  29. package/web/dist/assets/{task-commits-DecgF6zx.js → task-commits-y2F7KSSy.js} +1 -1
  30. package/web/dist/assets/{task-files-D7N-vFyz.js → task-files-BgoBjf1S.js} +1 -1
  31. package/web/dist/assets/{task-github-item-C8fBdico.js → task-github-item-DRiO1MOT.js} +1 -1
  32. package/web/dist/assets/{task-thread-DifTEOeK.js → task-thread-DtmCMLAL.js} +1 -1
  33. package/web/dist/assets/{thread-state-i29D-4yN.js → thread-state-B4uGx4AQ.js} +1 -1
  34. package/web/dist/assets/{use-desktop-CdWXLHne.js → use-desktop-B27Z5VAz.js} +1 -1
  35. package/web/dist/assets/{use-hand-to-agent-state-CPxNdj4_.js → use-hand-to-agent-state-PIoC-vpx.js} +1 -1
  36. package/web/dist/assets/{useInfiniteQuery-Bn5hIzUm.js → useInfiniteQuery-MTFj7KHp.js} +1 -1
  37. package/web/dist/assets/useQuery-pKaBf15T.js +1 -0
  38. package/web/dist/assets/{workflows-CflCv_rB.js → workflows-DABi3xsS.js} +1 -1
  39. package/web/dist/assets/{ws-DfKMAUWf.js → ws-DSHRpUsm.js} +1 -1
  40. package/web/dist/index.html +13 -13
  41. package/web/dist/assets/attention-D15PtJnc.js +0 -1
  42. package/web/dist/assets/useQuery-DjkTL27e.js +0 -1
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,L as n,S as r,d as i,t as a,u as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{Bt as l,Fn as u,Hn as d,Jn as f,Lr as ee,Pn as p,Un as m,Xn as h,i as g,jn as te,k as _,o as ne,pr as v,qn as re,zt as ie}from"./project-scope-context-qMCI2vmR.js";import{$ as y,B as ae,I as oe,Jt as se,Kt as b,L as x,N as ce,R as S,St as C,W as w,X as le,Y as ue,Yt as T,b as de,ft as fe,n as pe,qt as me,vt as he,yt as E,z as D}from"./queries-DFchmPfl.js";import{J as ge,L as _e,S as ve,_ as ye,a as be,b as xe,d as Se,f as Ce,n as we,o as Te,p as Ee,r as De,v as Oe,y as ke,z as O}from"./use-desktop-CdWXLHne.js";import{n as k}from"./toaster-CoMJoQvk.js";import{A as Ae,F as je,a as Me,at as Ne,f as Pe,ft as A,g as Fe,h as Ie,i as j,l as M,m as Le,p as Re,q as ze,t as Be,v as N,x as Ve}from"./design-icons-B6-0w7Aw.js";import{t as P}from"./createLucideIcon-BHp8sXmF.js";import{t as He}from"./app-window-CSHwDX9N.js";import{t as Ue}from"./info-DA1x_4bz.js";import{a as We,t as Ge}from"./format-BNCkW110.js";import{t as Ke}from"./message-square-B-MD-8rD.js";import{i as qe,n as Je,t as F}from"./reference-chip-BJe4UIpL.js";import{a as I,i as L,l as R,n as z,p as B,r as V,t as H}from"./dropdown-menu-CzUYjvx4.js";import{a as Ye,i as Xe,o as Ze,r as Qe,s as $e,t as et}from"./dialog-tMSuX5a7.js";import{c as tt,s as nt,t as U}from"./project-router-0DHZ1s8l.js";import"./attention-D15PtJnc.js";import{Bt as rt,Ct as it,Dt as W,Ht as at,Jt as G,M as ot,N as st,Ot as K,V as ct,Vt as lt,Xt as ut,Yt as dt,Zt as ft,_ as pt,a as mt,ct as ht,dt as gt,en as _t,ft as vt,gt as yt,ht as bt,j as xt,ln as St,lt as Ct,mt as q,nn as wt,o as Tt,pt as Et,r as Dt,rn as Ot,st as kt,t as At,ut as jt,vn as Mt,vt as Nt,yt as Pt}from"./index-aCWAgBiE.js";import{r as Ft,t as It}from"./markdown-D4ZGAuSC.js";import{t as J}from"./tab-link-lVQ2eOeD.js";var Lt=P(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Rt=P(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),zt=P(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Y=e(s(),1),X=c();function Bt(e){let t=b();return T({mutationFn:t=>ne(se(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>me()),onError:e=>k(e.message,{tone:`danger`})})}function Vt(e){return e.archived?`Unarchive`:`Archive task`}function Ht({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(kt,{open:t,onOpenChange:n,children:(0,X.jsxs)(jt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(Et,{children:[(0,X.jsx)(q,{children:`Archive task?`}),(0,X.jsxs)(gt,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:O(e),children:O(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(vt,{children:[(0,X.jsx)(Ct,{children:`Cancel`}),(0,X.jsx)(ht,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Z({run:e,className:t,compactOnMobile:n=!1}){let[r,i]=(0,Y.useState)(!1),s=Bt(e.id),c=Vt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(a,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":c,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:s.isPending,className:o(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?s.mutate(!1):i(!0),children:[e.archived?(0,X.jsx)(Mt,{"aria-hidden":`true`}):(0,X.jsx)(Be,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:o(n&&`max-md:sr-only`),children:c})]}),(0,X.jsx)(Ht,{run:e,open:r,onOpenChange:i,onConfirm:()=>{s.mutate(!0),i(!1)}})]})}function Ut({run:e,action:t,prUrl:n,patch:r}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&i(n)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,X.jsx)(a,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>k(e.message,{tone:`danger`})}),children:r.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Wt({run:e,blocker:t,flags:n}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(U,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&i(t.pullRequestUrl)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,X.jsx)(Z,{run:e}):null]})]})}function Gt({run:e}){let t=D(e.id),n=K(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,X.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,X.jsx)(Ut,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,X.jsx)(Wt,{run:e,blocker:i,flags:n}):null]})}var Kt=[`running`,`queued`,`waiting`];function qt(e,{queuePosition:t,now:n=new Date}){let r=te(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Kt.includes(e.status)?Yt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Jt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Yt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ge(n,t)}}async function Q(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function Xt(e){let t=w(),n=y(),r=(0,Y.useMemo)(()=>ve(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>Se(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Zt(e){return T({mutationFn:()=>l(e.id),onError:e=>{if(e instanceof g&&e.command){Q(e.command,`No terminal found — command copied to clipboard.`);return}k(e.message,{tone:`danger`})}})}function $(e,t){let n=S(),r=le(),i=T({mutationFn:t=>ie(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),a=v(r.data),o=e=>!r.isSuccess||a.includes(e??`claude`);return{canResumeHere:t&&o(it(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=ut(e.id);return t===void 0||o(t)}).map(t=>({target:t,...Pt(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:i}}function Qt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=W(e);return!r&&i.length===0&&!s?null:(0,X.jsxs)(X.Fragment,{children:[r||i.length>0?(0,X.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,X.jsxs)(a,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,X.jsx)(_t,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=ft(e);return(0,X.jsxs)(a,{variant:`outline`,"data-target":e.id,title:n,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:[(0,X.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,X.jsxs)(a,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,X.jsx)(N,{}),`Copy worktree path`]}):null]}):null,s?(0,X.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,X.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,X.jsxs)(a,{variant:`outline`,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{}),`Copy resume command`]})]}):null]})}function $t({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=W(e),c=e.worktreePath;if(!r&&i.length===0&&!s&&!c)return null;let l=`max-md:min-h-11`;return(0,X.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,X.jsx)(dt,{choices:i,onPick:e=>o.mutate(e),disabled:o.isPending,triggerVariant:`outline`,className:l,leading:r?(0,X.jsxs)(L,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(_t,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,c?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,className:l,onClick:()=>void Q(c,`Worktree path copied`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy worktree path`]}):null,s?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:s,className:l,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function en({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:o,choices:s}=$(e,t);return!o&&s.length===0?null:r?(0,X.jsx)(L,{onSelect:r,children:`Open in…`}):(0,X.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,X.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,X.jsx)(A,{})})]}),e.worktreePath?(0,X.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Qt,{run:e,canResume:t,onResume:n})})]})}function tn({branch:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{k(`Could not copy branch. Select and copy: ${e}`)}};return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function nn({run:e}){let t=w(),n=y(),r=r=>n===void 0?void 0:Oe(n,e.id,r,t),a=(0,Y.useMemo)(()=>ve(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(yt,{run:e,prNumber:t.number})},Ee(t)));let l=xe(e);l&&i(l)&&!c.some(e=>e.url===l)&&o.push((0,X.jsx)(F,{reference:{kind:`PR`,url:l},taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},Ee(t)));let d=ye(e,t);if(d&&i(d)&&!u.some(e=>e.url===d)){let t=Ce(d);s.push((0,X.jsx)(F,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?r({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,X.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function rn(){let e=nt(),t=ue();return xt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var an=e=>e.map(e=>`${e.name}: ${ot(e.url)}`).join(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,L as n,S as r,d as i,t as a,u as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{Bt as l,Fn as u,Hn as d,Jn as f,Lr as ee,Pn as p,Un as m,Xn as h,i as g,jn as te,k as _,o as ne,pr as v,qn as re,zt as ie}from"./project-scope-context-DhjdxoB5.js";import{$ as y,B as ae,I as oe,Jt as se,Kt as b,L as x,N as ce,R as S,St as C,W as w,X as le,Y as ue,Yt as T,b as de,ft as fe,n as pe,qt as me,vt as he,yt as E,z as D}from"./queries-DQWq3QYH.js";import{J as ge,L as _e,S as ve,_ as ye,a as be,b as xe,d as Se,f as Ce,n as we,o as Te,p as Ee,r as De,v as Oe,y as ke,z as O}from"./use-desktop-B27Z5VAz.js";import{n as k}from"./toaster-CoMJoQvk.js";import{A as Ae,F as je,a as Me,at as Ne,f as Pe,ft as A,g as Fe,h as Ie,i as j,l as M,m as Le,p as Re,q as ze,t as Be,v as N,x as Ve}from"./design-icons-B6-0w7Aw.js";import{t as P}from"./createLucideIcon-BHp8sXmF.js";import{t as He}from"./app-window-CSHwDX9N.js";import{t as Ue}from"./info-DA1x_4bz.js";import{a as We,t as Ge}from"./format-BNCkW110.js";import{t as Ke}from"./message-square-B-MD-8rD.js";import{i as qe,n as Je,t as F}from"./reference-chip-S5_xQP1E.js";import{a as I,i as L,l as R,n as z,p as B,r as V,t as H}from"./dropdown-menu-CzUYjvx4.js";import{a as Ye,i as Xe,o as Ze,r as Qe,s as $e,t as et}from"./dialog-tMSuX5a7.js";import{c as tt,s as nt,t as U}from"./project-router-4acCokGM.js";import"./attention-CJrUOS56.js";import{Bt as rt,Ct as it,Dt as W,Ht as at,Jt as G,M as ot,N as st,Ot as K,V as ct,Vt as lt,Xt as ut,Yt as dt,Zt as ft,_ as pt,a as mt,ct as ht,dt as gt,en as _t,ft as vt,gt as yt,ht as bt,j as xt,ln as St,lt as Ct,mt as q,nn as wt,o as Tt,pt as Et,r as Dt,rn as Ot,st as kt,t as At,ut as jt,vn as Mt,vt as Nt,yt as Pt}from"./index-8QnR_MBI.js";import{r as Ft,t as It}from"./markdown-C24Y3Ede.js";import{t as J}from"./tab-link-lLkoaQwJ.js";var Lt=P(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Rt=P(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),zt=P(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Y=e(s(),1),X=c();function Bt(e){let t=b();return T({mutationFn:t=>ne(se(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>me()),onError:e=>k(e.message,{tone:`danger`})})}function Vt(e){return e.archived?`Unarchive`:`Archive task`}function Ht({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(kt,{open:t,onOpenChange:n,children:(0,X.jsxs)(jt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(Et,{children:[(0,X.jsx)(q,{children:`Archive task?`}),(0,X.jsxs)(gt,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:O(e),children:O(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(vt,{children:[(0,X.jsx)(Ct,{children:`Cancel`}),(0,X.jsx)(ht,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Z({run:e,className:t,compactOnMobile:n=!1}){let[r,i]=(0,Y.useState)(!1),s=Bt(e.id),c=Vt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(a,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":c,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:s.isPending,className:o(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?s.mutate(!1):i(!0),children:[e.archived?(0,X.jsx)(Mt,{"aria-hidden":`true`}):(0,X.jsx)(Be,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:o(n&&`max-md:sr-only`),children:c})]}),(0,X.jsx)(Ht,{run:e,open:r,onOpenChange:i,onConfirm:()=>{s.mutate(!0),i(!1)}})]})}function Ut({run:e,action:t,prUrl:n,patch:r}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&i(n)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,X.jsx)(a,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>k(e.message,{tone:`danger`})}),children:r.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Wt({run:e,blocker:t,flags:n}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(U,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&i(t.pullRequestUrl)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,X.jsx)(Z,{run:e}):null]})]})}function Gt({run:e}){let t=D(e.id),n=K(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,X.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,X.jsx)(Ut,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,X.jsx)(Wt,{run:e,blocker:i,flags:n}):null]})}var Kt=[`running`,`queued`,`waiting`];function qt(e,{queuePosition:t,now:n=new Date}){let r=te(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Kt.includes(e.status)?Yt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Jt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Yt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ge(n,t)}}async function Q(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function Xt(e){let t=w(),n=y(),r=(0,Y.useMemo)(()=>ve(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>Se(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Zt(e){return T({mutationFn:()=>l(e.id),onError:e=>{if(e instanceof g&&e.command){Q(e.command,`No terminal found — command copied to clipboard.`);return}k(e.message,{tone:`danger`})}})}function $(e,t){let n=S(),r=le(),i=T({mutationFn:t=>ie(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),a=v(r.data),o=e=>!r.isSuccess||a.includes(e??`claude`);return{canResumeHere:t&&o(it(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=ut(e.id);return t===void 0||o(t)}).map(t=>({target:t,...Pt(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:i}}function Qt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=W(e);return!r&&i.length===0&&!s?null:(0,X.jsxs)(X.Fragment,{children:[r||i.length>0?(0,X.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,X.jsxs)(a,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,X.jsx)(_t,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=ft(e);return(0,X.jsxs)(a,{variant:`outline`,"data-target":e.id,title:n,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:[(0,X.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,X.jsxs)(a,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,X.jsx)(N,{}),`Copy worktree path`]}):null]}):null,s?(0,X.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,X.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,X.jsxs)(a,{variant:`outline`,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{}),`Copy resume command`]})]}):null]})}function $t({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=W(e),c=e.worktreePath;if(!r&&i.length===0&&!s&&!c)return null;let l=`max-md:min-h-11`;return(0,X.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,X.jsx)(dt,{choices:i,onPick:e=>o.mutate(e),disabled:o.isPending,triggerVariant:`outline`,className:l,leading:r?(0,X.jsxs)(L,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(_t,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,c?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,className:l,onClick:()=>void Q(c,`Worktree path copied`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy worktree path`]}):null,s?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:s,className:l,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function en({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:o,choices:s}=$(e,t);return!o&&s.length===0?null:r?(0,X.jsx)(L,{onSelect:r,children:`Open in…`}):(0,X.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,X.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,X.jsx)(A,{})})]}),e.worktreePath?(0,X.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Qt,{run:e,canResume:t,onResume:n})})]})}function tn({branch:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{k(`Could not copy branch. Select and copy: ${e}`)}};return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function nn({run:e}){let t=w(),n=y(),r=r=>n===void 0?void 0:Oe(n,e.id,r,t),a=(0,Y.useMemo)(()=>ve(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(yt,{run:e,prNumber:t.number})},Ee(t)));let l=xe(e);l&&i(l)&&!c.some(e=>e.url===l)&&o.push((0,X.jsx)(F,{reference:{kind:`PR`,url:l},taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},Ee(t)));let d=ye(e,t);if(d&&i(d)&&!u.some(e=>e.url===d)){let t=Ce(d);s.push((0,X.jsx)(F,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?r({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,X.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function rn(){let e=nt(),t=ue();return xt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var an=e=>e.map(e=>`${e.name}: ${ot(e.url)}`).join(`
2
2
  `);function on(e){return rn().length>0||e.notify===!0}function sn({run:e}){let t=rn(),n=t.length>0,r=x(e.id),[i,o]=(0,Y.useState)(null),s=e.notify===!0;return!n&&!s?null:(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsxs)(H,{children:[(0,X.jsx)(B,{asChild:!0,children:(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`notifying-chip`,className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":n?`Notifying ${st(t)} — webhook actions`:`Notifying — webhook actions`,title:n?an(t):void 0,children:[(0,X.jsx)(G,{tone:`success`}),(0,X.jsx)(`span`,{children:`Notifying`}),(0,X.jsx)(M,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,X.jsxs)(V,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[n?(0,X.jsx)(I,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-[11px] font-normal text-muted-foreground`,children:t.map(e=>(0,X.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:ot(e.url),children:e.name},e.id))}):null,n?(0,X.jsxs)(L,{className:`min-h-11`,onSelect:()=>o(`note`),children:[(0,X.jsx)(Ke,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,X.jsxs)(L,{variant:`destructive`,className:`min-h-11`,disabled:r.isPending,onSelect:()=>r.mutate({notify:!1},{onSuccess:()=>k(`Stopped notifying the webhook`),onError:e=>k(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),children:[(0,X.jsx)(Lt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-action":`handoff`,className:`size-11 px-0 md:h-[30px] md:w-auto md:px-2.5`,"aria-label":`Hand off to webhook`,onClick:()=>o(`handoff`),children:[(0,X.jsx)(wt,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),n?(0,X.jsx)(cn,{mode:i,targets:t,pending:r.isPending,onOpenChange:e=>!e&&o(null),onSubmit:e=>r.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{o(null),k(i===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>k(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null]})}function cn({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let o=(0,Y.useId)(),s=(0,Y.useId)(),[c,l]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e!==null&&l(``)},[e]);let u=e===`note`,d=st(t);return(0,X.jsx)(et,{open:e!==null,onOpenChange:e=>{e||l(``),r(e)},children:(0,X.jsx)(Qe,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(c.trim())},children:[(0,X.jsxs)(Ze,{className:`text-left`,children:[(0,X.jsx)($e,{children:u?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,X.jsx)(Xe,{children:(0,X.jsx)(`span`,{"data-webhook-destination":``,title:an(t),children:u?`${d} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${d} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:o,className:`text-[13px] font-medium`,children:`Note`}),(0,X.jsx)(ct,{id:o,"data-slot":`handoff-note`,"aria-describedby":s,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:c,onChange:e=>l(e.target.value)}),(0,X.jsxs)(`p`,{id:s,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,X.jsxs)(Ye,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:h-11 max-sm:[&>button]:w-full`,children:[(0,X.jsx)(a,{type:`button`,variant:`ghost`,className:`sm:h-9`,onClick:()=>r(!1),children:`Cancel`}),(0,X.jsxs)(a,{type:`submit`,variant:`contrast`,className:`sm:h-9`,"data-action":`handoff-submit`,disabled:n||u&&c.trim()===``,children:[(0,X.jsx)(wt,{"aria-hidden":`true`}),u?`Send note`:`Hand off`]})]})]})})})}function ln({runId:e,children:t}){let n=r(),i=(0,Y.useMemo)(()=>({runId:e}),[e]);return n?(0,X.jsx)(un,{runId:e,children:t}):(0,X.jsx)(Ft.Provider,{value:i,children:t})}function un({runId:e,children:n}){let{projectId:r}=t(),i=(0,Y.useMemo)(()=>({runId:e,...r?{projectId:r}:{}}),[e,r]);return(0,X.jsx)(Ft.Provider,{value:i,children:n})}function dn(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function fn(e){return typeof e==`object`&&!!e&&!(0,Y.isValidElement)(e)&&`keep`in e}function pn({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:s,onToggle:c,className:l,children:u}){let d=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,X.jsx)(`span`,{className:o(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(fn(r)?(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,X.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,X.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,X.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:o(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,a,(0,X.jsx)(M,{"aria-hidden":!0,className:o(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,s&&`rotate-180`)})]}):(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,a]}),f&&s?(0,X.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function mn(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function hn(e){let t=e.delegation,n=t?.role===`root`,r=E(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=mn(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function gn(e){let t=E(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>ge(e.status))}function _n({run:e,open:t,onToggle:n}){let r=E(e.id),i=C(),s=we(),c=e.delegation,l=new Map(r.data?.workers.map(e=>[e.workerId,e])),u=mn(c,r.data),d=re(e)??h(e),f=d?vn(e,d):void 0;return(0,X.jsx)(pn,{slot:`workers`,icon:(0,X.jsx)(Ae,{className:`size-4`}),title:`Workers`,meta:yn({ids:u,workers:l,desktop:s,query:r}),aside:r.data?.capacity?(0,X.jsx)(En,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,X.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,d?(0,X.jsx)(Cn,{wait:d,dependencyLabel:f}):null,u.length>0?(0,X.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:u.map(t=>{let n=l.get(t),a=i.data?.find(e=>e.id===t)??r.data?.titles?.find(e=>e.id===t),s=n?xn(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,X.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,X.jsxs)(U,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(bn,{status:n?.status}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a?O(a):`Worker ${t.slice(0,8)}`}),(0,X.jsx)(`span`,{className:o(`max-w-[45%] shrink-0 truncate text-xs`,Sn(n?.status)),children:s}),(0,X.jsx)(Me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,X.jsx)(On,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,X.jsx)(An,{state:n.destroy}):null]},t)})}):c?.role===`root`&&r.isSuccess?(0,X.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,X.jsx)(a,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function vn(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return u(e)??p(n.role,t,`requestIds`in t&&f(n,t.requestIds))}function yn({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function bn({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,X.jsx)(Pe,{"aria-hidden":!0,className:o(t,`text-success`)}):e===`failed`?(0,X.jsx)(Fe,{"aria-hidden":!0,className:o(t,`text-danger`)}):e===`cancelled`?(0,X.jsx)(Ie,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,X.jsx)(We,{role:`status`,"aria-label":`Worker running`,className:o(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,X.jsx)(Le,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)})}function xn(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Sn(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Cn({wait:e,dependencyLabel:t}){return(0,X.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,X.jsxs)(X.Fragment,{children:[` `,`Deadline: `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: ${n(`Cezar`)} wakes this task when they have all settled.`]})}function wn(e){return e.delegation?.role===`worker`&&h(e)?.phase===`wake-pending`}function Tn({run:e}){let t=h(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,X.jsx)(Cn,{wait:t,dependencyLabel:p(`worker`,t)}):null}function En({capacity:e}){return(0,X.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Dn=new Set([`review`,`done`,`failed`,`cancelled`]);function On({parentRunId:e,worker:t}){let n=de(e),[r,i]=(0,Y.useState)(!1);if(!Dn.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let o=t.workerId.slice(0,8),s=!!t.destroy&&t.destroy.phase!==`complete`;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`break-words text-xs`,children:`Removes this worker's worktree and branch. Its result is saved first.`}),(0,X.jsx)(a,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${o}`,onClick:()=>{i(!1),n.mutate(t.workerId)},children:`Clean up`}),(0,X.jsx)(a,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,X.jsx)(a,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":s?`Retry clean up of worker ${o}`:`Clean up worker ${o}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:s?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,X.jsxs)(`span`,{role:`status`,className:`break-words text-xs`,children:[`Cleanup did not finish: `,n.error.message]}):null]})}function kn(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function An({state:e}){if(!kn(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,X.jsx)(jn,{at:t.nextAt});return(0,X.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,X.jsxs)(X.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,X.jsxs)(X.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function jn({at:e}){let t=bt(3e4);return(0,X.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:At(t,Date.parse(e))})}function Mn({id:e}){return(0,X.jsxs)(U,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function Nn({id:e}){let t=fe(e),n=t.data?O(t.data):e;return(0,X.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,X.jsxs)(U,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,X.jsx)(a,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var Pn=3,Fn=(e,t)=>e.kind===t.kind&&e.number===t.number;function In(e,t,n=Pn){let r=t?e.findIndex(e=>Fn(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var Ln=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function Rn({tab:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e.kind===`pr`?je:Re,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,X.jsx)(Je,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function zn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function Bn({servers:e}){let t=pt();if(t===null)return null;let n=t.agentLive===!0,r=e[0],i=e.length+ +!!n===1?r?{port:r.port}:{agent:!0}:{};return(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`preview-toggle`,className:`max-md:h-11`,"aria-pressed":t.open,onClick:()=>t.openPane(i),children:[(0,X.jsx)(He,{"aria-hidden":`true`}),zn(e,n),t.live?(0,X.jsx)(G,{tone:`success`,"aria-label":`Preview is live`}):null]})}function Vn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function Hn({run:e,compact:t=!1}){return e.delegation?.role===`worker`?t?(0,X.jsx)(Mn,{id:e.delegation.parentRunId}):(0,X.jsx)(Nn,{id:e.delegation.parentRunId}):null}function Un(e,t,n,r){return!e.archiveBlocker&&t.archive&&(n!==`session`||!Nt(e,r))?(0,X.jsx)(Z,{run:e}):null}function Wn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,X.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function Gn({shown:e,run:t,archiveButton:n,previewToggle:r}){let i=on(t);return e&&(n||r||i)?(0,X.jsxs)(`div`,{"data-slot":`run-mobile-actions`,className:`flex flex-wrap items-center gap-2 pt-2`,children:[n,r,(0,X.jsx)(sn,{run:t})]}):null}function Kn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,Y.useRef)(null),c=n?`${n.kind}#${n.number}`:null;return(0,Y.useEffect)(()=>{!c||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[c,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,X.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,className:`mt-3 flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-3.5 max-md:[&>a]:text-[13.5px]`,children:[(0,X.jsx)(J,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:a,children:`Commits`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,X.jsx)(J,{to:Ln(e.id,t),active:n!==null&&Fn(t,n),replace:a,children:(0,X.jsx)(Rn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,X.jsxs)(H,{children:[(0,X.jsxs)(B,{"data-slot":`run-tabs-more`,"aria-label":`${i.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,i.length]}),(0,X.jsx)(V,{align:`end`,children:i.map(t=>(0,X.jsx)(L,{asChild:!0,children:(0,X.jsx)(U,{to:Ln(e.id,t),replace:a,children:(0,X.jsx)(Rn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function qn({run:e,tab:t=`session`,onMarkedUnread:n}){let r=te(e),i=K(e),a=gn(e),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=Jn(e,n),f=C(),ee=ce(),p=qt(e,{queuePosition:e.status===`queued`?_e(f.data??[]).get(e.id):void 0}),m=at(),h=lt(),g=m!==null&&!h?m:null,_=g!==null,{referenceProjectId:ne,repoBase:v,requests:re}=Xt(e),ie=(0,Y.useMemo)(()=>ke(e,v),[e,v]),y=typeof t==`object`?t:null,{inline:ae,overflow:oe}=In(ie,y),se=ee.data?.capabilities?.preview===!0,b=e.worktreePath&&se?(0,X.jsx)(Bn,{servers:e.previewServers??[]}):null,x=(0,X.jsx)(Qn,{run:e,actions:d,onOpenChooser:()=>u(!0),onToggleNotes:()=>c(e=>!e)}),S=Un(e,i,t,a);return(0,X.jsx)(qe,{projectId:ne,repoBase:v,requests:re,children:(0,X.jsxs)(`header`,{"data-slot":`run-header`,className:o(`relative z-20 bg-background px-[18px] md:px-9 md:pt-7`,_?`pt-0`:`pt-[18px]`,t===`session`&&`md:sticky md:top-0`),children:[(0,X.jsx)(Wn,{run:e}),(0,X.jsx)(Gt,{run:e}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(Hn,{run:e}),g?(0,X.jsxs)(rt,{slot:g,children:[(0,X.jsx)(Zn,{run:e}),(0,X.jsx)(Hn,{run:e,compact:!0}),x]}):(0,X.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,X.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:Vn(e.delegation)}),(0,X.jsx)(Xn,{run:e}),(0,X.jsx)(Dt,{dot:r.tone,shape:r.shape,pulse:r.pulse,className:`max-md:hidden`,children:Jt(p)}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[S,b,(0,X.jsx)(sn,{run:e}),x]})]}),(0,X.jsx)(Gn,{shown:g!==null,run:e,archiveButton:S,previewToggle:b}),(0,X.jsx)(Kn,{run:e,tab:t,activeItem:y,inlineItemTabs:ae,overflowItemTabs:oe,phoneBar:_,isDesktop:h}),s?(0,X.jsx)(tr,{runId:e.id,onClose:()=>c(!1)}):null,l?(0,X.jsx)(en,{run:e,canResume:K(e).terminal,onResume:()=>d.terminal.mutate(),onClose:()=>u(!1)}):null]}),(0,X.jsx)(er,{run:e,actions:d})]})})}function Jn(e,t){let n=ee(),r=tt(),[i,a]=(0,Y.useState)(null),o=()=>n.invalidateQueries({queryKey:pe.runs.all}),s=e=>k(e.message,{tone:`danger`}),c=ae(),l={isPending:c.isPending,mutate:()=>c.mutate({id:e.id,pinned:!e.pinned})},u=oe();return{pin:l,markUnread:{isPending:u.isPending,mutate:()=>{t?.(),u.mutate(e.id,{onError:s})}},delete:T({mutationFn:()=>_(e.id),onSuccess:()=>{o(),r(`/`)},onError:s}),terminal:Zt(e),confirming:i,setConfirming:a}}function Yn(e){let t=D(e.id),n=O(e);return{title:n,editor:Tt(n,e=>t.mutate({title:e},{onError:e=>k(e.message,{tone:`danger`})}))}}function Xn({run:e}){let{title:t,editor:n}=Yn(e);return n.editing?(0,X.jsx)(mt,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,X.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(Ot,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Zn({run:e}){let{title:t,editor:n}=Yn(e);return(0,X.jsxs)(De,{open:n.editing,onOpenChange:e=>{e?n.begin():n.commit()},children:[(0,X.jsx)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-px`,children:(0,X.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,title:e.task,children:t})}),(0,X.jsx)(Te,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,className:`flex size-11 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(Ot,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(be,{align:`end`,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},children:(0,X.jsx)(mt,{editor:n,className:`text-[16px] font-semibold`})})]})}function Qn({run:e,actions:t,onToggleNotes:n,onOpenChooser:r}){let i=K(e),o=W(e),s=D(e.id),c=(0,Y.useId)();return(0,X.jsxs)(H,{children:[(0,X.jsx)(B,{asChild:!0,children:(0,X.jsx)(a,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,X.jsx)(Ve,{"aria-hidden":`true`})})}),(0,X.jsxs)(V,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,X.jsx)(I,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),(0,X.jsxs)(L,{onSelect:n,children:[(0,X.jsx)(St,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,X.jsx)(en,{run:e,canResume:i.terminal,onResume:()=>t.terminal.mutate(),onOpen:r}),o?(0,X.jsxs)(L,{onSelect:()=>void Q(o,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),` Copy resume command`]}):null,i.markUnread?(0,X.jsxs)(L,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,X.jsx)(Rt,{"aria-hidden":`true`}),` Mark unread`]}):null,i.pin?(0,X.jsxs)(z,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,X.jsx)(zt,{"aria-hidden":`true`}):(0,X.jsx)(ze,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,(0,X.jsx)(R,{}),(0,X.jsx)(I,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,X.jsx)(z,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:s.isPending,onCheckedChange:e=>s.mutate({archiveWhenDone:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,X.jsx)(z,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:s.isPending,"aria-describedby":c,onCheckedChange:e=>s.mutate({autoMergePr:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,X.jsx)(`p`,{id:c,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,X.jsx)($n,{run:e,patch:s}),i.deleteRun?(0,X.jsx)(R,{}):null,i.deleteRun?(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,X.jsx)(Ne,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})}function $n({run:e,patch:t}){let r=(0,Y.useId)(),i=(0,Y.useId)(),a=(0,Y.useId)(),o=e=>k(e.message,{tone:`danger`});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{}),(0,X.jsx)(I,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,X.jsxs)(z,{"data-slot":`allow-workers`,className:`min-h-11`,checked:m(e),disabled:t.isPending,"aria-describedby":`${r} ${a}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:o}),children:[`Allow `,n(`cezar`),` workers`]}),(0,X.jsxs)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:[`Agents in this task can start `,n(`Cezar`),` workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`]}),(0,X.jsx)(z,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:d(e),disabled:t.isPending,"aria-describedby":`${i} ${a}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:o}),children:`Allow task messaging`}),(0,X.jsx)(`p`,{id:i,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,X.jsx)(`p`,{id:a,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function er({run:e,actions:t}){let n=t.confirming;return(0,X.jsx)(kt,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,X.jsxs)(jt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(Et,{children:[(0,X.jsx)(q,{className:`text-danger`,children:`Delete task permanently?`}),(0,X.jsx)(gt,{children:(0,X.jsxs)(X.Fragment,{children:[`Delete “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:O(e),children:O(e)}),`” and its transcript, worktree and branch. This cannot be undone.`]})})]}),(0,X.jsxs)(vt,{children:[(0,X.jsx)(Ct,{children:`Cancel`}),(0,X.jsx)(ht,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function tr({runId:e,onClose:t}){let n=he(e);return(0,X.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,X.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,X.jsx)(A,{})})]}),n.isPending?(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,X.jsx)(ln,{runId:e,children:(0,X.jsx)(It,{children:n.data})}):(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`}),(0,X.jsxs)(`div`,{className:`mt-4 flex gap-3`,children:[(0,X.jsx)(a,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Q(n.data??``,`Notes copied`),children:`Copy notes`}),(0,X.jsx)(a,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{qt as _,kn as a,hn as c,ln as d,tn as f,Xt as g,Zt as h,Tn as i,pn as l,$t as m,An as n,wn as o,nn as p,_n as r,gn as s,qn as t,dn as u,Z as v};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Lr as o,Tt as s}from"./project-scope-context-qMCI2vmR.js";import{Rt as c,m as l,n as u}from"./queries-DFchmPfl.js";import{n as d}from"./toaster-CoMJoQvk.js";import{O as f,T as p,X as m,Y as h,ct as g,ot as _,u as v}from"./design-icons-B6-0w7Aw.js";import{t as y}from"./project-router-0DHZ1s8l.js";import{f as b,l as x}from"./skills-pM_PouEs.js";import{n as S}from"./runner-facts-BpvNgJqf.js";import{i as C,n as w}from"./agent-accounts-Bxqcccek.js";import{Ft as T,P as E,Qt as D}from"./index-aCWAgBiE.js";var O=e(i(),1),k=a(),A=e=>e.split(`@`)[0]||e,j={project:0,user:1,plugin:2,system:3,other:4},M={project:`This project`,user:`Your skills`,system:`Built in`,other:`Other`};function N(e){if(e.plugin)return{key:`plugin:${e.plugin}`,label:A(e.plugin),kind:`plugin`};let t=e.scope===`repo`?`project`:e.scope===`user`?`user`:e.scope===`system`?`system`:`other`;return{key:t,label:M[t],kind:t}}function P(e){let t=new Map;for(let n of e){let e=N(n),r=t.get(e.key)??{...e,skills:[]};r.skills.push(n),t.set(e.key,r)}return[...t.values()].sort((e,t)=>j[e.kind]-j[t.kind]||e.label.localeCompare(t.label))}function F(e){let t=e.plugin?`${A(e.plugin)}:`:``;return t&&e.name.startsWith(t)&&e.name.length>t.length?e.name.slice(t.length):e.name}var I={project:p,user:g,plugin:f,system:f,other:f};function L({groups:e,openId:t,searching:n,runner:r,account:i}){let[a,o]=(0,O.useState)(new Set),s=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,k.jsx)(`div`,{"data-slot":`skills-list`,className:`overflow-hidden rounded-xl border border-border bg-card`,children:e.map(e=>{let o=n||!a.has(e.key);return(0,k.jsxs)(`section`,{"data-slot":`skill-group`,"aria-label":e.label,className:`border-border not-first:border-t`,children:[(0,k.jsx)(R,{group:e,open:o,onToggle:()=>s(e.key)}),o?e.skills.map(e=>(0,k.jsx)(z,{skill:e,open:e.id===t,runner:r,account:i},b(e))):null]},e.key)})})}function R({group:e,open:t,onToggle:n}){let i=I[e.kind];return(0,k.jsx)(`h2`,{className:`m-0`,children:(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:n,className:`flex min-h-10 w-full items-center gap-2 bg-muted/45 px-3.5 text-left text-xs font-semibold text-muted-foreground focus-visible:outline-2 focus-visible:-outline-offset-2 pointer-hover:text-foreground`,children:[(0,k.jsx)(v,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform motion-reduce:transition-none`,t&&`rotate-90`)}),(0,k.jsx)(i,{"aria-hidden":`true`,className:`size-3.5`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),(0,k.jsx)(`span`,{className:`font-medium text-soft-foreground`,children:e.skills.length})]})})}function z({skill:e,open:t,runner:r,account:i}){let a=T({skill:e.id,skillPath:e.path,runner:r,...i?{account:i}:{}});return(0,k.jsxs)(`details`,{"data-slot":`skill-row`,"data-skill":e.id,"data-skill-path":e.path,name:`skill-details`,open:t||void 0,className:`group/skill border-t border-border/60 open:bg-sidebar-row-selected`,children:[(0,k.jsxs)(`summary`,{className:`grid min-h-11 cursor-pointer list-none grid-cols-1 items-baseline gap-x-4 gap-y-0.5 py-2.5 pr-3.5 pl-9 focus-visible:outline-2 focus-visible:-outline-offset-2 pointer-hover:bg-sidebar-row-hover sm:grid-cols-[minmax(10rem,15rem)_minmax(0,1fr)] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(`span`,{className:`truncate text-[13.5px] font-semibold`,title:e.name,children:F(e)}),e.description?(0,k.jsx)(`span`,{className:`truncate text-[13px] text-muted-foreground group-open/skill:hidden`,children:e.description}):null]}),(0,k.jsx)(`div`,{className:`pr-3.5 pb-4 pl-9`,children:(0,k.jsx)(E,{skill:e,heading:null,actions:(0,k.jsx)(n,{asChild:!0,size:`sm`,"data-action":`start-task`,children:(0,k.jsx)(y,{to:a,children:`Start task`})})})})]})}function B(){let e=l(),[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(null),[u,d]=(0,O.useState)(``),[f]=t(),p=i??e.data?.defaultRunner??`claude`,g=c(i??e.data?.defaultRunner,o),_=G(p,g.account),v=g.data??[];return(0,k.jsxs)(`div`,{"data-route":`skills`,className:`mx-auto grid min-h-full w-full max-w-[1100px] content-start gap-5 px-[18px] py-6 md:p-9 max-md:[padding-block-end:5rem]`,children:[(0,k.jsxs)(`header`,{children:[(0,k.jsx)(`h1`,{className:`text-[25px] font-semibold tracking-tight md:text-[30px]`,children:`Skills`}),(0,k.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`The skills each agent loads in this project, as its runner reports them.`})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(H,{runner:p,onChange:e=>{a(e),s(null)}}),(0,k.jsx)(U,{runner:p,account:o,onChange:s}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-soft-foreground`,"data-slot":`skills-count`,children:g.list?`${v.length} ${v.length===1?`skill`:`skills`}${g.list.source===`cache`?` · from cache`:``}`:null}),(0,k.jsxs)(n,{variant:`outline`,size:`sm`,onClick:()=>void _.run(),disabled:_.running||g.isPending,"data-slot":`skills-refresh`,children:[(0,k.jsx)(h,{"aria-hidden":`true`,className:r(`size-3.5`,_.running&&`motion-safe:animate-spin`)}),`Re-read`]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(D,{"aria-label":`Search skills`,placeholder:`Filter by name or description…`,value:u,onChange:e=>d(e.target.value),className:`h-10 bg-card pl-9 text-[13px]`})]}),(0,k.jsx)(W,{query:g}),g.isPending?(0,k.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Loading skills…`}):(0,k.jsx)(V,{skills:v,search:u,openId:f.get(`skill`),runner:p,account:g.account??null,unchecked:g.unchecked})]})}function V({skills:e,search:t,openId:n,runner:r,account:i,unchecked:a}){if(e.length===0)return a?null:(0,k.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`No skills reported by this runner and account.`});let o=x(e,t);return o.length===0?(0,k.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`No skills match “`,t.trim(),`”.`]}):(0,k.jsx)(L,{groups:P(o),openId:n,searching:t.trim()!==``,runner:r,account:i})}function H({runner:e,onChange:t}){return(0,k.jsx)(`div`,{role:`group`,"aria-label":`Runner`,className:`flex max-w-full gap-0.5 overflow-x-auto rounded-[10px] border border-border bg-card p-[3px]`,children:C.map(n=>(0,k.jsx)(`button`,{type:`button`,"aria-pressed":n.id===e,onClick:()=>t(n.id),className:`h-8 shrink-0 rounded-[7px] px-3 text-[13px] text-muted-foreground focus-visible:outline-2 aria-pressed:bg-muted aria-pressed:font-semibold aria-pressed:text-foreground pointer-hover:text-foreground`,children:S(n.id)},n.id))})}function U({runner:e,account:t,onChange:n}){let r=w().accounts.filter(t=>t.provider===e);return r.length===0?null:(0,k.jsxs)(`select`,{"aria-label":`Account`,value:t??``,onChange:e=>n(e.target.value||null),className:`h-[38px] rounded-md border border-border bg-card px-2.5 text-[13px] text-foreground focus-visible:outline-2`,children:[(0,k.jsx)(`option`,{value:``,children:`Account: project default`}),r.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function W({query:e}){let t=e.list?.problems??[];return!e.unchecked&&t.length===0?null:(0,k.jsxs)(`div`,{className:`grid gap-1.5 rounded-lg border border-pending/40 bg-pending/10 px-3.5 py-2.5 text-[13px]`,children:[e.unchecked&&!e.isPending?(0,k.jsxs)(`p`,{role:`status`,className:`flex gap-2`,children:[(0,k.jsx)(_,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{children:[`Skill list unavailable. `,e.list?.reason??e.error?.message,` You can still type a skill id when starting a task.`]})]}):null,t.map((e,t)=>(0,k.jsxs)(`p`,{role:`alert`,className:`flex gap-2 break-words`,children:[(0,k.jsx)(_,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{children:[e.message,e.path?` · ${e.path}`:``]})]},t))]})}function G(e,t){let n=o(),[r,i]=(0,O.useState)(!1),a=u.runnerSkills(e,t);return{running:r,run:async()=>{i(!0);try{n.setQueryData(a,await s(e,t,{refresh:!0})),await n.invalidateQueries({queryKey:a.slice(0,3)})}catch(e){d(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{i(!1)}}}}export{B as SkillsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Lr as o,Tt as s}from"./project-scope-context-DhjdxoB5.js";import{Rt as c,m as l,n as u}from"./queries-DQWq3QYH.js";import{n as d}from"./toaster-CoMJoQvk.js";import{O as f,T as p,X as m,Y as h,ct as g,ot as _,u as v}from"./design-icons-B6-0w7Aw.js";import{t as y}from"./project-router-4acCokGM.js";import{f as b,l as x}from"./skills-pM_PouEs.js";import{n as S}from"./runner-facts-BpvNgJqf.js";import{i as C,n as w}from"./agent-accounts-CrhI2D79.js";import{Ft as T,P as E,Qt as D}from"./index-8QnR_MBI.js";var O=e(i(),1),k=a(),A=e=>e.split(`@`)[0]||e,j={project:0,user:1,plugin:2,system:3,other:4},M={project:`This project`,user:`Your skills`,system:`Built in`,other:`Other`};function N(e){if(e.plugin)return{key:`plugin:${e.plugin}`,label:A(e.plugin),kind:`plugin`};let t=e.scope===`repo`?`project`:e.scope===`user`?`user`:e.scope===`system`?`system`:`other`;return{key:t,label:M[t],kind:t}}function P(e){let t=new Map;for(let n of e){let e=N(n),r=t.get(e.key)??{...e,skills:[]};r.skills.push(n),t.set(e.key,r)}return[...t.values()].sort((e,t)=>j[e.kind]-j[t.kind]||e.label.localeCompare(t.label))}function F(e){let t=e.plugin?`${A(e.plugin)}:`:``;return t&&e.name.startsWith(t)&&e.name.length>t.length?e.name.slice(t.length):e.name}var I={project:p,user:g,plugin:f,system:f,other:f};function L({groups:e,openId:t,searching:n,runner:r,account:i}){let[a,o]=(0,O.useState)(new Set),s=e=>o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,k.jsx)(`div`,{"data-slot":`skills-list`,className:`overflow-hidden rounded-xl border border-border bg-card`,children:e.map(e=>{let o=n||!a.has(e.key);return(0,k.jsxs)(`section`,{"data-slot":`skill-group`,"aria-label":e.label,className:`border-border not-first:border-t`,children:[(0,k.jsx)(R,{group:e,open:o,onToggle:()=>s(e.key)}),o?e.skills.map(e=>(0,k.jsx)(z,{skill:e,open:e.id===t,runner:r,account:i},b(e))):null]},e.key)})})}function R({group:e,open:t,onToggle:n}){let i=I[e.kind];return(0,k.jsx)(`h2`,{className:`m-0`,children:(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:n,className:`flex min-h-10 w-full items-center gap-2 bg-muted/45 px-3.5 text-left text-xs font-semibold text-muted-foreground focus-visible:outline-2 focus-visible:-outline-offset-2 pointer-hover:text-foreground`,children:[(0,k.jsx)(v,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform motion-reduce:transition-none`,t&&`rotate-90`)}),(0,k.jsx)(i,{"aria-hidden":`true`,className:`size-3.5`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),(0,k.jsx)(`span`,{className:`font-medium text-soft-foreground`,children:e.skills.length})]})})}function z({skill:e,open:t,runner:r,account:i}){let a=T({skill:e.id,skillPath:e.path,runner:r,...i?{account:i}:{}});return(0,k.jsxs)(`details`,{"data-slot":`skill-row`,"data-skill":e.id,"data-skill-path":e.path,name:`skill-details`,open:t||void 0,className:`group/skill border-t border-border/60 open:bg-sidebar-row-selected`,children:[(0,k.jsxs)(`summary`,{className:`grid min-h-11 cursor-pointer list-none grid-cols-1 items-baseline gap-x-4 gap-y-0.5 py-2.5 pr-3.5 pl-9 focus-visible:outline-2 focus-visible:-outline-offset-2 pointer-hover:bg-sidebar-row-hover sm:grid-cols-[minmax(10rem,15rem)_minmax(0,1fr)] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(`span`,{className:`truncate text-[13.5px] font-semibold`,title:e.name,children:F(e)}),e.description?(0,k.jsx)(`span`,{className:`truncate text-[13px] text-muted-foreground group-open/skill:hidden`,children:e.description}):null]}),(0,k.jsx)(`div`,{className:`pr-3.5 pb-4 pl-9`,children:(0,k.jsx)(E,{skill:e,heading:null,actions:(0,k.jsx)(n,{asChild:!0,size:`sm`,"data-action":`start-task`,children:(0,k.jsx)(y,{to:a,children:`Start task`})})})})]})}function B(){let e=l(),[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(null),[u,d]=(0,O.useState)(``),[f]=t(),p=i??e.data?.defaultRunner??`claude`,g=c(i??e.data?.defaultRunner,o),_=G(p,g.account),v=g.data??[];return(0,k.jsxs)(`div`,{"data-route":`skills`,className:`mx-auto grid min-h-full w-full max-w-[1100px] content-start gap-5 px-[18px] py-6 md:p-9 max-md:[padding-block-end:5rem]`,children:[(0,k.jsxs)(`header`,{children:[(0,k.jsx)(`h1`,{className:`text-[25px] font-semibold tracking-tight md:text-[30px]`,children:`Skills`}),(0,k.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`The skills each agent loads in this project, as its runner reports them.`})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(H,{runner:p,onChange:e=>{a(e),s(null)}}),(0,k.jsx)(U,{runner:p,account:o,onChange:s}),(0,k.jsx)(`span`,{className:`ml-auto text-xs text-soft-foreground`,"data-slot":`skills-count`,children:g.list?`${v.length} ${v.length===1?`skill`:`skills`}${g.list.source===`cache`?` · from cache`:``}`:null}),(0,k.jsxs)(n,{variant:`outline`,size:`sm`,onClick:()=>void _.run(),disabled:_.running||g.isPending,"data-slot":`skills-refresh`,children:[(0,k.jsx)(h,{"aria-hidden":`true`,className:r(`size-3.5`,_.running&&`motion-safe:animate-spin`)}),`Re-read`]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(D,{"aria-label":`Search skills`,placeholder:`Filter by name or description…`,value:u,onChange:e=>d(e.target.value),className:`h-10 bg-card pl-9 text-[13px]`})]}),(0,k.jsx)(W,{query:g}),g.isPending?(0,k.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Loading skills…`}):(0,k.jsx)(V,{skills:v,search:u,openId:f.get(`skill`),runner:p,account:g.account??null,unchecked:g.unchecked})]})}function V({skills:e,search:t,openId:n,runner:r,account:i,unchecked:a}){if(e.length===0)return a?null:(0,k.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`No skills reported by this runner and account.`});let o=x(e,t);return o.length===0?(0,k.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`No skills match “`,t.trim(),`”.`]}):(0,k.jsx)(L,{groups:P(o),openId:n,searching:t.trim()!==``,runner:r,account:i})}function H({runner:e,onChange:t}){return(0,k.jsx)(`div`,{role:`group`,"aria-label":`Runner`,className:`flex max-w-full gap-0.5 overflow-x-auto rounded-[10px] border border-border bg-card p-[3px]`,children:C.map(n=>(0,k.jsx)(`button`,{type:`button`,"aria-pressed":n.id===e,onClick:()=>t(n.id),className:`h-8 shrink-0 rounded-[7px] px-3 text-[13px] text-muted-foreground focus-visible:outline-2 aria-pressed:bg-muted aria-pressed:font-semibold aria-pressed:text-foreground pointer-hover:text-foreground`,children:S(n.id)},n.id))})}function U({runner:e,account:t,onChange:n}){let r=w().accounts.filter(t=>t.provider===e);return r.length===0?null:(0,k.jsxs)(`select`,{"aria-label":`Account`,value:t??``,onChange:e=>n(e.target.value||null),className:`h-[38px] rounded-md border border-border bg-card px-2.5 text-[13px] text-foreground focus-visible:outline-2`,children:[(0,k.jsx)(`option`,{value:``,children:`Account: project default`}),r.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function W({query:e}){let t=e.list?.problems??[];return!e.unchecked&&t.length===0?null:(0,k.jsxs)(`div`,{className:`grid gap-1.5 rounded-lg border border-pending/40 bg-pending/10 px-3.5 py-2.5 text-[13px]`,children:[e.unchecked&&!e.isPending?(0,k.jsxs)(`p`,{role:`status`,className:`flex gap-2`,children:[(0,k.jsx)(_,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{children:[`Skill list unavailable. `,e.list?.reason??e.error?.message,` You can still type a skill id when starting a task.`]})]}):null,t.map((e,t)=>(0,k.jsxs)(`p`,{role:`alert`,className:`flex gap-2 break-words`,children:[(0,k.jsx)(_,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{children:[e.message,e.path?` · ${e.path}`:``]})]},t))]})}function G(e,t){let n=o(),[r,i]=(0,O.useState)(!1),a=u.runnerSkills(e,t);return{running:r,run:async()=>{i(!0);try{n.setQueryData(a,await s(e,t,{refresh:!0})),await n.invalidateQueries({queryKey:a.slice(0,3)})}catch(e){d(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{i(!1)}}}}export{B as SkillsRoute};
@@ -1 +1 @@
1
- import{l as e,u as t}from"./button-DGwhwRuD.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./project-router-0DHZ1s8l.js";var i=n();function a({to:n,active:a=!1,onClick:o,count:s,replace:c,className:l,children:u}){return(0,i.jsxs)(r,{to:n,...e({replace:c}),"aria-current":a?`page`:void 0,onClick:o,className:t(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,a?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`,l),children:[u,s===void 0?null:(0,i.jsx)(`span`,{"data-slot":`tab-count`,className:`ml-1.5 text-[11.5px] font-normal text-soft-foreground`,children:s})]})}export{a as t};
1
+ import{l as e,u as t}from"./button-DGwhwRuD.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./project-router-4acCokGM.js";var i=n();function a({to:n,active:a=!1,onClick:o,count:s,replace:c,className:l,children:u}){return(0,i.jsxs)(r,{to:n,...e({replace:c}),"aria-current":a?`page`:void 0,onClick:o,className:t(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,a?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`,l),children:[u,s===void 0?null:(0,i.jsx)(`span`,{"data-slot":`tab-count`,className:`ml-1.5 text-[11.5px] font-normal text-soft-foreground`,children:s})]})}export{a as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n}from"./button-DGwhwRuD.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{Bt as a,Kt as o,Lr as s,Rt as c,Zn as l,cn as u,h as d,i as f,w as p,yt as m}from"./project-scope-context-qMCI2vmR.js";import{N as h,Yt as g,ft as _,n as v,pt as y,st as b}from"./queries-DFchmPfl.js";import{n as x,q as S,z as C}from"./use-desktop-CdWXLHne.js";import{n as w}from"./toaster-CoMJoQvk.js";import{C as T,j as E}from"./design-icons-B6-0w7Aw.js";import{t as D}from"./run-header-DBbM_xNy.js";import{i as O,n as k,r as A}from"./git-toolbar-CvG0gvVf.js";import{a as j,i as M,o as N,r as P,s as F,t as I}from"./dialog-tMSuX5a7.js";import{t as L}from"./centered-state-B5QmAy2y.js";import{D as R,E as z,L as B,V,wt as H}from"./index-aCWAgBiE.js";import{t as U}from"./markdown-BBDDg-4t.js";import{t as W}from"./diff-BvBs4Gxp.js";var G=e(r(),1),K=`no worktree — this task ran directly in the repo working tree`;function q(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${K}`)}function J(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${K}`)}function Y(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${K}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?l(e.run)?t(`Create PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):S(e.run)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function X(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:q(e),n=e.prUrl?[q(e),J(e)]:[J(e),Y(e)],r=[];if(e.localHandoff){let t=e.hasSession?S(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var Z=i();function Q({run:e,open:t,onOpenChange:r}){let i=s(),[a,o]=(0,G.useState)(``),c=C(e),l=(0,G.useRef)(c);l.current=c,(0,G.useEffect)(()=>{t&&o(l.current)},[t]);let u=g({mutationFn:t=>d(e.id,t),onSuccess:t=>{w(`Committed ${t.sha.slice(0,7)}`),r(!1),i.invalidateQueries({queryKey:v.runs.changes(e.id)}),i.invalidateQueries({queryKey:v.runs.all})},onError:e=>w(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Z.jsx)(I,{open:t,onOpenChange:r,children:(0,Z.jsxs)(P,{"data-slot":`commit-dialog`,children:[(0,Z.jsxs)(N,{children:[(0,Z.jsx)(F,{children:`Commit changes`}),(0,Z.jsxs)(M,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Z.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Z.jsx)(V,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{B({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(n,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsx)(n,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function $(){let{id:e}=t(),n=_(e);return n.isPending?(0,Z.jsx)(R,{tab:`changes`}):n.isError?(0,Z.jsx)(z,{tab:`changes`,error:n.error}):(0,Z.jsx)(ee,{run:n.data})}function ee({run:e}){let t=h(),n=b(),r=y(e.id,S(e)),i=x(),[l,u]=(0,G.useState)(`unified`),[d,m]=(0,G.useState)(!1),[_,C]=(0,G.useState)(!1),[T,E]=(0,G.useState)(null),[O,j]=(0,G.useState)(!1),M=(0,G.useRef)(null),N=s(),P=()=>N.invalidateQueries({queryKey:v.runs.all}),F=e=>w(e.message,{tone:`danger`}),I=g({mutationFn:()=>o(e.id),onSuccess:e=>w(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:F}),L=g({mutationFn:()=>p(e.id),onSuccess:e=>{w(`Draft PR created — ${e.url}`),P()},onError:F}),R=g({mutationFn:()=>a(e.id),onError:e=>{if(e instanceof f&&e.command){navigator.clipboard.writeText(e.command).then(()=>w(`No terminal found — command copied to clipboard.`)).catch(()=>w(`Run manually: ${e.command}`));return}F(e)}}),z=g({mutationFn:t=>c(e.id,t),onError:F}),B=r.isError&&r.error instanceof f&&r.error.status===409,V=X({run:e,hasWorktree:!!e.worktreePath&&!B,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:H(e)!==void 0,prUrl:e.pullRequestUrl}),W=e=>{switch(e){case`commit`:j(!0);break;case`push`:I.mutate();break;case`create-pr`:L.mutate();break;case`open-terminal`:R.mutate();break;case`view-pr`:break}},K=r.data?.files??[],q=(0,G.useMemo)(()=>A(K),[K]),J=(0,G.useMemo)(()=>K.some(U),[K]),Y=i?l:`unified`,$=!i||d;return(0,Z.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(D,{run:e,tab:`changes`}),(0,Z.jsx)(k,{bar:V,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:Y,wrap:$,preview:_,onModeChange:u,onWrapChange:m,onPreviewChange:J?C:void 0,onAction:W}),r.data?.repointedHead?(0,Z.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,Z.jsx)(te,{changes:r,changesRefused:B,fileCount:K.length,children:(0,Z.jsx)(ne,{runId:e.id,files:K,tree:q,selected:T,selectFile:e=>{E(e),M.current?.scrollToPath(e)},diffRef:M,effectiveMode:Y,effectiveWrap:$,preview:_,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:z.mutate})}),(0,Z.jsx)(Q,{run:e,open:O,onOpenChange:j})]})}function te({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(L,{icon:t?(0,Z.jsx)(T,{size:16}):(0,Z.jsx)(E,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,Z.jsx)(L,{icon:(0,Z.jsx)(T,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function ne({runId:e,files:t,tree:n,selected:r,selectFile:i,diffRef:a,effectiveMode:o,effectiveWrap:s,preview:c,localHandoff:l,onOpenInApp:d}){return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(O,{root:n,selected:r,onSelect:i})]}),(0,Z.jsx)(W,{files:t,viewRef:a,mode:o,wrap:s,preview:c,loadFileText:t=>re(e,t),imageSrc:t=>u(e,t),onOpenInApp:l?e=>d(e):void 0,className:`min-w-0 flex-1`})]})}async function re(e,t){try{let n=await m(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{$ as TaskChangesRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n}from"./button-DGwhwRuD.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{Bt as a,Kt as o,Lr as s,Rt as c,Zn as l,cn as u,h as d,i as f,w as p,yt as m}from"./project-scope-context-DhjdxoB5.js";import{N as h,Yt as g,ft as _,n as v,pt as y,st as b}from"./queries-DQWq3QYH.js";import{n as x,q as S,z as C}from"./use-desktop-B27Z5VAz.js";import{n as w}from"./toaster-CoMJoQvk.js";import{C as T,j as E}from"./design-icons-B6-0w7Aw.js";import{t as D}from"./run-header-Bfg4NPUu.js";import{i as O,n as k,r as A}from"./git-toolbar-BIMZxkIR.js";import{a as j,i as M,o as N,r as P,s as F,t as I}from"./dialog-tMSuX5a7.js";import{t as L}from"./centered-state-B5QmAy2y.js";import{D as R,E as z,L as B,V,wt as H}from"./index-8QnR_MBI.js";import{t as U}from"./markdown-BBDDg-4t.js";import{t as W}from"./diff-DsC9nsup.js";var G=e(r(),1),K=`no worktree — this task ran directly in the repo working tree`;function q(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${K}`)}function J(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${K}`)}function Y(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${K}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?l(e.run)?t(`Create PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):S(e.run)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function X(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:q(e),n=e.prUrl?[q(e),J(e)]:[J(e),Y(e)],r=[];if(e.localHandoff){let t=e.hasSession?S(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var Z=i();function Q({run:e,open:t,onOpenChange:r}){let i=s(),[a,o]=(0,G.useState)(``),c=C(e),l=(0,G.useRef)(c);l.current=c,(0,G.useEffect)(()=>{t&&o(l.current)},[t]);let u=g({mutationFn:t=>d(e.id,t),onSuccess:t=>{w(`Committed ${t.sha.slice(0,7)}`),r(!1),i.invalidateQueries({queryKey:v.runs.changes(e.id)}),i.invalidateQueries({queryKey:v.runs.all})},onError:e=>w(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Z.jsx)(I,{open:t,onOpenChange:r,children:(0,Z.jsxs)(P,{"data-slot":`commit-dialog`,children:[(0,Z.jsxs)(N,{children:[(0,Z.jsx)(F,{children:`Commit changes`}),(0,Z.jsxs)(M,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Z.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Z.jsx)(V,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{B({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(n,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsx)(n,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function $(){let{id:e}=t(),n=_(e);return n.isPending?(0,Z.jsx)(R,{tab:`changes`}):n.isError?(0,Z.jsx)(z,{tab:`changes`,error:n.error}):(0,Z.jsx)(ee,{run:n.data})}function ee({run:e}){let t=h(),n=b(),r=y(e.id,S(e)),i=x(),[l,u]=(0,G.useState)(`unified`),[d,m]=(0,G.useState)(!1),[_,C]=(0,G.useState)(!1),[T,E]=(0,G.useState)(null),[O,j]=(0,G.useState)(!1),M=(0,G.useRef)(null),N=s(),P=()=>N.invalidateQueries({queryKey:v.runs.all}),F=e=>w(e.message,{tone:`danger`}),I=g({mutationFn:()=>o(e.id),onSuccess:e=>w(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:F}),L=g({mutationFn:()=>p(e.id),onSuccess:e=>{w(`Draft PR created — ${e.url}`),P()},onError:F}),R=g({mutationFn:()=>a(e.id),onError:e=>{if(e instanceof f&&e.command){navigator.clipboard.writeText(e.command).then(()=>w(`No terminal found — command copied to clipboard.`)).catch(()=>w(`Run manually: ${e.command}`));return}F(e)}}),z=g({mutationFn:t=>c(e.id,t),onError:F}),B=r.isError&&r.error instanceof f&&r.error.status===409,V=X({run:e,hasWorktree:!!e.worktreePath&&!B,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:H(e)!==void 0,prUrl:e.pullRequestUrl}),W=e=>{switch(e){case`commit`:j(!0);break;case`push`:I.mutate();break;case`create-pr`:L.mutate();break;case`open-terminal`:R.mutate();break;case`view-pr`:break}},K=r.data?.files??[],q=(0,G.useMemo)(()=>A(K),[K]),J=(0,G.useMemo)(()=>K.some(U),[K]),Y=i?l:`unified`,$=!i||d;return(0,Z.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(D,{run:e,tab:`changes`}),(0,Z.jsx)(k,{bar:V,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:Y,wrap:$,preview:_,onModeChange:u,onWrapChange:m,onPreviewChange:J?C:void 0,onAction:W}),r.data?.repointedHead?(0,Z.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Z.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,Z.jsx)(te,{changes:r,changesRefused:B,fileCount:K.length,children:(0,Z.jsx)(ne,{runId:e.id,files:K,tree:q,selected:T,selectFile:e=>{E(e),M.current?.scrollToPath(e)},diffRef:M,effectiveMode:Y,effectiveWrap:$,preview:_,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:z.mutate})}),(0,Z.jsx)(Q,{run:e,open:O,onOpenChange:j})]})}function te({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(L,{icon:t?(0,Z.jsx)(T,{size:16}):(0,Z.jsx)(E,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,Z.jsx)(L,{icon:(0,Z.jsx)(T,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function ne({runId:e,files:t,tree:n,selected:r,selectFile:i,diffRef:a,effectiveMode:o,effectiveWrap:s,preview:c,localHandoff:l,onOpenInApp:d}){return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(O,{root:n,selected:r,onSelect:i})]}),(0,Z.jsx)(W,{files:t,viewRef:a,mode:o,wrap:s,preview:c,loadFileText:t=>re(e,t),imageSrc:t=>u(e,t),onOpenInApp:l?e=>d(e):void 0,className:`min-w-0 flex-1`})]})}async function re(e,t){try{let n=await m(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{$ as TaskChangesRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,u as n}from"./button-DGwhwRuD.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{i as a}from"./project-scope-context-qMCI2vmR.js";import{ft as o,ht as s,mt as c,pt as l}from"./queries-DFchmPfl.js";import{q as u}from"./use-desktop-CdWXLHne.js";import{C as d,S as f,X as p,j as m}from"./design-icons-B6-0w7Aw.js";import{t as h}from"./run-header-DBbM_xNy.js";import{t as g}from"./project-router-0DHZ1s8l.js";import{t as _}from"./centered-state-B5QmAy2y.js";import{D as v,E as y,Qt as b,s as x}from"./index-aCWAgBiE.js";import{t as S}from"./commit-diff-panel-OWVorWVw.js";var C=e(r(),1),w=i(),T=77;function E({slot:e,commits:t,className:r,heading:i}){let[a,o]=(0,C.useState)(``),s=a.trim().toLowerCase(),c=s?t.filter(e=>e.subject.toLowerCase().includes(s)):t,l=c.length>150,u=(0,C.useRef)(null),d=(0,C.useRef)(null),[f,m]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=u.current,t=d.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=c.map(n=>(0,w.jsx)(D,{commit:n,detailed:e===`task-commits`&&t.length===1},n.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-[22px] block`,children:[(0,w.jsx)(p,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3.5 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(b,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:a,onChange:e=>o(e.target.value),className:`h-11 bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{u.current=e,e&&(d.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:n(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-4 py-1 md:px-5`,r),children:[i?(0,w.jsx)(`div`,{className:`flex min-h-14 flex-wrap items-center gap-2 py-4`,children:i}):null,c.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,l?(0,w.jsx)(x,{scrollRef:d,startMargin:f,itemSize:T,children:h}):h]})]})}function D({commit:e,detailed:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_77px] [content-visibility:auto]`,children:(0,w.jsxs)(g,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,className:n(`flex min-h-[76px] min-w-0 flex-col items-start gap-3 rounded-sm py-4 hover:bg-muted`,!t&&`md:flex-row md:items-center md:py-3`),children:[(0,w.jsx)(m,{size:16,"aria-hidden":`true`,className:n(`shrink-0 text-accent-text`,t?`size-[22px]`:`size-4`)}),(0,w.jsxs)(`span`,{className:n(`min-w-0 w-full`,!t&&`md:w-auto md:flex-1`),children:[(0,w.jsx)(`span`,{className:n(`block font-normal`,t?`text-[22px] leading-snug`:`text-[13px] md:truncate`),children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-soft-foreground`,children:[e.author,` · `,e.when]})]}),(0,w.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),t?(0,w.jsxs)(`span`,{className:`inline-flex min-h-11 items-center gap-2 rounded-lg bg-action px-3 text-xs font-medium text-action-foreground`,children:[(0,w.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-4`}),`View changes`]}):null]})})}function O(){let{id:e}=t(),n=o(e);return n.isPending?(0,w.jsx)(v,{tab:`changes`}):n.isError?(0,w.jsx)(y,{tab:`changes`,error:n.error}):(0,w.jsx)(k,{run:n.data})}function k({run:e}){let{sha:n}=t(),r=s(e.id,u(e));return(0,w.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,w.jsx)(h,{run:e,tab:`commits`}),n?(0,w.jsx)(A,{runId:e.id,sha:n}):r.isPending?(0,w.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):r.isError?(0,w.jsx)(_,{icon:(0,w.jsx)(m,{size:16}),tone:r.error instanceof a&&r.error.status===409?`neutral`:`danger`,heading:`h2`,title:r.error instanceof a&&r.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:r.error.message}):r.data.commits.length===0?(0,w.jsx)(_,{icon:(0,w.jsx)(m,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,w.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,w.jsx)(E,{slot:`task-commits`,heading:(0,w.jsxs)(`h2`,{className:`text-base font-semibold`,children:[r.data.commits.length,` `,r.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:r.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,w.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){return(0,w.jsx)(S,{commit:c(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`})}function j({run:e}){let t=l(e.id,u(e));return t.isPending?(0,w.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,w.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,w.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,w.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,w.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,w.jsx)(`li`,{children:(0,w.jsxs)(g,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,w.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,w.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,u as n}from"./button-DGwhwRuD.js";import{i as r,t as i}from"./react-runtime-CCIEwYL0.js";import{i as a}from"./project-scope-context-DhjdxoB5.js";import{ft as o,ht as s,mt as c,pt as l}from"./queries-DQWq3QYH.js";import{q as u}from"./use-desktop-B27Z5VAz.js";import{C as d,S as f,X as p,j as m}from"./design-icons-B6-0w7Aw.js";import{t as h}from"./run-header-Bfg4NPUu.js";import{t as g}from"./project-router-4acCokGM.js";import{t as _}from"./centered-state-B5QmAy2y.js";import{D as v,E as y,Qt as b,s as x}from"./index-8QnR_MBI.js";import{t as S}from"./commit-diff-panel-BaxN0Drk.js";var C=e(r(),1),w=i(),T=77;function E({slot:e,commits:t,className:r,heading:i}){let[a,o]=(0,C.useState)(``),s=a.trim().toLowerCase(),c=s?t.filter(e=>e.subject.toLowerCase().includes(s)):t,l=c.length>150,u=(0,C.useRef)(null),d=(0,C.useRef)(null),[f,m]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=u.current,t=d.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=c.map(n=>(0,w.jsx)(D,{commit:n,detailed:e===`task-commits`&&t.length===1},n.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-[22px] block`,children:[(0,w.jsx)(p,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3.5 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(b,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:a,onChange:e=>o(e.target.value),className:`h-11 bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{u.current=e,e&&(d.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:n(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-4 py-1 md:px-5`,r),children:[i?(0,w.jsx)(`div`,{className:`flex min-h-14 flex-wrap items-center gap-2 py-4`,children:i}):null,c.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,l?(0,w.jsx)(x,{scrollRef:d,startMargin:f,itemSize:T,children:h}):h]})]})}function D({commit:e,detailed:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_77px] [content-visibility:auto]`,children:(0,w.jsxs)(g,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,className:n(`flex min-h-[76px] min-w-0 flex-col items-start gap-3 rounded-sm py-4 hover:bg-muted`,!t&&`md:flex-row md:items-center md:py-3`),children:[(0,w.jsx)(m,{size:16,"aria-hidden":`true`,className:n(`shrink-0 text-accent-text`,t?`size-[22px]`:`size-4`)}),(0,w.jsxs)(`span`,{className:n(`min-w-0 w-full`,!t&&`md:w-auto md:flex-1`),children:[(0,w.jsx)(`span`,{className:n(`block font-normal`,t?`text-[22px] leading-snug`:`text-[13px] md:truncate`),children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-soft-foreground`,children:[e.author,` · `,e.when]})]}),(0,w.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),t?(0,w.jsxs)(`span`,{className:`inline-flex min-h-11 items-center gap-2 rounded-lg bg-action px-3 text-xs font-medium text-action-foreground`,children:[(0,w.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-4`}),`View changes`]}):null]})})}function O(){let{id:e}=t(),n=o(e);return n.isPending?(0,w.jsx)(v,{tab:`changes`}):n.isError?(0,w.jsx)(y,{tab:`changes`,error:n.error}):(0,w.jsx)(k,{run:n.data})}function k({run:e}){let{sha:n}=t(),r=s(e.id,u(e));return(0,w.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,w.jsx)(h,{run:e,tab:`commits`}),n?(0,w.jsx)(A,{runId:e.id,sha:n}):r.isPending?(0,w.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):r.isError?(0,w.jsx)(_,{icon:(0,w.jsx)(m,{size:16}),tone:r.error instanceof a&&r.error.status===409?`neutral`:`danger`,heading:`h2`,title:r.error instanceof a&&r.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:r.error.message}):r.data.commits.length===0?(0,w.jsx)(_,{icon:(0,w.jsx)(m,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,w.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,w.jsx)(E,{slot:`task-commits`,heading:(0,w.jsxs)(`h2`,{className:`text-base font-semibold`,children:[r.data.commits.length,` `,r.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:r.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,w.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){return(0,w.jsx)(S,{commit:c(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`})}function j({run:e}){let t=l(e.id,u(e));return t.isPending?(0,w.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,w.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,w.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,w.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,w.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,w.jsx)(`li`,{children:(0,w.jsxs)(g,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,w.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,w.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{N as l,i as u,s as d}from"./project-scope-context-qMCI2vmR.js";import{S as f,_t as p,d as m,ft as h,l as g}from"./queries-DFchmPfl.js";import{S as _,T as v,X as y,ot as b,u as x}from"./design-icons-B6-0w7Aw.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{d as C,t as w}from"./run-header-DBbM_xNy.js";import{a as T,i as E,n as D,r as O}from"./file-preview-B6mM_dbK.js";import{t as k}from"./centered-state-B5QmAy2y.js";import{D as A,E as j,Qt as M}from"./index-aCWAgBiE.js";import{r as N}from"./markdown-D4ZGAuSC.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=g(e,r),s=r?o:i,c=(0,I.useContext)(N),u=t(),p=u.pathname.replace(/\/files\/?$/,`/report`)+u.search,m=s.data,h=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(N.Provider,{value:h,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?d(e,_.id,`image`):l(e,n),..._?{downloadUrl:d(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=p(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=h(e),n=H();return t.isPending?(0,L.jsx)(A,{tab:`files`}):t.isError?(0,L.jsx)(j,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=g(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=p(e.id,``),r=m(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[d,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let h=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},g=t.isError&&t.error instanceof u&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&h(`path`,d.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(M,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(k,{icon:g?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:g?`neutral`:`danger`,heading:`h2`,title:g?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>h(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>h(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,T as i,t as a,u as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{N as l,i as u,s as d}from"./project-scope-context-DhjdxoB5.js";import{S as f,_t as p,d as m,ft as h,l as g}from"./queries-DQWq3QYH.js";import{S as _,T as v,X as y,ot as b,u as x}from"./design-icons-B6-0w7Aw.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{d as C,t as w}from"./run-header-Bfg4NPUu.js";import{a as T,i as E,n as D,r as O}from"./file-preview-Bg9lwYd3.js";import{t as k}from"./centered-state-B5QmAy2y.js";import{D as A,E as j,Qt as M}from"./index-8QnR_MBI.js";import{r as N}from"./markdown-C24Y3Ede.js";var P=S(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),F=S(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),I=e(s(),1),L=c();function R({runId:e,path:n,artifactId:r}){let i=f(e,r?null:n),o=g(e,r),s=r?o:i,c=(0,I.useContext)(N),u=t(),p=u.pathname.replace(/\/files\/?$/,`/report`)+u.search,m=s.data,h=(0,I.useMemo)(()=>m?.type===`file`&&m.source!==`artifact`?{runId:e,...c,basePath:m.path}:null,[m,c,e]);if(!n&&!r)return(0,L.jsx)(O,{runId:e,path:null,className:`min-w-0 flex-1`});if(s.isPending)return(0,L.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(s.isError)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:`Could not load this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:s.error.message}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});if(!m)return(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(m.type!==`file`)return(0,L.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,L.jsx)(`h2`,{children:m.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,L.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:m.path}),(0,L.jsx)(`p`,{className:`text-sm`,children:m.reason}),(0,L.jsx)(a,{variant:`outline`,onClick:()=>void s.refetch(),children:`Retry`})]});let _=m.artifact;return(0,L.jsx)(N.Provider,{value:h,children:(0,L.jsx)(D,{runId:e,entry:m,documentPreview:!0,readerHref:p,className:`min-w-0 flex-1`,imageUrl:_?d(e,_.id,`image`):l(e,n),..._?{downloadUrl:d(e,_.id,`download`),snapshot:new Date(_.createdAt).toLocaleString()}:{}},_?.id??m.path)})}var z=new Map;function B(e){let t=e?.filesRestoreKey;return typeof t==`string`&&t?t:null}var V=(0,I.createContext)(null);function H(){let{key:e}=t(),n=i()===`POP`,[r,a]=(0,I.useState)({key:e,generation:0});if(r.key===e)return r.generation;let o={key:e,generation:n?r.generation+1:r.generation};return a(o),o.generation}var U=()=>document.querySelector(`[data-slot="main"]`);function W(e,n){let r=(0,I.useRef)(null),a=t(),o=i()===`POP`?a.key:B(a.state),[s]=(0,I.useState)(()=>{let t=o?z.get(o):void 0;return t?.runId===e?t:null}),c=(0,I.useRef)(new Set(s?.folders??[])),l=(0,I.useRef)(new Set),[u,d]=(0,I.useState)(0),f=(0,I.useRef)(s===null),p=(0,I.useCallback)(()=>{f.current&&z.set(a.key,{runId:e,folders:new Set(c.current),tree:r.current?.scrollTop??0,main:U()?.scrollTop??0})},[a.key,e]),m=(0,I.useMemo)(()=>({isOpen:e=>c.current.has(e),setOpen:(e,t)=>{t?c.current.add(e):c.current.delete(e),p()},loading:(e,t)=>{s?.folders.has(e)&&(t?l.current.add(e):l.current.delete(e),d(l.current.size))}}),[s,p]);return(0,I.useEffect)(()=>{if(f.current||!s||!n||l.current.size>0)return;r.current&&(r.current.scrollTop=s.tree);let e=U();e&&(e.scrollTop=s.main),f.current=!0,p()},[s,n,u,p]),(0,I.useEffect)(()=>{p();let e=[r.current,U()].filter(e=>e!==null);for(let t of e)t.addEventListener(`scroll`,p,{passive:!0});return()=>{for(let t of e)t.removeEventListener(`scroll`,p)}},[p]),{tree:r,folders:m}}function G({runId:e,selected:t,onSelect:n}){return(0,L.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function K({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=p(e,t),o=(0,I.useContext)(V);return(0,I.useEffect)(()=>{if(!(!t||!o))return o.loading(t,a.isPending),()=>o.loading(t,!1)},[o,t,a.isPending]),a.isPending?(0,L.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,L.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,L.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,L.jsx)(L.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,L.jsx)(q,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,L.jsx)(J,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function q({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let s=(0,I.useContext)(V),[c,l]=(0,I.useState)(()=>s?.isOpen(n)??!1);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":c?`open`:`closed`,"aria-expanded":c,onClick:()=>{s?.setOpen(n,!c),l(!c)},className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(x,{size:16,"aria-hidden":`true`,className:o(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,c&&`rotate-90`)}),(0,L.jsx)(v,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),c?(0,L.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,L.jsx)(K,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function J({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let s=i===t,c=T(t)?F:_;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":s?`true`:void 0,onClick:()=>a(t),className:o(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,s?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,L.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,L.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:E(n)})]})})}function Y(){let{id:e}=r(),t=h(e),n=H();return t.isPending?(0,L.jsx)(A,{tab:`files`}):t.isError?(0,L.jsx)(j,{tab:`files`,error:t.error}):(0,L.jsx)(C,{runId:t.data.id,children:(0,L.jsx)(Z,{run:t.data},`${t.data.id}:${n}`)})}function X(e,t,n,r){let i=f(e,r||n!==null?null:t),a=g(e,r?null:n);return r||t===null&&n===null?!0:!(n===null?i:a).isPending}function Z({run:e}){let t=p(e.id,``),r=m(e.id),[i,o]=n(),s=i.get(`path`),c=i.get(`artifact`),l=i.getAll(`path`).length>1||i.getAll(`artifact`).length>1||s!==null&&c!==null,[d,f]=(0,I.useState)(s??``);(0,I.useEffect)(()=>f(s??``),[s]);let h=(e,t)=>{let n=new URLSearchParams(i);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},g=t.isError&&t.error instanceof u&&t.error.status===409,_=X(e.id,s,c,l),v=W(e.id,!t.isPending&&_);return(0,L.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,L.jsx)(w,{run:e,tab:`files`}),(0,L.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&h(`path`,d.trim())},children:[(0,L.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,L.jsx)(y,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,L.jsx)(M,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>f(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,L.jsx)(a,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,L.jsxs)(`aside`,{ref:v.tree,"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,L.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,L.jsx)(k,{icon:g?(0,L.jsx)(P,{}):(0,L.jsx)(b,{size:16}),tone:g?`neutral`:`danger`,heading:`h2`,title:g?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,L.jsx)(V.Provider,{value:v.folders,children:(0,L.jsx)(G,{runId:e.id,selected:s,onSelect:e=>h(`path`,e)})}),(0,L.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),r.isPending?(0,L.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):r.isError?(0,L.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):r.data.artifacts.length===0?(0,L.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,L.jsx)(`ul`,{children:r.data.artifacts.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":e.id===c?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>h(`artifact`,e.id),children:e.name})},e.id))}),(0,L.jsx)(a,{variant:`ghost`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Refresh published files`})]})]}),l?(0,L.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||c!==null||t.isSuccess?(0,L.jsx)(R,{runId:e.id,path:s,artifactId:c}):null]}),(0,L.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{Y as TaskFilesRoute};
@@ -1 +1 @@
1
- import{E as e,d as t,t as n}from"./button-DGwhwRuD.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{$ as i,Lr as a}from"./project-scope-context-qMCI2vmR.js";import{N as o,O as s,T as c,W as l,Y as u,Yt as d,ft as f,n as p}from"./queries-DFchmPfl.js";import{S as m,tt as h,y as g}from"./use-desktop-CdWXLHne.js";import{F as _,ot as v,p as y}from"./design-icons-B6-0w7Aw.js";import{t as b}from"./run-header-DBbM_xNy.js";import{u as x}from"./reference-chip-BJe4UIpL.js";import{t as S}from"./project-router-0DHZ1s8l.js";import{t as C}from"./centered-state-B5QmAy2y.js";import{E as w,T,on as E}from"./index-aCWAgBiE.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-CPxNdj4_.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=f(n);return r.isPending?(0,A.jsx)(T,{kind:t}):r.isError?(0,A.jsx)(w,{tab:`github-item`,error:r.error}):(0,A.jsx)(N,{run:r.data,kind:t})}function N({run:t,kind:r}){let{n:i}=e(),a=Number(i),c=l(),d=u(),f=o(),p=d.isPending||f.isPending,m=g(t,c).some(e=>e.kind===r&&e.number===a),h=s(r,a,m);return(0,A.jsxs)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:[(0,A.jsx)(b,{run:t,tab:{kind:r,number:a}}),m?(0,A.jsx)(V,{run:t,kind:r,number:a,repoBase:c,item:h}):p?(0,A.jsx)(T,{kind:r,number:a,heading:`h2`}):(0,A.jsx)(C,{icon:(0,A.jsx)(E,{size:16}),tone:`neutral`,heading:`h2`,title:`#${i} is not linked to this task`,subtitle:`Only the issues and pull requests this task references open here.`,actions:(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsx)(S,{to:`/tasks/${t.id}`,children:`Back to the session`})})})]})}function P(e,t){return e===`pr`&&t.data?.available===!0&&t.data.item!==null}function F(e,t,n,r){return e===`pr`?n?.[t]??r:r}function I({retry:e,kind:t,number:r}){return(0,A.jsx)(n,{variant:`outline`,disabled:e.isPending,onClick:()=>e.mutate(p.githubItem(t,r)),children:`Retry`})}function L({kind:e,number:t,error:n,retryButton:r}){return(0,A.jsx)(C,{icon:(0,A.jsx)(v,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load ${j[e].toLowerCase()} #${t}`,subtitle:n.message,actions:r})}function R({run:e,kind:r,number:i,repoBase:a,reason:o,retryError:s,retryButton:c}){let l=r===`pr`?_:y,u=m(e,a).find(e=>e.kind===`PR`==(r===`pr`)&&e.number===i)?.url;return(0,A.jsx)(C,{icon:(0,A.jsx)(l,{size:16}),tone:`neutral`,heading:`h2`,title:`GitHub is unavailable`,subtitle:s?.message??o,actions:(0,A.jsxs)(A.Fragment,{children:[c,u&&t(u)?(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,children:[`open on GitHub`,(0,A.jsx)(h,{"aria-hidden":`true`})]})}):null]})})}function z({label:e,repoBase:t}){return(0,A.jsx)(C,{icon:(0,A.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`${e} was not found in ${H(t)}`,subtitle:`It may have been deleted, or the number points at a different repository.`})}function B({kind:e,item:t,labelColors:n,checks:r}){return(0,A.jsx)(`div`,{className:`min-w-0 px-0.5 md:px-2`,children:(0,A.jsx)(O,{item:t,colors:n??{},checks:r,backLink:null,subNav:null,children:e===`issue`?(0,A.jsx)(U,{item:t},t.url):null})})}function V({run:e,kind:t,number:n,repoBase:r,item:o}){let s=a(),l=d({mutationFn:e=>i(t,n,{refresh:!0}),onSuccess:(e,t)=>s.setQueryData(t,e)}),u=P(t,o),f=c(u?[n]:[],u),p=f.data?.available?f.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:l,kind:t,number:n});if(o.isPending)return(0,A.jsx)(T,{kind:t,number:n,heading:`h2`});if(o.isError)return(0,A.jsx)(L,{kind:t,number:n,error:l.error??o.error,retryButton:h});let g=o.data;return g.available?g.item?(0,A.jsx)(B,{kind:t,item:g.item,labelColors:g.labelColors,checks:F(t,n,p,g.item.checks)}):(0,A.jsx)(z,{label:m,repoBase:r}):(0,A.jsx)(R,{run:e,kind:t,number:n,repoBase:r,reason:g.reason,retryError:l.error,retryButton:h})}function H(e){if(!e)return`this repository`;try{return new URL(e).pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`)||`this repository`}catch{return`this repository`}}function U({item:e}){let t=k();return(0,A.jsx)(D,{item:e,workflows:t.workflows.data?.workflows??[],skills:t.skillList,workflow:t.workflow,onWorkflowChange:t.setWorkflow,selectedSkills:t.selectedSkills,onSkillsChange:t.setSelectedSkills,engine:t.engine,onEngineChange:t.setEngine,queuedRunId:t.queued.get(e.url)??null,onQueued:t.onQueued},e.url)}export{M as TaskGithubItemRoute};
1
+ import{E as e,d as t,t as n}from"./button-DGwhwRuD.js";import{t as r}from"./react-runtime-CCIEwYL0.js";import{$ as i,Lr as a}from"./project-scope-context-DhjdxoB5.js";import{N as o,O as s,T as c,W as l,Y as u,Yt as d,ft as f,n as p}from"./queries-DQWq3QYH.js";import{S as m,tt as h,y as g}from"./use-desktop-B27Z5VAz.js";import{F as _,ot as v,p as y}from"./design-icons-B6-0w7Aw.js";import{t as b}from"./run-header-Bfg4NPUu.js";import{u as x}from"./reference-chip-S5_xQP1E.js";import{t as S}from"./project-router-4acCokGM.js";import{t as C}from"./centered-state-B5QmAy2y.js";import{E as w,T,on as E}from"./index-8QnR_MBI.js";import{n as D,o as O,t as k}from"./use-hand-to-agent-state-PIoC-vpx.js";var A=r(),j={issue:`Issue`,pr:`Pull request`};function M({kind:t}){let{id:n}=e(),r=f(n);return r.isPending?(0,A.jsx)(T,{kind:t}):r.isError?(0,A.jsx)(w,{tab:`github-item`,error:r.error}):(0,A.jsx)(N,{run:r.data,kind:t})}function N({run:t,kind:r}){let{n:i}=e(),a=Number(i),c=l(),d=u(),f=o(),p=d.isPending||f.isPending,m=g(t,c).some(e=>e.kind===r&&e.number===a),h=s(r,a,m);return(0,A.jsxs)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:[(0,A.jsx)(b,{run:t,tab:{kind:r,number:a}}),m?(0,A.jsx)(V,{run:t,kind:r,number:a,repoBase:c,item:h}):p?(0,A.jsx)(T,{kind:r,number:a,heading:`h2`}):(0,A.jsx)(C,{icon:(0,A.jsx)(E,{size:16}),tone:`neutral`,heading:`h2`,title:`#${i} is not linked to this task`,subtitle:`Only the issues and pull requests this task references open here.`,actions:(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsx)(S,{to:`/tasks/${t.id}`,children:`Back to the session`})})})]})}function P(e,t){return e===`pr`&&t.data?.available===!0&&t.data.item!==null}function F(e,t,n,r){return e===`pr`?n?.[t]??r:r}function I({retry:e,kind:t,number:r}){return(0,A.jsx)(n,{variant:`outline`,disabled:e.isPending,onClick:()=>e.mutate(p.githubItem(t,r)),children:`Retry`})}function L({kind:e,number:t,error:n,retryButton:r}){return(0,A.jsx)(C,{icon:(0,A.jsx)(v,{size:16}),tone:`danger`,heading:`h2`,title:`Could not load ${j[e].toLowerCase()} #${t}`,subtitle:n.message,actions:r})}function R({run:e,kind:r,number:i,repoBase:a,reason:o,retryError:s,retryButton:c}){let l=r===`pr`?_:y,u=m(e,a).find(e=>e.kind===`PR`==(r===`pr`)&&e.number===i)?.url;return(0,A.jsx)(C,{icon:(0,A.jsx)(l,{size:16}),tone:`neutral`,heading:`h2`,title:`GitHub is unavailable`,subtitle:s?.message??o,actions:(0,A.jsxs)(A.Fragment,{children:[c,u&&t(u)?(0,A.jsx)(n,{asChild:!0,variant:`outline`,children:(0,A.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,children:[`open on GitHub`,(0,A.jsx)(h,{"aria-hidden":`true`})]})}):null]})})}function z({label:e,repoBase:t}){return(0,A.jsx)(C,{icon:(0,A.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`${e} was not found in ${H(t)}`,subtitle:`It may have been deleted, or the number points at a different repository.`})}function B({kind:e,item:t,labelColors:n,checks:r}){return(0,A.jsx)(`div`,{className:`min-w-0 px-0.5 md:px-2`,children:(0,A.jsx)(O,{item:t,colors:n??{},checks:r,backLink:null,subNav:null,children:e===`issue`?(0,A.jsx)(U,{item:t},t.url):null})})}function V({run:e,kind:t,number:n,repoBase:r,item:o}){let s=a(),l=d({mutationFn:e=>i(t,n,{refresh:!0}),onSuccess:(e,t)=>s.setQueryData(t,e)}),u=P(t,o),f=c(u?[n]:[],u),p=f.data?.available?f.data.checks:void 0,m=`${j[t]} #${n}`,h=(0,A.jsx)(I,{retry:l,kind:t,number:n});if(o.isPending)return(0,A.jsx)(T,{kind:t,number:n,heading:`h2`});if(o.isError)return(0,A.jsx)(L,{kind:t,number:n,error:l.error??o.error,retryButton:h});let g=o.data;return g.available?g.item?(0,A.jsx)(B,{kind:t,item:g.item,labelColors:g.labelColors,checks:F(t,n,p,g.item.checks)}):(0,A.jsx)(z,{label:m,repoBase:r}):(0,A.jsx)(R,{run:e,kind:t,number:n,repoBase:r,reason:g.reason,retryError:l.error,retryButton:h})}function H(e){if(!e)return`this repository`;try{return new URL(e).pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`)||`this repository`}catch{return`this repository`}}function U({item:e}){let t=k();return(0,A.jsx)(D,{item:e,workflows:t.workflows.data?.workflows??[],skills:t.skillList,workflow:t.workflow,onWorkflowChange:t.setWorkflow,selectedSkills:t.selectedSkills,onSkillsChange:t.setSelectedSkills,engine:t.engine,onEngineChange:t.setEngine,queuedRunId:t.queued.get(e.url)??null,onQueued:t.onQueued},e.url)}export{M as TaskGithubItemRoute};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,N as i,d as a,p as o,t as s,u as c,w as l}from"./button-DGwhwRuD.js";import{i as u,r as d,t as f}from"./react-runtime-CCIEwYL0.js";import{n as p}from"./live-refetch-CZb2VOyu.js";import{$n as m,E as h,Kn as g,Lr as _,P as v,Zn as y,_ as b,d as x,i as S,jn as C,l as w,nr as T,pr as E,w as D}from"./project-scope-context-qMCI2vmR.js";import{G as O,W as k}from"./live-protocol-B8HJ-VW8.js";import{Et as A,F as j,Jt as M,Kt as ee,N as te,St as ne,W as N,X as P,Yt as F,ft as I,gt as L,m as R,n as z,ot as re,s as B,u as ie,x as ae,xt as oe,yt as se,z as ce}from"./queries-DFchmPfl.js";import{$ as le,E as ue,L as de,Y as fe,Z as pe,_ as me,b as he,et as ge,l as _e,n as V,p as ve,q as ye,tt as be,w as xe,z as H}from"./use-desktop-CdWXLHne.js";import{n as U}from"./toaster-CoMJoQvk.js";import{A as Se,B as Ce,F as we,K as Te,X as Ee,at as De,c as Oe,dt as ke,f as Ae,g as je,it as Me,k as Ne,l as Pe,m as Fe,n as Ie,ot as Le,s as Re,u as W,ut as ze,v as Be,y as Ve,z as He}from"./design-icons-B6-0w7Aw.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{_ as Ue,a as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as K,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at}from"./run-header-DBbM_xNy.js";import{t as ot}from"./eye-B8okNWXU.js";import{a as st}from"./format-BNCkW110.js";import{t as ct}from"./message-square-B-MD-8rD.js";import{a as lt,c as ut,i as dt,l as ft,n as pt,o as mt,r as ht,s as gt,t as _t}from"./thread-state-i29D-4yN.js";import{i as vt,o as yt,t as bt,u as xt}from"./reference-chip-BJe4UIpL.js";import{s as St,t as q}from"./project-router-0DHZ1s8l.js";import"./attention-D15PtJnc.js";import{n as Ct,r as wt,t as Tt}from"./picker-pill-B6QPSEUZ.js";import{n as Et}from"./runner-facts-BpvNgJqf.js";import{n as Dt,t as Ot}from"./centered-state-B5QmAy2y.js";import{c as kt,d as At,f as jt,l as Mt,n as Nt,p as Pt,s as Ft,t as It}from"./agent-accounts-Bxqcccek.js";import{Dt as Lt,Et as Rt,Gt as zt,I as Bt,Jt as Vt,Kt as Ht,L as Ut,Nt as Wt,Ot as Gt,S as Kt,St as qt,Tt as Jt,U as Yt,Ut as Xt,V as Zt,W as Qt,Wt as $t,_ as en,_t as tn,bt as nn,c as J,en as rn,f as an,fn as on,i as sn,kt as cn,l as Y,ln,n as un,nn as dn,qt as fn,s as pn,sn as mn,u as X,vt as hn,w as gn,xt as _n}from"./index-aCWAgBiE.js";import{t as vn}from"./zoomable-image-C7mEDZaS.js";import{i as yn,r as bn,s as xn,t as Sn}from"./markdown-D4ZGAuSC.js";import{t as Cn}from"./report-title-D4Mbu2Er.js";var wn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Tn=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),En=G(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Dn=G(`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`}]]),On=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),kn=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),An=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Z=e(u(),1),Q=f(),jn=12;function Mn({run:e}){let t=_(),n=F({mutationFn:()=>w(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:z.runs.detail(e.id)}),t.invalidateQueries({queryKey:z.runs.list()}),U(`This task will not resume itself`)},onError:e=>U(e.message,{tone:`danger`})});if(!y(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,Q.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Vt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Q.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,jn,`)`]}):(0,Q.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Q.jsx)(o,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pn=/^[A-Za-z0-9_./:=+,@%-]+$/;function Fn(e){return e.replaceAll(`'`,`'\\''`)}function In(e){return e===``?`''`:Pn.test(e)?e:`\u0027${Fn(e)}\u0027`}function Ln(e){if(!Nn(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(In).join(` `)}}function Rn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function zn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Bn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Vn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Hn(e){let t=Rn(zn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Vn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Vn(e[2])&&i.push({label:Bn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Bn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Vn(t)&&i.push({label:t,href:t})}return i}var Un=(0,Z.createContext)(void 0),Wn=(0,Z.createContext)(void 0);function Gn(e,t){let n=new Map;for(let r of Hn(e)){let e=yn(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function Kn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function qn({text:e,messageKey:t}){let n=(0,Z.useContext)(bn),r=(0,Z.useContext)(Wn),i=t??r;if(!n||i===void 0)return null;let a=Gn(e,n);return a.length===0?null:(0,Q.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,Q.jsx)(Jn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Jn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:s}=e,c=(0,Z.useContext)(Un),u=(0,Z.useContext)(Kt);(0,Z.useLayoutEffect)(()=>u?.register(r,i),[u,r,i]);let d=ie(i,r),f=t(),p=l();if(d.isError)return(0,Q.jsx)(o,{id:Kn(n,r),"data-slot":`report-card-fallback`,to:s,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!xn(m.name))return null;let h=new URLSearchParams(f.search);h.set(`report`,r),h.set(`card`,n);let g=new URLSearchParams(f.search).has(`report`)?f.state:null,_=new URLSearchParams(f.search);_.delete(`report`),_.delete(`card`);let v=`${f.pathname}${_.size?`?${_}`:``}`,y=window.navigation,b={reportCardEntry:!0,reportReturnTo:g?.reportReturnTo??v,reportReturnKey:g?.reportReturnKey??y?.currentEntry?.key,reportScrollTop:g?.reportScrollTop},x={pathname:f.pathname,search:`?${h}`,hash:new URL(s,`https://cockpit.invalid`).hash};return(0,Q.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":r,"data-report-run-id":i,"aria-busy":d.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,Q.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:m?Cn(m):a}),(0,Q.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,Q.jsx)(o,{id:Kn(n,r),to:x,state:b,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),c?.(n);let t=b.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;p(x,{state:{...b,reportScrollTop:t}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${d.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Yn={message:!0,reasoning:!0,tool:!0,hook:!0};function Xn(e){return Object.hasOwn(Yn,e)&&Yn[e]}var Zn=e=>e.kind===`tool`,Qn=e=>e.kind===`conversation`,$n=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,er=(e,t,n)=>`${e} ${e===1?t:n}`;function tr(e,t){let n=[];return e>0&&n.push(er(e,`file`,`files`)),t>0&&n.push(er(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function nr(e){return`${e} earlier tool call${e===1?``:`s`}`}var rr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ir(e){for(let t of rr)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function ar(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Zn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Xn(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:tr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of or(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Qn(e)){s(),c.push(e);continue}l(),Zn(e)&&$n(e)&&!r.has(e.id)?o.push(e):(s(),Zn(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function or(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var sr=new Map,cr=(0,Z.createContext)(null);function lr(){return(0,Z.useContext)(cr)}function ur({runId:e,children:t}){let n=(0,Z.useMemo)(()=>({get:t=>sr.get(e)?.get(t),set:(t,n)=>{let r=sr.get(e)??new Map;r.set(t,n),sr.set(e,r)}}),[e]);return(0,Q.jsx)(cr.Provider,{value:n,children:t})}function dr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function fr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function pr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function mr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function hr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var gr=new Map;function _r(e,t){gr.set(e,t)}function vr(e){return gr.get(e)}var yr=new Map;function br(e,t){yr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function xr(e){return yr.get(e)}function Sr(e,t,n){let r=yr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Cr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),wr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Tr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Er=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Dr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function $(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Or(e){let t=$(e);return t===void 0?void 0:Cr.format(t)}function kr(e){let t=$(e);return t===void 0?void 0:wr.format(t)}var Ar=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function jr(e){let t=$(e);return t===void 0?void 0:Ar(t)}function Mr(e,t=new Date){let n=$(e);if(n===void 0)return;let r=Ar(n);return r===Ar(t)?`Today`:r===Ar(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Tr:Er).format(n)}function Nr(e,t){let n=$(e),r=$(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Pr({ts:e}){let t=Or(e);return t===void 0?null:(0,Q.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:kr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Fr({startedAt:e,completedAt:t}){let n=Or(t);if(n===void 0)return null;let r=Nr(e,t);return(0,Q.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,Q.jsx)(`time`,{dateTime:t,title:kr(t),children:n}),r===void 0?null:(0,Q.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ir({ts:e}){let t=Mr(e),n=$(e);if(t===void 0||n===void 0)return null;let r=Dr.format(n);return(0,Q.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,Q.jsx)(`time`,{dateTime:jr(e),title:r,children:t}),(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Lr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Rr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Lr[e],s=r===void 0?void 0:Or(r);return(0,Q.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:c(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,Q.jsxs)(`p`,{className:c(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,Q.jsx)(ct,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,Q.jsx)(Pr,{ts:r})})]}),(0,Q.jsx)(`div`,{className:c(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function zr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(e),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,Q.jsxs)(Rr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,Q.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,Q.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,Q.jsx)(st,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,Q.jsxs)(Rr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(An,{className:`size-3.5`})}):null,o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(De,{className:`size-3.5`})}):null]}):null,_?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,Q.jsx)(Sn,{breaks:!0,children:e}),n.length>0?(0,Q.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>T(e.split(`/`).pop()??``)?(0,Q.jsx)(vn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,Q.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,Q.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}var Br=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Vr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Hr(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Vr).forEach(e=>e.remove());let r=Hn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Vn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Ur(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Hr(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}function Wr({text:e,ts:t,messageKey:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Ur(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,Q.jsxs)(Rr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Br,children:[(0,Q.jsx)(Be,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Br,children:[(0,Q.jsx)(ln,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,Q.jsx)(`div`,{ref:r,children:(0,Q.jsx)(Sn,{breaks:!0,children:e})}),(0,Q.jsx)(qn,{text:e,messageKey:n})]})}function Gr({note:e}){return e.icon===`handoff`?(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,Q.jsx)(dn,{className:`size-3`})}),(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:c(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function Kr({incident:e}){let t=Et(e.provider);return(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function qr({text:e}){let t=(0,Z.useId)();if(e.trim()===``)return null;let n=e.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,E as n,I as r,N as i,d as a,p as o,t as s,u as c,w as l}from"./button-DGwhwRuD.js";import{i as u,r as d,t as f}from"./react-runtime-CCIEwYL0.js";import{n as p}from"./live-refetch-CZb2VOyu.js";import{$n as m,E as h,Kn as g,Lr as _,P as v,Zn as y,_ as b,d as x,i as S,jn as C,l as w,nr as T,pr as E,w as D}from"./project-scope-context-DhjdxoB5.js";import{G as O,W as k}from"./live-protocol-B8HJ-VW8.js";import{Et as A,F as j,Jt as M,Kt as ee,N as te,St as ne,W as N,X as P,Yt as F,ft as I,gt as L,m as R,n as z,ot as re,s as B,u as ie,x as ae,xt as oe,yt as se,z as ce}from"./queries-DQWq3QYH.js";import{$ as le,E as ue,L as de,Y as fe,Z as pe,_ as me,b as he,et as ge,l as _e,n as V,p as ve,q as ye,tt as be,w as xe,z as H}from"./use-desktop-B27Z5VAz.js";import{n as U}from"./toaster-CoMJoQvk.js";import{A as Se,B as Ce,F as we,K as Te,X as Ee,at as De,c as Oe,dt as ke,f as Ae,g as je,it as Me,k as Ne,l as Pe,m as Fe,n as Ie,ot as Le,s as Re,u as W,ut as ze,v as Be,y as Ve,z as He}from"./design-icons-B6-0w7Aw.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{_ as Ue,a as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as K,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at}from"./run-header-Bfg4NPUu.js";import{t as ot}from"./eye-B8okNWXU.js";import{a as st}from"./format-BNCkW110.js";import{t as ct}from"./message-square-B-MD-8rD.js";import{a as lt,c as ut,i as dt,l as ft,n as pt,o as mt,r as ht,s as gt,t as _t}from"./thread-state-B4uGx4AQ.js";import{i as vt,o as yt,t as bt,u as xt}from"./reference-chip-S5_xQP1E.js";import{s as St,t as q}from"./project-router-4acCokGM.js";import"./attention-CJrUOS56.js";import{n as Ct,r as wt,t as Tt}from"./picker-pill-Dl5RK9pn.js";import{n as Et}from"./runner-facts-BpvNgJqf.js";import{n as Dt,t as Ot}from"./centered-state-B5QmAy2y.js";import{c as kt,d as At,f as jt,l as Mt,n as Nt,p as Pt,s as Ft,t as It}from"./agent-accounts-CrhI2D79.js";import{Dt as Lt,Et as Rt,Gt as zt,I as Bt,Jt as Vt,Kt as Ht,L as Ut,Nt as Wt,Ot as Gt,S as Kt,St as qt,Tt as Jt,U as Yt,Ut as Xt,V as Zt,W as Qt,Wt as $t,_ as en,_t as tn,bt as nn,c as J,en as rn,f as an,fn as on,i as sn,kt as cn,l as Y,ln,n as un,nn as dn,qt as fn,s as pn,sn as mn,u as X,vt as hn,w as gn,xt as _n}from"./index-8QnR_MBI.js";import{t as vn}from"./zoomable-image-C7mEDZaS.js";import{i as yn,r as bn,s as xn,t as Sn}from"./markdown-C24Y3Ede.js";import{t as Cn}from"./report-title-D4Mbu2Er.js";var wn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Tn=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),En=G(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Dn=G(`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`}]]),On=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),kn=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),An=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Z=e(u(),1),Q=f(),jn=12;function Mn({run:e}){let t=_(),n=F({mutationFn:()=>w(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:z.runs.detail(e.id)}),t.invalidateQueries({queryKey:z.runs.list()}),U(`This task will not resume itself`)},onError:e=>U(e.message,{tone:`danger`})});if(!y(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,Q.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Vt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,Q.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,jn,`)`]}):(0,Q.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,Q.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,Q.jsx)(o,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pn=/^[A-Za-z0-9_./:=+,@%-]+$/;function Fn(e){return e.replaceAll(`'`,`'\\''`)}function In(e){return e===``?`''`:Pn.test(e)?e:`\u0027${Fn(e)}\u0027`}function Ln(e){if(!Nn(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(In).join(` `)}}function Rn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function zn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Bn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Vn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Hn(e){let t=Rn(zn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Vn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Vn(e[2])&&i.push({label:Bn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Bn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Vn(t)&&i.push({label:t,href:t})}return i}var Un=(0,Z.createContext)(void 0),Wn=(0,Z.createContext)(void 0);function Gn(e,t){let n=new Map;for(let r of Hn(e)){let e=yn(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function Kn(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function qn({text:e,messageKey:t}){let n=(0,Z.useContext)(bn),r=(0,Z.useContext)(Wn),i=t??r;if(!n||i===void 0)return null;let a=Gn(e,n);return a.length===0?null:(0,Q.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,Q.jsx)(Jn,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Jn({reference:e,messageKey:n}){let{artifactId:r,runId:i,label:a,href:s}=e,c=(0,Z.useContext)(Un),u=(0,Z.useContext)(Kt);(0,Z.useLayoutEffect)(()=>u?.register(r,i),[u,r,i]);let d=ie(i,r),f=t(),p=l();if(d.isError)return(0,Q.jsx)(o,{id:Kn(n,r),"data-slot":`report-card-fallback`,to:s,state:{readerFrom:f.pathname+f.search},children:a});let m=d.data?.artifact;if(m&&!xn(m.name))return null;let h=new URLSearchParams(f.search);h.set(`report`,r),h.set(`card`,n);let g=new URLSearchParams(f.search).has(`report`)?f.state:null,_=new URLSearchParams(f.search);_.delete(`report`),_.delete(`card`);let v=`${f.pathname}${_.size?`?${_}`:``}`,y=window.navigation,b={reportCardEntry:!0,reportReturnTo:g?.reportReturnTo??v,reportReturnKey:g?.reportReturnKey??y?.currentEntry?.key,reportScrollTop:g?.reportScrollTop},x={pathname:f.pathname,search:`?${h}`,hash:new URL(s,`https://cockpit.invalid`).hash};return(0,Q.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":r,"data-report-run-id":i,"aria-busy":d.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,Q.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:m?Cn(m):a}),(0,Q.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,Q.jsx)(o,{id:Kn(n,r),to:x,state:b,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),c?.(n);let t=b.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;p(x,{state:{...b,reportScrollTop:t}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${d.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Yn={message:!0,reasoning:!0,tool:!0,hook:!0};function Xn(e){return Object.hasOwn(Yn,e)&&Yn[e]}var Zn=e=>e.kind===`tool`,Qn=e=>e.kind===`conversation`,$n=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,er=(e,t,n)=>`${e} ${e===1?t:n}`;function tr(e,t){let n=[];return e>0&&n.push(er(e,`file`,`files`)),t>0&&n.push(er(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function nr(e){return`${e} earlier tool call${e===1?``:`s`}`}var rr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ir(e){for(let t of rr)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function ar(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(Zn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=Xn(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:tr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of or(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(Qn(e)){s(),c.push(e);continue}l(),Zn(e)&&$n(e)&&!r.has(e.id)?o.push(e):(s(),Zn(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function or(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var sr=new Map,cr=(0,Z.createContext)(null);function lr(){return(0,Z.useContext)(cr)}function ur({runId:e,children:t}){let n=(0,Z.useMemo)(()=>({get:t=>sr.get(e)?.get(t),set:(t,n)=>{let r=sr.get(e)??new Map;r.set(t,n),sr.set(e,r)}}),[e]);return(0,Q.jsx)(cr.Provider,{value:n,children:t})}function dr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function fr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function pr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function mr(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function hr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var gr=new Map;function _r(e,t){gr.set(e,t)}function vr(e){return gr.get(e)}var yr=new Map;function br(e,t){yr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function xr(e){return yr.get(e)}function Sr(e,t,n){let r=yr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Cr=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),wr=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Tr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Er=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Dr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function $(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Or(e){let t=$(e);return t===void 0?void 0:Cr.format(t)}function kr(e){let t=$(e);return t===void 0?void 0:wr.format(t)}var Ar=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function jr(e){let t=$(e);return t===void 0?void 0:Ar(t)}function Mr(e,t=new Date){let n=$(e);if(n===void 0)return;let r=Ar(n);return r===Ar(t)?`Today`:r===Ar(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Tr:Er).format(n)}function Nr(e,t){let n=$(e),r=$(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Pr({ts:e}){let t=Or(e);return t===void 0?null:(0,Q.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:kr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Fr({startedAt:e,completedAt:t}){let n=Or(t);if(n===void 0)return null;let r=Nr(e,t);return(0,Q.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,Q.jsx)(`time`,{dateTime:t,title:kr(t),children:n}),r===void 0?null:(0,Q.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ir({ts:e}){let t=Mr(e),n=$(e);if(t===void 0||n===void 0)return null;let r=Dr.format(n);return(0,Q.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,Q.jsx)(`time`,{dateTime:jr(e),title:r,children:t}),(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Lr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Rr({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Lr[e],s=r===void 0?void 0:Or(r);return(0,Q.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:c(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,Q.jsxs)(`p`,{className:c(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,Q.jsx)(ct,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,Q.jsx)(Pr,{ts:r})})]}),(0,Q.jsx)(`div`,{className:c(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}function zr({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(e),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,Q.jsxs)(Rr,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,Q.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,Q.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,Q.jsx)(st,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,Q.jsxs)(Rr,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(An,{className:`size-3.5`})}):null,o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(De,{className:`size-3.5`})}):null]}):null,_?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,Q.jsx)(Sn,{breaks:!0,children:e}),n.length>0?(0,Q.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>T(e.split(`/`).pop()??``)?(0,Q.jsx)(vn,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,Q.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,Q.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}var Br=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Vr=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Hr(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Vr).forEach(e=>e.remove());let r=Hn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Vn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Ur(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Hr(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}function Wr({text:e,ts:t,messageKey:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Ur(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,Q.jsxs)(Rr,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,Q.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Br,children:[(0,Q.jsx)(Be,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Br,children:[(0,Q.jsx)(ln,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,Q.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,Q.jsx)(`div`,{ref:r,children:(0,Q.jsx)(Sn,{breaks:!0,children:e})}),(0,Q.jsx)(qn,{text:e,messageKey:n})]})}function Gr({note:e}){return e.icon===`handoff`?(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,Q.jsx)(dn,{className:`size-3`})}),(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,Q.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:c(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function Kr({incident:e}){let t=Et(e.provider);return(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,Q.jsx)(q,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function qr({text:e}){let t=(0,Z.useId)();if(e.trim()===``)return null;let n=e.split(`
2
2
  `,1)[0]??``,r=n.length<e.length;return(0,Q.jsxs)(J,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,Q.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,Q.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,Q.jsx)(Sn,{inline:!0,children:n})}),r?(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,Q.jsx)(X,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,Q.jsx)(Y,{children:(0,Q.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,Q.jsx)(Sn,{children:e})})})]})}function Jr(){return(0,Q.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,Q.jsx)(st,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,Q.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Yr={read:ln,edit:An,delete:De,move:On,search:Ee,execute:rn,think:Tn,fetch:mn,task:Re,plan:Ce,other:ke},Xr=e=>e.split(`
3
3
  `).length;function Zr({text:e,streaming:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Xr(e),s=!t&&!n&&o>12;return(0,Q.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=mr(e.currentTarget)}:void 0,className:c(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,Q.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,Q.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function Qr({diffs:e}){return(0,Q.jsx)(Q.Fragment,{children:e.map((e,t)=>(0,Q.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,Q.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...$r(e.oldText).map((e,t)=>(0,Q.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...$r(e.newText).map((e,t)=>(0,Q.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
4
  `).map((e,t)=>(0,Q.jsx)(ei,{text:e},t))})]},`${e.path}:${t}`))})}function $r(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`