@hearsay-tools/squawk 0.17.0-dev.5749 → 0.17.0-dev.5769
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runs/store-open-error.js +1 -1
- package/dist/runs/store-open-error.js.map +1 -1
- package/dist/runs/store.js +1 -1
- package/dist/runs/store.js.map +1 -1
- package/dist/self-update/pulls.d.ts +1 -1
- package/dist/self-update/pulls.js +1 -1
- package/dist/self-update/pulls.js.map +1 -1
- package/dist/server/server.d.ts +58 -58
- package/dist/workflows/run-states.js +5 -5
- package/dist/workflows/run-states.js.map +1 -1
- package/package.json +5 -5
- package/web/dist/assets/{activity-motion-Deqj_hcK.js → activity-motion-2nE59DAT.js} +1 -1
- package/web/dist/assets/{activity-route-Z8SMpPLm.js → activity-route-R9lPc2jy.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-DZutYRbq.js → commit-diff-panel-BJyNYmCY.js} +1 -1
- package/web/dist/assets/{diff-DNAtaTLC.js → diff-D_9MtICR.js} +2 -2
- package/web/dist/assets/{diff-view---8Bt-0a.js → diff-view-xRPxXHXl.js} +1 -1
- package/web/dist/assets/{git-toolbar-DMDmGits.js → git-toolbar-D9taioU5.js} +1 -1
- package/web/dist/assets/{github-DlMu4p0I.js → github-bv_pBGc5.js} +1 -1
- package/web/dist/assets/{global-activity-route-mJrrP9I0.js → global-activity-route-QxTPDyx-.js} +1 -1
- package/web/dist/assets/{index-FoxgrgAH.js → index-DgU3yYUl.js} +3 -3
- package/web/dist/assets/{preview-pane-connected-KzJn9jAG.js → preview-pane-connected-cD-MTiVN.js} +2 -2
- package/web/dist/assets/{repo-git-Bf_EfIHt.js → repo-git-E_4Ighvg.js} +1 -1
- package/web/dist/assets/{report-reader-ztLhC9gp.js → report-reader-XVNQsXB4.js} +1 -1
- package/web/dist/assets/{reports-BxGqf1aC.js → reports-B_PVTBzP.js} +1 -1
- package/web/dist/assets/{run-header-CDMGqoPE.js → run-header-wm0gSs6X.js} +1 -1
- package/web/dist/assets/{skills-D2r8n5IP.js → skills-D2RLxUIc.js} +1 -1
- package/web/dist/assets/{task-changes-CfUCDwcL.js → task-changes-DNtkfFzQ.js} +1 -1
- package/web/dist/assets/{task-commits-IOjoz_mL.js → task-commits-CivO-OrN.js} +1 -1
- package/web/dist/assets/{task-files-CpUYhIpd.js → task-files-dczkxV_G.js} +1 -1
- package/web/dist/assets/{task-github-item-B8YPhQDV.js → task-github-item-DKV4yrcf.js} +1 -1
- package/web/dist/assets/{task-thread-2Kme3Fc0.js → task-thread-DIaTTGEF.js} +1 -1
- package/web/dist/assets/{thread-state-C136Em0C.js → thread-state-DIozHuHb.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-C6u70P2A.js → use-hand-to-agent-state-D58ayxI4.js} +1 -1
- package/web/dist/assets/{workflows-CWrdqLII.js → workflows-YMEsGXeB.js} +1 -1
- package/web/dist/index.html +1 -1
package/web/dist/assets/{preview-pane-connected-KzJn9jAG.js → preview-pane-connected-cD-MTiVN.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-CHUAMTHK.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Fr as o,Ir as s,Pr as c,gr as l}from"./project-scope-context-B3M-u8R0.js";import{n as u}from"./toaster-B1MyeHiE.js";import{a as d,c as f,i as p,l as m,p as h,r as g,s as _,t as v}from"./dropdown-menu-DhrBcVgr.js";import{t as y}from"./loader-circle-CZkGEdoI.js";import{t as b}from"./createLucideIcon-BHp8sXmF.js";import{t as ee}from"./arrow-right-Dh_Lx3um.js";import{n as x,r as S,t as C}from"./hourglass-B0lPAJvT.js";import{t as w}from"./info-DA1x_4bz.js";import{c as T,n as E,o as te,s as ne}from"./thread-state-
|
|
2
|
-
`);return(0,J.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,J.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,J.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/cezarion#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,J.jsx)(We,{state:e,actions:t});case`downloading`:return(0,J.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,J.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,J.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,J.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,J.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,J.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,J.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,J.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,J.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,J.jsx)(rt,{state:e,actions:t});case`loading`:return(0,J.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,J.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,J.jsx)(st,{actions:t});case`taken-over`:return(0,J.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,J.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,J.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(le,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,J.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,J.jsx)(`span`,{children:n}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,J.jsx)(A,{className:`size-4`,"aria-hidden":`true`})})]}),(0,J.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,J.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,J.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,J.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,J.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cwd`}),(0,J.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,J.jsx)(`div`,{className:`mt-2.5`,children:(0,J.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,J.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,J.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,J.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,q.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,J.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,J.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(De,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,J.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,J.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry download`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(Te,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,J.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,J.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(x,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,J.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,J.jsxs)(X,{state:e.stage,icon:a?(0,J.jsx)(Oe,{className:`text-pending-strong`}):(0,J.jsx)(k,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,J.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,J.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,J.jsx)(k,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(De,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,J.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(k,{}),title:`Starting ${i.label}`,children:[(0,J.jsx)(Z,{children:`${t(`cezar`)} ran ${M(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,J.jsx)(y,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,J.jsx)(Y,{text:e.logTail.join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-CHUAMTHK.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Fr as o,Ir as s,Pr as c,gr as l}from"./project-scope-context-B3M-u8R0.js";import{n as u}from"./toaster-B1MyeHiE.js";import{a as d,c as f,i as p,l as m,p as h,r as g,s as _,t as v}from"./dropdown-menu-DhrBcVgr.js";import{t as y}from"./loader-circle-CZkGEdoI.js";import{t as b}from"./createLucideIcon-BHp8sXmF.js";import{t as ee}from"./arrow-right-Dh_Lx3um.js";import{n as x,r as S,t as C}from"./hourglass-B0lPAJvT.js";import{t as w}from"./info-DA1x_4bz.js";import{c as T,n as E,o as te,s as ne}from"./thread-state-DIozHuHb.js";import{s as re}from"./project-router-MMOk9VbW.js";import{$t as D,A as O,Bt as k,D as ie,Gt as ae,Ht as oe,It as se,Jt as ce,Lt as le,O as ue,Qt as de,Rt as fe,Ut as pe,Wt as me,Yt as A,Zt as j,_t as he,ct as ge,dt as M,ft as _e,gt as ve,ht as ye,k as N,lt as be,ot as P,st as F,ut as xe}from"./index-DgU3yYUl.js";var Se=b(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),I=b(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),L=b(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=b(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=b(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=b(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Ce=b(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),we=b(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),V=b(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=b(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=b(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=b(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=b(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=b(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Te=b(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Ee=b(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),De=b(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Oe=b(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),ke=b(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),q=e(i(),1),Ae=1e3,je=[500,1e3,2e3,4e3,8e3],Me=1;function Ne(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,a,s=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||c(),m=()=>{if(s||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=l.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||s)return;if(i=null,!u){if(d+=1,d>=2){s=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),a=setTimeout(m,Ae);return}if(f>=5){s=!0,t.onTransport(`closed`);return}let e=je[Math.min(f,je.length-1)];f+=1,t.onTransport(`reconnecting`,f),a=setTimeout(m,e)})},h=o(e=>{if(!s)if(e)i||m();else{clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===Me&&i.send(JSON.stringify(e))},close(){s=!0,h(),clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}}}var J=a();function Pe({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,J.jsx)(N,{children:(0,J.jsxs)(ie,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,J.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,J.jsx)(ue,{children:`Experimental`})]})}):e?(0,J.jsx)(N,{children:(0,J.jsxs)(ie,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,J.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(ue,{children:`Experimental`})]})}):(0,J.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,J.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Y({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
|
+
`);return(0,J.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,J.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,J.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/squawk#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,J.jsx)(We,{state:e,actions:t});case`downloading`:return(0,J.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,J.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,J.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,J.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,J.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,J.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,J.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,J.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,J.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,J.jsx)(rt,{state:e,actions:t});case`loading`:return(0,J.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,J.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,J.jsx)(st,{actions:t});case`taken-over`:return(0,J.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,J.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,J.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(le,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,J.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,J.jsx)(`span`,{children:n}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,J.jsx)(A,{className:`size-4`,"aria-hidden":`true`})})]}),(0,J.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,J.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,J.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,J.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,J.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cwd`}),(0,J.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,J.jsx)(`div`,{className:`mt-2.5`,children:(0,J.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,J.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,J.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,J.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,q.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,J.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,J.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(De,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,J.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,J.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry download`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(Te,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,J.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,J.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(x,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,J.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,J.jsx)(A,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,J.jsxs)(X,{state:e.stage,icon:a?(0,J.jsx)(Oe,{className:`text-pending-strong`}):(0,J.jsx)(k,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,J.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,J.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,J.jsx)(k,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(De,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,J.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(k,{}),title:`Starting ${i.label}`,children:[(0,J.jsx)(Z,{children:`${t(`cezar`)} ran ${M(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,J.jsx)(y,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,J.jsx)(Y,{text:e.logTail.join(`
|
|
3
3
|
`),source:M(i.command),onCopy:r.copy}):null,(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`outline`,onClick:()=>r.stop(i.port),children:`Stop server`})})]})}function tt({state:e,actions:t}){let{server:r}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(C,{className:`text-pending-strong`}),title:`${r.label} is running, but :${r.port} is silent`,children:[(0,J.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,J.jsx)(Y,{text:e.logTail,source:M(r.command),onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(n,{variant:`contrast`,onClick:()=>t.keepWaiting(r.port),children:`Keep waiting`}),(0,J.jsx)(n,{variant:`outline`,onClick:()=>t.stop(r.port),children:`Stop server`})]})]})}function nt({state:e,actions:t}){let{server:r}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(x,{className:`text-danger`}),title:e.exitCode===null?`${r.label} was stopped by a signal`:`${r.label} exited with code ${e.exitCode}`,children:[(0,J.jsx)(Z,{children:`${M(r.command)} stopped.`}),(0,J.jsx)(Y,{text:e.logTail,source:M(r.command),onCopy:t.copy}),(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:()=>t.run(r.port),children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Start again`]})}),(0,J.jsx)(Ve,{server:r})]})}function rt({state:e,actions:r}){let{server:i}=e,a=e.reason===`idle`;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(oe,{}),title:a?`Stopped after 15 min idle`:`${i.label} stopped`,children:[(0,J.jsx)(Z,{children:a?`Nobody had this pane open for 15 min, so ${t(`cezar`)} stopped ${i.label} :${i.port} and the browser to free memory. Start again reopens ${Re(e.lastUrl)}.`:`You stopped ${i.label} :${i.port}. Start again reopens ${Re(e.lastUrl)}.`}),(0,J.jsx)(Q,{children:(0,J.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,J.jsx)(T,{"aria-hidden":`true`}),`Start again`]})}),(0,J.jsx)(Ve,{server:i})]})}var it=[`browser`,`page`,`frame`];function at({step:e,url:t}){let n=it.indexOf(e),i=t?Re(t):`the page`;return(0,J.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,J.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,J.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,J.jsx)(S,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,J.jsx)(y,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,J.jsx)(L,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function ot({state:e,actions:t,worktree:r}){let i=r?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(r)?.[0]:void 0,a=e.server?.label;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,J.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,J.jsx)(te,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,J.jsx)(Q,{children:(0,J.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function st({actions:e}){return(0,J.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(Pe,{})}),(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,J.jsx)(W,{})}),(0,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,J.jsxs)(Z,{children:[`The proxy in front of `,t(`cezar`),` didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in `,t(`cezar`),` keeps working.`]}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(n,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,J.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ct(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function lt({state:e,actions:t}){let r=ct(e.by);return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(U,{}),title:`Preview is open somewhere else`,children:[(0,J.jsx)(Z,{children:`Another tab took this browser${r?` (${r})`:``}. Only one tab can view and drive it at a time.`}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(n,{variant:`contrast`,onClick:t.useHere,children:[(0,J.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,J.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ut({attempt:e,exhausted:t,onReconnect:r}){return(0,J.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,J.jsx)(ke,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,J.jsx)(n,{variant:`outline`,onClick:r,children:t?`Reconnect`:`Reconnect now`})]})}function dt({servers:e,states:t,onOpen:r,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,J.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,J.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,J.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,J.jsx)(Oe,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,J.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,J.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,J.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(P,{tone:`success`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,J.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,J.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,J.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,J.jsx)(`ul`,{children:e.map(e=>{let i=be(e,t),a=_e(i);return(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(P,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,J.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>r(e.port),children:xe(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,J.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(w,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ft({dialog:e,onResult:t}){let[r,i]=(0,q.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,q.useRef)(null),s=(0,q.useRef)(null);(0,q.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,q.useRef)(t);c.current=t,(0,q.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:r}:{accept:!0});return(0,J.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,J.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,J.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,J.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,J.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,J.jsx)(n,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,J.jsx)(n,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var pt=10,mt=500,ht=500,gt=4,_t=16,vt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function yt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function bt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var xt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=yt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:xt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:vt(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=yt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=pt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=mt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=ht&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=gt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=yt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?_t:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:vt(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:vt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:vt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,q.useRef)(null),i=(0,q.useRef)(bt({left:0,top:0},e)),a=(0,q.useRef)(e);a.current=e;let o=(0,q.useRef)(t);o.current=t;let s=(0,q.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,q.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,q.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,q.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,q.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,J.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:o,children:s}){let l=(0,q.useRef)(0),u=(0,q.useRef)(null),d=(0,q.useRef)(null),[f,p]=(0,q.useState)(null),m=(0,q.useRef)(a);m.current=a,(0,q.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!c()))try{let i=await Nt(e);try{if(t!==l.current||!c()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,q.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,J.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,J.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,J.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),o?.({canvas:d.current,scale:g,viewport:h})]}):null,s]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:fe},{w:820,h:1180,icon:Ee},{w:1440,h:900,icon:pe}],Ht=`size-8 shrink-0 max-md:size-11`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,J.jsx)(P,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,J.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(P,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...r}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,J.jsxs)(n,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...r,children:[e||t?(0,J.jsx)(P,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,J.jsx)(ne,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:i}),e?(0,J.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,J.jsx)(j,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,J.jsxs)(p,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:n,children:[(0,J.jsx)(P,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,J.jsx)(D,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:r,loading:i=!1}=e,a=(0,q.useRef)(null),o=e.urlInputRef??a,s=(0,q.useRef)(!1),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(!1),f=(0,J.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!r,onClick:e.onBack,children:(0,J.jsx)(Se,{"aria-hidden":`true`})}),p=(0,J.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!r,onClick:e.onForward,children:(0,J.jsx)(ee,{"aria-hidden":`true`})}),m=(0,J.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!r||i,onClick:()=>e.onReload(!1),children:(0,J.jsx)(K,{"aria-hidden":`true`})}),h=e.onSession?(0,J.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,J.jsx)(de,{"aria-hidden":`true`}),`Session`]}):null,g=i?(0,J.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,J.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,J.jsx)($t,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:d}),{agentListed:v}=Xt(e),y=e.servers.length+ +!!v>=2,b=y||e.adopted,x={back:f,forward:p,reload:m,address:_,more:(0,J.jsx)(an,{props:e,compact:t,crowded:b}),session:h,progress:g};return t?(0,J.jsx)(on,{props:e,elements:x}):(0,J.jsx)(sn,{props:e,elements:x,switcher:y,crowded:b,input:o,focusUrlAfterMenu:s})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,J.jsxs)(v,{children:[(0,J.jsx)(h,{asChild:!0,children:(0,J.jsx)(qt,{current:i,agentShown:o})}),(0,J.jsxs)(g,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,J.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=_e(be(t,e.serverStates));return(0,J.jsxs)(p,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onPickServer(t.port),children:[(0,J.jsx)(P,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,J.jsx)(D,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,J.jsx)(m,{}),(0,J.jsxs)(p,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,J.jsx)(ae,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:n,draft:i,setDraft:a,focused:o,setFocused:s}){let{url:c,adopted:l}=e;return(0,J.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,J.jsx)(ae,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsx)(`input`,{ref:n,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:i??(o?c:Re(c)),title:c||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,l?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;s(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{s(!1),a(null)},onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(i??c),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),l&&!o?(0,J.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,J.jsx)(we,{className:`size-3`,"aria-hidden":`true`}),`Not started by `,t(`cezar`)]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,J.jsxs)(v,{children:[(0,J.jsx)(h,{asChild:!0,children:(0,J.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,J.jsx)(H,{"aria-hidden":`true`}):(0,J.jsx)(pe,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,J.jsx)(j,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,J.jsxs)(g,{align:`start`,className:`min-w-56`,children:[(0,J.jsxs)(p,{className:`gap-2.5`,onSelect:()=>e.onViewport(`fit`),children:[(0,J.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,J.jsx)(D,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,J.jsxs)(p,{className:`gap-2.5 font-mono`,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,J.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,J.jsx)(D,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,J.jsx)(_,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,J.jsx)(f,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,J.jsxs)(v,{children:[(0,J.jsx)(h,{asChild:!0,children:(0,J.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,J.jsx)(Ce,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Rt(t)}),(0,J.jsx)(j,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,J.jsxs)(g,{align:`start`,className:`w-64`,children:[(0,J.jsx)(d,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,J.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,J.jsx)(Kt,{stats:e,shrunk:n}):t?(0,J.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(P,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function an({props:e,compact:r,crowded:i}){let{stats:a,navEnabled:o,url:s,current:c,adopted:l}=e;return(0,J.jsxs)(v,{children:[(0,J.jsx)(h,{asChild:!0,children:(0,J.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,J.jsx)(ce,{"aria-hidden":`true`})})}),(0,J.jsxs)(g,{align:`end`,className:`min-w-64`,children:[i&&a&&!r?(0,J.jsx)(d,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(a)}):null,(0,J.jsxs)(p,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!o,onSelect:()=>e.onReload(!0),children:[(0,J.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,J.jsxs)(p,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:s===``,onSelect:e.onCopyUrl,children:[(0,J.jsx)(me,{"aria-hidden":`true`}),`Copy page URL`]}),c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{}),l?(0,J.jsxs)(p,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,J.jsx)(V,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${c.label} :${c.port}`}),(0,J.jsxs)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:[t(`cezar`),` didn't start this server, so it won't stop it. Stop it where it was started.`]})]})]}):(0,J.jsxs)(p,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(c.port),children:[(0,J.jsx)(I,{"aria-hidden":`true`}),`Stop server · ${c.label} :${c.port}`]})]}):null,r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{}),(0,J.jsx)(d,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,J.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,J.jsx)(m,{}),(0,J.jsxs)(p,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,J.jsx)(se,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,J.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,J.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,J.jsx)(P,{tone:`success`,"aria-hidden":`true`}):null,(0,J.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:r,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,J.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,r?(0,J.jsx)(Qt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,J.jsx)(en,{props:e}),(0,J.jsx)(nn,{props:e}),(0,J.jsx)(rn,{stats:c,status:l,crowded:i}),s?(0,J.jsx)(Pe,{iconOnly:i,responsive:!i}):null,(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,J.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,J.jsx)(se,{"aria-hidden":`true`})}),g]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,J.jsx)(Be,{...n,actions:o})}case`empty`:return(0,J.jsx)(dt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,q.useState)(un);return(0,q.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>u(`Copied`),()=>u(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let o=dn(),l=(0,q.useRef)(o);l.current=o;let u=s(),d=(0,q.useRef)(crypto.randomUUID()),f=(0,q.useRef)(!1),p=re(),m=ve(ye,!1),[h,g]=(0,q.useState)(0),[_,v]=(0,q.useState)({state:`connecting`,attempt:0}),[y,b]=(0,q.useState)(!1),[ee,x]=(0,q.useState)(void 0),[S,C]=(0,q.useState)(void 0),[w,T]=(0,q.useState)(``),[E,te]=(0,q.useState)(void 0),[ne,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(void 0),[ie,ae]=(0,q.useState)(!1),[oe,se]=(0,q.useState)(!1),[ce,le]=(0,q.useState)(void 0),[ue,de]=(0,q.useState)(void 0),[fe,pe]=(0,q.useState)(void 0),[me,A]=(0,q.useState)(`fit`),[j,he]=(0,q.useState)(zt),[ge,M]=(0,q.useState)(null),[_e,N]=(0,q.useState)(void 0),[be,P]=(0,q.useState)(0),F=(0,q.useRef)(void 0),xe=(0,q.useRef)(null),Se=(0,q.useRef)(null),I=(0,q.useRef)(void 0),L=(0,q.useRef)(void 0),R=(0,q.useRef)(j);R.current=j;let z=(0,q.useRef)({port:E,stage:S,agent:ne});z.current={port:E,stage:S,agent:ne};let B=(0,q.useRef)([]),Ce=(0,q.useRef)(void 0),we=(0,q.useRef)(!1),V=(0,q.useRef)(!1),H=(0,q.useCallback)(e=>{V.current&&F.current?.send(e)},[]);(0,q.useEffect)(()=>{let t;return t=Ne({projectId:p??`default`,runId:e.id},{onFrame(e){if(!c())return;let n=Date.now();B.current.push({at:n,bytes:e.size}),we.current||(we.current=!0,se(!0)),(xe.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&P(e=>e+1),L.current!==void 0&&hn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return le(e.cursor);case`dialog`:return de(e);case`pong`:Ce.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),V.current=!1,t?.close();return}},onTransport(e,n){V.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(b(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:d.current,resume:f.current,quality:R.current,dpr:l.current}),f.current=!0))}}),F.current=t,()=>{V.current=!1,t?.close(),F.current===t&&(F.current=void 0)}},[p,e.id,h]);let U=u&&_.state===`open`&&ee===void 0,W=m||me===`fit`?ge:me;(0,q.useEffect)(()=>{W&&U&&(S?.stage===`streaming`||S?.stage===`loading`)&&H({t:`resize`,w:W.w,h:W.h,...o===1?{}:{dpr:o}})},[W?.w,W?.h,o,U,S?.stage,be,H]),(0,q.useEffect)(()=>{if(!U)return;let e=setInterval(()=>H({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[U,H]);let G=U&&S?.stage===`streaming`;(0,q.useEffect)(()=>{if(!G){pe(void 0);return}let e=setInterval(()=>{let e=Date.now();B.current=B.current.filter(t=>e-t.at<=mn);let t={fps:B.current.length,kbps:Math.round(B.current.reduce((e,t)=>e+t.bytes,0)/1024),...Ce.current===void 0?{}:{rttMs:Ce.current},...B.current.length>0?{lastFrameAt:B.current.at(-1).at}:{}};pe(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[G]),(0,q.useEffect)(()=>(i?.(G),()=>i?.(!1)),[G,i]),(0,q.useEffect)(()=>{O&&r?.(O)},[O,r]);let K=(0,q.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,ae(!0),C(void 0),x(void 0),N(void 0),T(t),te(`port`in e?e.port:void 0),D(`agent`in e),k(yn(e)),H({t:`open`,target:e,viewerId:d.current,quality:R.current,dpr:l.current}),f.current=V.current},[H]),Te=(0,q.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);K({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,K]),Ee=(0,q.useCallback)(()=>K({agent:!0},``),[K]);(0,q.useEffect)(()=>{if(n?.agent){if(z.current.agent&&z.current.stage?.stage===`streaming`)return;Ee();return}if(n?.url!==void 0){let e=Ie(n.url,t);e.kind===`server`?Te(e.port):e.kind===`url`&&K({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||z.current.port===n.port&&z.current.stage?.stage===`streaming`&&n.run!==!0||Te(n.port,n.run===!0))},[n]);let De=!ie&&!ee&&_.state!==`blocked`,Oe=vn(n,t);(0,q.useEffect)(()=>{De&&!Oe&&Se.current?.focus()},[De,Oe]);let ke=e=>{let n=Ie(e,t);if(n.kind===`error`)return N(n.message);if(n.kind===`server`)return Te(n.port);if(z.current.stage?.stage===`streaming`&&!z.current.agent)return I.current={url:n.url},L.current=void 0,te(void 0),k({url:n.url}),N(void 0),T(n.url),H({t:`nav`,url:n.url});K({url:n.url},n.url)},Ae=(0,q.useCallback)(e=>{R.current=e,he(e),Bt(e),H({t:`quality`,quality:e})},[H]),je=()=>{f.current=!1,x(void 0),v({state:`connecting`,attempt:0}),we.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:ee,stage:S,url:w,port:E,agent:ne,hasFrame:oe,cursor:ce,dialog:ue,setDialog:de,stats:fe,viewport:me,setViewport:A,quality:j,chooseQuality:Ae,setStageSize:M,addressError:_e,stageHandle:xe,urlInput:Se,send:H,connected:U,streaming:G,openServer:Te,openAgent:Ee,empty:De,navigate:ke,reconnect:je,actions:(0,q.useMemo)(()=>({download:()=>H({t:`download`}),cancelDownload:()=>H({t:`cancelDownload`}),retryBrowser:()=>H({t:`retryBrowser`}),run:e=>H({t:`run`,port:e}),stop:e=>H({t:`stop`,port:e}),keepWaiting:e=>H({t:`keepWaiting`,port:e}),close:a,useHere:je,copy:gn}),[H,a])}}function xn(e){return(0,J.jsx)(he,{onClose:e.onClose,children:(0,J.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:b,chooseQuality:ee,addressError:x,urlInput:S,send:C,streaming:w,openServer:T,openAgent:E,empty:te,navigate:ne,actions:re}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ie,dim:ae}=cn({transport:l.state,takenOver:d,empty:te,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),oe=ln(ie,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:re});return(0,J.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,J.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:b,compact:c,navEnabled:w,loading:f?.stage===`loading`,stats:w?_??{fps:0,kbps:0}:void 0,status:w?void 0:Sn(l,u,d!==void 0,f),urlInputRef:S,onSession:a,onNavigate:ne,onBack:()=>C({t:`back`}),onForward:()=>C({t:`forward`}),onReload:e=>C({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:ee,onCopyUrl:()=>gn(p),onStop:e=>C({t:`stop`,port:e}),onClose:o}),x?(0,J.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,J.jsx)(Tn,{transportState:s,overlay:oe,dim:ae,lost:k})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,J.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,J.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,J.jsx)(ut,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,J.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,J.jsx)(ft,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=ge(e);return(0,q.useMemo)(()=>{let e=new Map;for(let n of E(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=F(e.run.id);return(0,J.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{C as u,Jr as d,Kt as f,T as p,an as m,i as h,k as g,on as _}from"./project-scope-context-B3M-u8R0.js";import{lt as v}from"./live-protocol-BVn0UA_g.js";import{Et as y,H as ee,J as b,P as x,Rn as te,T as ne,Un as S,Vt as re,Yt as C,dt as w,ft as T,mt as ie,n as E,pt as ae}from"./queries-DORTKwyN.js";import{n as D}from"./toaster-B1MyeHiE.js";import{i as O,l as oe,p as se,r as ce,t as le}from"./dropdown-menu-DhrBcVgr.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-Dj464rjk.js";import{D as ue,I as de,M as fe,N as pe,Q as me,S as he,X as ge,Z as _e,c as ve,ct as L,d as ye,j as R,n as be,st as xe,w as z,y as Se}from"./design-icons-DmYTv2r1.js";import{a as B,t as Ce}from"./loader-circle-CZkGEdoI.js";import{t as V}from"./createLucideIcon-BHp8sXmF.js";import{l as we,n as Te,y as Ee}from"./nav-row-styles-BZUUavOF.js";import{n as De,r as Oe}from"./diff-controls-BR2uqhwG.js";import{i as ke,r as Ae,t as je}from"./git-toolbar-DMDmGits.js";import{t as H}from"./info-DA1x_4bz.js";import{a as Me,l as Ne,n as Pe,t as Fe}from"./control-locations-C9II3kPz.js";import{t as U}from"./project-router-MMOk9VbW.js";import{t as W}from"./centered-state-DGyy0SuA.js";import{Et as G,Kt as Ie,Tt as Le,a as Re,c as ze,d as Be,en as K,f as Ve,i as He,l as Ue,m as We,o as Ge,ot as Ke,p as qe,q,r as Je,rn as J,s as Ye,u as Xe}from"./index-FoxgrgAH.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-DNAtaTLC.js";import{t as $e}from"./commit-diff-panel-DZutYRbq.js";var Y=e(c(),1);function et(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=V(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),nt=V(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=l();function rt(){let e=i(),t=w(),n=d(),r=et({queryKey:E.repo})>0,a=t.data?.info?t.data:null,o=Je(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:Te,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(we,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:E.repo}),n.invalidateQueries({queryKey:E.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(_e,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(He,{branch:a?.info?.branch??null,counts:o,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function it({repo:e,info:t}){let n=x(),r=T(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=d(),c=S({mutationFn:e=>u({name:e}),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:E.repo}),a.invalidateQueries({queryKey:E.health})]),a.setQueryData(E.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(E.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>D(e.message,{tone:`danger`})}),[l,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),h=p.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(me,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:p,onChange:e=>m(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(U,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(R,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,p.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&c.mutate(t,{onSuccess:()=>f(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>f(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(at,{}):null]})}function at(){let e=ne({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(ot,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(de,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(st,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:ct[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function ut(){let e=ae(),t=q(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Ae(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(je,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(De,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Oe,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(W,{icon:d?(0,X.jsx)(z,{size:16}):(0,X.jsx)(L,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(z,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(ke,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>qe(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Be(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(W,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(U,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,We(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(U,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:s(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(ve,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function pt({info:e,tracking:t}){let n=ze(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(be,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:q()?`/git`:Ue,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function ht(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function gt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=T(),t=y(),n=i(),r=b(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(U,{to:Xe.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Me,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(yt,{}),l,s.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(Ie,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(bt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Pe,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(wt,{entry:e})]}):null})}function St({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=S({mutationFn:()=>p(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:E.repoBranches}),n.invalidateQueries({queryKey:E.runs.all})},onError:e=>D(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>D(`Copied ${e.name}`),()=>D(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(le,{children:[(0,X.jsx)(se,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(ce,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(O,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(U,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(O,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(O,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(oe,{className:`md:hidden`}),(0,X.jsx)(O,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=B(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ee,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ke,{tone:e.runStatus&&_t[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=te(Ne(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function Tt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:E.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(I,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(j,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(J,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(M,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=T(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;D(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:E.repo})},onError:e=>{n.invalidateQueries({queryKey:E.repo}),D(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let f=l.length,p=`branch${f===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,f]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:f===0||u.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(xe,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${f} ${p}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(I,{open:a,onOpenChange:o,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,f,` `,p,`?`]}),(0,X.jsxs)(k,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsxs)(M,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,f,` `,p]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(ye,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:B(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>f(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:E.worktrees}),r.invalidateQueries({queryKey:E.repoBranches})]),s=S({mutationFn:e=>_(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);D(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>D(e.message,{tone:`danger`})}),c=S({mutationFn:e=>m(e.runId),onSuccess:(e,t)=>{o(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),D(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:u,keep:p}=e.data,h=s.isPending||c.isPending,g=l.filter(e=>e.pastKeep),v=g.length>0,y=g.some(e=>e.sizeBytes===null)?null:g.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${C(y)} now`:`Reclaim ${g.length} now`:`Reclaim now`,x=u?C(u):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(U,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Fe(`worktrees`,` › `)}),p===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:h||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(I,{open:i,onOpenChange:a,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsx)(A,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(k,{children:[g.length,` finished worktree`,g.length===1?``:`s`,` beyond the keep limit`,y?` (${C(y)})`:``,` `,g.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsx)(M,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(g.length),a(!1)},children:b})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=B(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:C(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=w(),a=q(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Le,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(R,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Re(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ve(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Ft,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Ft({repo:e,info:t}){let n=Q(e,T().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{C as u,Jr as d,Kt as f,T as p,an as m,i as h,k as g,on as _}from"./project-scope-context-B3M-u8R0.js";import{lt as v}from"./live-protocol-BVn0UA_g.js";import{Et as y,H as ee,J as b,P as x,Rn as te,T as ne,Un as S,Vt as re,Yt as C,dt as w,ft as T,mt as ie,n as E,pt as ae}from"./queries-DORTKwyN.js";import{n as D}from"./toaster-B1MyeHiE.js";import{i as O,l as oe,p as se,r as ce,t as le}from"./dropdown-menu-DhrBcVgr.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-Dj464rjk.js";import{D as ue,I as de,M as fe,N as pe,Q as me,S as he,X as ge,Z as _e,c as ve,ct as L,d as ye,j as R,n as be,st as xe,w as z,y as Se}from"./design-icons-DmYTv2r1.js";import{a as B,t as Ce}from"./loader-circle-CZkGEdoI.js";import{t as V}from"./createLucideIcon-BHp8sXmF.js";import{l as we,n as Te,y as Ee}from"./nav-row-styles-BZUUavOF.js";import{n as De,r as Oe}from"./diff-controls-BR2uqhwG.js";import{i as ke,r as Ae,t as je}from"./git-toolbar-D9taioU5.js";import{t as H}from"./info-DA1x_4bz.js";import{a as Me,l as Ne,n as Pe,t as Fe}from"./control-locations-C9II3kPz.js";import{t as U}from"./project-router-MMOk9VbW.js";import{t as W}from"./centered-state-DGyy0SuA.js";import{Et as G,Kt as Ie,Tt as Le,a as Re,c as ze,d as Be,en as K,f as Ve,i as He,l as Ue,m as We,o as Ge,ot as Ke,p as qe,q,r as Je,rn as J,s as Ye,u as Xe}from"./index-DgU3yYUl.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-D_9MtICR.js";import{t as $e}from"./commit-diff-panel-BJyNYmCY.js";var Y=e(c(),1);function et(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=V(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),nt=V(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=l();function rt(){let e=i(),t=w(),n=d(),r=et({queryKey:E.repo})>0,a=t.data?.info?t.data:null,o=Je(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:Te,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(we,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:E.repo}),n.invalidateQueries({queryKey:E.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(_e,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(He,{branch:a?.info?.branch??null,counts:o,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function it({repo:e,info:t}){let n=x(),r=T(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=d(),c=S({mutationFn:e=>u({name:e}),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:E.repo}),a.invalidateQueries({queryKey:E.health})]),a.setQueryData(E.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(E.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>D(e.message,{tone:`danger`})}),[l,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),h=p.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(me,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:p,onChange:e=>m(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(U,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(R,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,p.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&c.mutate(t,{onSuccess:()=>f(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>f(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(at,{}):null]})}function at(){let e=ne({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(ot,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(de,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(st,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:ct[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function ut(){let e=ae(),t=q(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Ae(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(je,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(De,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Oe,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(W,{icon:d?(0,X.jsx)(z,{size:16}):(0,X.jsx)(L,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(z,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(ke,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>qe(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Be(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(W,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(U,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,We(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;return e?(0,X.jsxs)(U,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:s(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(ve,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function pt({info:e,tracking:t}){let n=ze(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(be,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:q()?`/git`:Ue,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function ht(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function gt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=T(),t=y(),n=i(),r=b(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(U,{to:Xe.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Me,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(yt,{}),l,s.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(Ie,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(bt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Pe,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(wt,{entry:e})]}):null})}function St({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=S({mutationFn:()=>p(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:E.repoBranches}),n.invalidateQueries({queryKey:E.runs.all})},onError:e=>D(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>D(`Copied ${e.name}`),()=>D(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(le,{children:[(0,X.jsx)(se,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(ce,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(O,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(U,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(O,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(O,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(oe,{className:`md:hidden`}),(0,X.jsx)(O,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=B(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ee,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ke,{tone:e.runStatus&&_t[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=te(Ne(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function Tt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:E.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(I,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(j,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(J,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(M,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=T(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;D(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:E.repo})},onError:e=>{n.invalidateQueries({queryKey:E.repo}),D(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let f=l.length,p=`branch${f===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,f]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:f===0||u.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(xe,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${f} ${p}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(I,{open:a,onOpenChange:o,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,f,` `,p,`?`]}),(0,X.jsxs)(k,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsxs)(M,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,f,` `,p]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(ye,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(U,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:B(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>f(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:E.worktrees}),r.invalidateQueries({queryKey:E.repoBranches})]),s=S({mutationFn:e=>_(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);D(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>D(e.message,{tone:`danger`})}),c=S({mutationFn:e=>m(e.runId),onSuccess:(e,t)=>{o(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),D(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:l,totalBytes:u,keep:p}=e.data,h=s.isPending||c.isPending,g=l.filter(e=>e.pastKeep),v=g.length>0,y=g.some(e=>e.sizeBytes===null)?null:g.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${C(y)} now`:`Reclaim ${g.length} now`:`Reclaim now`,x=u?C(u):null;return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(U,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Fe(`worktrees`,` › `)}),p===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:h||!v,title:v?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(I,{open:i,onOpenChange:a,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsx)(A,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(k,{children:[g.length,` finished worktree`,g.length===1?``:`s`,` beyond the keep limit`,y?` (${C(y)})`:``,` `,g.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsx)(M,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(g.length),a(!1)},children:b})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=B(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:C(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:a,className:d,children:(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=w(),a=q(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Le,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(R,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Re(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`no commits yet`:`latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Ve(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Ft,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`nothing here can delete work that is not on `,r]})}}function Ft({repo:e,info:t}){let n=Q(e,T().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{c as u,i as d}from"./project-scope-context-B3M-u8R0.js";import{C as f,u as p}from"./queries-DORTKwyN.js";import{ct as m,r as h}from"./design-icons-DmYTv2r1.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-D08Kq15E.js";import{t as S}from"./centered-state-DGyy0SuA.js";import{s as C}from"./markdown-D7DUNWcJ.js";import{gt as w,ht as T,mt as E}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{c as u,i as d}from"./project-scope-context-B3M-u8R0.js";import{C as f,u as p}from"./queries-DORTKwyN.js";import{ct as m,r as h}from"./design-icons-DmYTv2r1.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-D08Kq15E.js";import{t as S}from"./centered-state-DGyy0SuA.js";import{s as C}from"./markdown-D7DUNWcJ.js";import{gt as w,ht as T,mt as E}from"./index-DgU3yYUl.js";var D=e(c(),1),O=l();function k(){let e=t(),n=s();return()=>{if(e.key==="default"||window.history.state?.idx===0){n({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let t=window.navigation,r=A(e.state);t?.canGoBack?t.back():r?n(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):n(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=n(),t=e.get(`path`),r=e.get(`artifact`);return{path:t,artifactId:r,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&r!==null||t===``||r===``}}function N(){let{id:e=``}=r(),n=M(),i=t(),a=k();return(0,O.jsx)(P,{runId:e,selection:n,fragment:i.hash,onBack:a,variant:`route`})}function P({runId:e,selection:n,fragment:r,onBack:a,variant:o,sourceLookup:s}){let{path:c,conflict:l,selected:u,result:d}=I(e,n,s),f=w(E,!0),p=w(T,!1),m=t(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(o===`route`&&L(_))return(0,O.jsx)(i,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,c),y=o===`pane`&&!p&&!f?`Conversation`:`Back`,b=o===`pane`&&!h&&R(_),x=F(m.pathname,e,n);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":o,onKeyDown:e=>{o!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),a())},className:o===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:a,backLabel:y,hideDownload:o===`pane`&&p,focusBack:o===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:l,selected:u,result:d,source:h,name:v,fragment:r,pane:o===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:a=!1}=t,o=n?.isPending||n?.isError,s=f(e,i||a||o?null:r),c=p(e,a||o?null:i),l=o&&n?{...n,data:void 0}:i?c:s;return{path:r,conflict:a,selected:r!==null||i!==null,result:l}}function L(e){return e!==null&&(!C(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let d=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&d.current?.focus({preventScroll:!0})},[l]);let f=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(o,{ref:d,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(h,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[f?`Published snapshot · ${new Date(f.createdAt).toLocaleString()}`:`Live file`,` · `,_(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(o,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,f&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:u(e,f.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:o,pane:s,filesHref:c}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let l=n.data;return l.type===`file`?s&&!C(l.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(a,{to:c,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):l.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Too large to preview`,subtitle:`${_(l.size)} is past the 500 kB preview limit. Download it to read it.`}):l.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(x,{path:l.path,text:l.content??``})}):(0,O.jsx)(y,{html:l.content??``,title:`Report: ${i}`,fragment:o,className:s?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:l.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:l.reason})}function H({result:e}){let t=e.error instanceof d&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(b,{}):(0,O.jsx)(m,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(o,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,I as n,M as r,T as i,t as a}from"./button-CHUAMTHK.js";import{i as o,t as s}from"./react-runtime-CCIEwYL0.js";import{Dr as c,En as l,Jr as u,Xn as d,kr as f,p,zt as m}from"./project-scope-context-B3M-u8R0.js";import{$ as h,J as g,X as _,Z as v,ct as y,et as b,rt as x,st as S}from"./live-protocol-BVn0UA_g.js";import{t as C}from"./useInfiniteQuery-BbYMWe23.js";import{n as w,t as T}from"./ws-BtSVmivO.js";import{t as E}from"./project-router-MMOk9VbW.js";import{rn as D,yt as O}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,I as n,M as r,T as i,t as a}from"./button-CHUAMTHK.js";import{i as o,t as s}from"./react-runtime-CCIEwYL0.js";import{Dr as c,En as l,Jr as u,Xn as d,kr as f,p,zt as m}from"./project-scope-context-B3M-u8R0.js";import{$ as h,J as g,X as _,Z as v,ct as y,et as b,rt as x,st as S}from"./live-protocol-BVn0UA_g.js";import{t as C}from"./useInfiniteQuery-BbYMWe23.js";import{n as w,t as T}from"./ws-BtSVmivO.js";import{t as E}from"./project-router-MMOk9VbW.js";import{rn as D,yt as O}from"./index-DgU3yYUl.js";import{t as k}from"./report-title-D4Mbu2Er.js";var A=e(o(),1),j=1e3,M=x().min(1).max(1024);b({q:x().max(j).optional(),before:M.optional(),limit:x().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var N=b({reports:g(b({id:S(),runId:S(),name:x(),title:x(),createdAt:y(),size:h().int().nonnegative(),taskTitle:x(),taskStatus:d}).strict()),nextCursor:M.nullable(),total:h().int().nonnegative()}).strict(),P=b({epoch:S(),generation:h().int().nonnegative(),metadataGeneration:h().int().nonnegative()}).strict(),F=b({runId:S(),taskTitle:x(),taskStatus:d}).strict(),I=_(`type`,[P.extend({type:v(`snapshot`)}),P.extend({type:v(`content`)}),P.extend({type:v(`metadata`),runs:g(F)})]),L=new WeakMap;function R(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var z=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=R(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function B(e,t){let n=L.get(e);n||(n=new Map,L.set(e,n));let r=n.get(t);return r||(r=new z(e,t),n.set(t,r)),r}async function V(e,t){let n=await p.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},m({signal:t}));return P.parse(await l(n,`/reports/state`))}function H(e){let t=B(u(),e);return(0,A.useEffect)(()=>{let n=T(`reports:project:${e}`,e=>{let n=I.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(c()===`finite`&&!r){i=new AbortController;let n=i.signal;V(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=w({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=P.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let o=f(a);return()=>{o(),i?.abort(),r?.(),n()}},[t,e]),t}async function U(e,t,n,r){let i=await p.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,j),...n?{before:n}:{}}},m(r?{signal:r}:void 0));return N.parse(await l(i,`/reports`))}function W(e){let t=r(),n=H(t);return C({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>U(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var G=s(),K=new Map;function q(){let e=t(),r=i(),[o,s]=O(),c=(o.get(`q`)??``).slice(0,j),l=W(c),u=(0,A.useRef)(null),d=(0,A.useRef)(``),f=e.pathname+e.search,p=l.data?.pages.flatMap(e=>e.reports)??[];(0,A.useLayoutEffect)(()=>{if(!l.data||d.current===f)return;let t=K.get(f),n=e.state?.filesRestoreKey===f;if(!t||!u.current||r!==`POP`&&!n){d.current=f;return}let i=u.current.querySelector(`[data-report-id="${t.row}"]`);if(l.isFetchNextPageError){d.current=f,u.current.scrollTop=0;return}if((!i||l.data.pages.length<t.pages)&&l.hasNextPage){l.isFetchingNextPage||l.fetchNextPage();return}d.current=f,u.current.scrollTop=i?t.scroll:0,i?.focus({preventScroll:!0})},[f,l.data,l.hasNextPage,l.isFetchingNextPage,l.isFetchNextPageError,l.fetchNextPage,e.state,r]);let m=t=>s(n=>(t?n.set(`q`,t.slice(0,j)):n.delete(`q`),K.delete(e.pathname+`?`+n.toString()),n));return(0,G.jsxs)(`section`,{"data-route":`reports`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border p-4`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Reports`}),(0,G.jsx)(D,{maxLength:j,"aria-label":`Search reports`,placeholder:`Search reports or source tasks`,value:c,onChange:e=>m(e.target.value),className:`min-h-11`})]}),(0,G.jsxs)(`div`,{ref:u,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable]`,children:[l.isPending?(0,G.jsx)(`p`,{role:`status`,children:`Loading reports…`}):l.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`p`,{children:`Could not load reports`}),(0,G.jsx)(`p`,{className:`text-sm text-soft-foreground`,children:l.error.message}),(0,G.jsx)(a,{className:`min-h-11`,onClick:()=>void l.refetch(),children:`Retry`})]}):p.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-medium`,children:c?`No matching reports`:`No published reports yet`}),c?(0,G.jsx)(a,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>m(``),children:`Clear search`}):(0,G.jsxs)(`p`,{className:`text-sm text-soft-foreground`,children:[`Publish an HTML snapshot with `,(0,G.jsxs)(`code`,{children:[n(),` artifact publish`]}),` to list it here.`]})]}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:p.map(e=>(0,G.jsxs)(`li`,{"data-slot":`report-row`,className:`reports-row rounded-lg border border-border bg-card p-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 font-medium [overflow-wrap:anywhere]`,children:(0,G.jsx)(E,{"data-report-id":e.id,className:`reports-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:f,filesRestoreKey:f},onClick:()=>K.set(f,{scroll:u.current?.scrollTop??0,row:e.id,pages:l.data?.pages.length??1}),children:k(e)})}),(0,G.jsx)(E,{className:`reports-task text-sm text-accent-text underline [overflow-wrap:anywhere]`,to:`/tasks/${e.runId}`,children:e.taskTitle}),(0,G.jsx)(`time`,{className:`block text-xs text-soft-foreground`,dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]},e.id))}),l.hasNextPage?(0,G.jsx)(a,{variant:`outline`,className:`min-h-11`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more reports`}):null]})]})}export{q as ReportsRoute};
|