cezarion 0.19.0-dev.8773 → 0.19.0-dev.8778
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/package.json +3 -3
- package/web/dist/assets/{accounts-section-CIgJyKva.js → accounts-section-DyE8nZhG.js} +1 -1
- package/web/dist/assets/{activity-motion-D_URV8Di.js → activity-motion-BbCsI0zQ.js} +1 -1
- package/web/dist/assets/{activity-route-Do33FDky.js → activity-route-BBHWMCvF.js} +1 -1
- package/web/dist/assets/{agent-config-section-BMfcQCbi.js → agent-config-section-7k8wATxQ.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-Co96ec0d.js → agent-defaults-section-DwjS2zpP.js} +1 -1
- package/web/dist/assets/{appearance-DkSPOcn0.js → appearance-Cz_Xisdp.js} +1 -1
- package/web/dist/assets/{automations-route-YNUMP0mD.js → automations-route-331MoIW6.js} +1 -1
- package/web/dist/assets/{commit-list-0tp9mxng.js → commit-list-Ogvgv0V9.js} +1 -1
- package/web/dist/assets/{diff-6Tr1DKFm.js → diff-ZGlCIC2o.js} +2 -2
- package/web/dist/assets/{diff-controls-Uj68AWl-.js → diff-controls-CY3bqJPO.js} +1 -1
- package/web/dist/assets/{diff-view-DMO64pR1.js → diff-view-9-FcV8NQ.js} +1 -1
- package/web/dist/assets/{file-preview-BqaVkwcr.js → file-preview-CBme1fo_.js} +1 -1
- package/web/dist/assets/{git-toolbar-D513sAp1.js → git-toolbar-p0Gt04pZ.js} +1 -1
- package/web/dist/assets/{github-C5qUGzPx.js → github-ohX3f9y8.js} +1 -1
- package/web/dist/assets/{global-activity-route-DRZlGf9a.js → global-activity-route-Do0nIcLb.js} +1 -1
- package/web/dist/assets/{index-CIAFRUw6.js → index-BSZD2aai.js} +4 -4
- package/web/dist/assets/index-BwvwfpYW.css +1 -0
- package/web/dist/assets/{markdown-B8uIJFot.js → markdown-BZgLow5j.js} +1 -1
- package/web/dist/assets/{notifications-section-DcR7A7aZ.js → notifications-section-UWrIuuqK.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-BOptVmB7.js → preview-pane-connected-D-NHVwVK.js} +1 -1
- package/web/dist/assets/{projects-section-ByjMveO2.js → projects-section-ZvcZ3_Gf.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-mztZbjR2.js → prompt-templates-section-C41o3_cn.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-_lT2fFKo.js → remote-settings-notice-BsKK4zWt.js} +1 -1
- package/web/dist/assets/{repo-git-muNCGIF4.js → repo-git-CaKYihkq.js} +1 -1
- package/web/dist/assets/{report-reader-CJTciXLf.js → report-reader-MQRVVGOV.js} +1 -1
- package/web/dist/assets/{reports-Ddq_ls0m.js → reports-BkkJOinX.js} +1 -1
- package/web/dist/assets/{resources-section-C5ssAmKn.js → resources-section-D4cLySUg.js} +1 -1
- package/web/dist/assets/{review-panel-wst8aLz4.js → review-panel-DwoLnSOz.js} +1 -1
- package/web/dist/assets/{run-header-bZAJ80iC.js → run-header-DXt2EtCb.js} +1 -1
- package/web/dist/assets/{select-B05NBo-9.js → select-DsxHxI9X.js} +1 -1
- package/web/dist/assets/{session-context-section-BzflGStM.js → session-context-section-Dq7kwhFC.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-BjvjnUs4.js → settings-agent-picker--LZQKc3H.js} +1 -1
- package/web/dist/assets/{settings-shell-vD5R1O7D.js → settings-shell-BLI4CANd.js} +1 -1
- package/web/dist/assets/{sidebar-section-BZLTjCJ6.js → sidebar-section-BZKlFvG9.js} +1 -1
- package/web/dist/assets/{skills-BNbkK6g-.js → skills-Dvzt9DdF.js} +1 -1
- package/web/dist/assets/{task-changes-BbRB1M0L.js → task-changes-Bj8vcfpY.js} +1 -1
- package/web/dist/assets/{task-commits-_hMQ47BK.js → task-commits-D2sgt47s.js} +1 -1
- package/web/dist/assets/{task-file-scope-CGgYP4rR.js → task-file-scope-BEi9o8Ur.js} +1 -1
- package/web/dist/assets/{task-files-Cce3Lghe.js → task-files-CSGqLTZ9.js} +1 -1
- package/web/dist/assets/{task-github-item-C25rYc6W.js → task-github-item-DyMsNAdL.js} +1 -1
- package/web/dist/assets/{task-thread-Cqs9j6f8.js → task-thread-D7iB5aiK.js} +1 -1
- package/web/dist/assets/{thread-state-C4f5H6np.js → thread-state-D8MmuQvJ.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-Dnb5uNM1.js → use-hand-to-agent-state-BFCOOUq3.js} +1 -1
- package/web/dist/assets/{workflows-FH3RBKvk.css → workflows-BpuZNAc8.css} +1 -1
- package/web/dist/assets/workflows-V_D7FZYN.js +7 -0
- package/web/dist/assets/{workspace-tools-DJcDHrF-.js → workspace-tools-BwNE3W6C.js} +1 -1
- package/web/dist/assets/{worktrees-section-DRG2wiAo.js → worktrees-section-DLigjWPB.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-DclFk8VO.css +0 -1
- package/web/dist/assets/workflows-Cl1NhrpU.js +0 -7
package/web/dist/assets/{preview-pane-connected-BOptVmB7.js → preview-pane-connected-D-NHVwVK.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Xr as i,Yr as a,Zr as o,mr as s,n as c}from"./toaster-Cer2NOxt.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Xr as i,Yr as a,Zr as o,mr as s,n as c}from"./toaster-Cer2NOxt.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-D8MmuQvJ.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-B7MKxYjT.js";import{a as T,c as re,i as E,l as D,p as O,r as k,s as ie,t as A}from"./dropdown-menu-4e2iKSMT.js";import{s as ae}from"./project-router-BypHPat0.js";import{t as j}from"./status-dot-BRzVlF2X.js";import{$n as oe,Bn as se,Rn as ce,Vn as le,_ as ue,c as de,cr as fe,d as pe,dr as me,f as M,l as he,lr as N,nr as ge,p as _e,u as ve,v as ye,y as be,zn as xe}from"./index-BSZD2aai.js";var Se=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),F=l(`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`}]]),I=l(`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`}]]),L=l(`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`}]]),we=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),R=l(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=l(`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`}]]),Te=l(`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`}]]),Ee=l(`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`}]]),B=l(`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`}]]),V=l(`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`}]]),H=l(`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`}]]),U=l(`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`}]]),W=l(`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`}]]),G=l(`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`}]]),K=l(`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`}]]),q=l(`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`}]]),De=l(`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`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(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}`,o=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,o=n,n.addEventListener(`open`,()=>{n===o&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==o)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.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!==o||l)return;if(o=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)o||m();else{clearTimeout(c),c=void 0;let e=o;o=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){o?.readyState===Ae&&o.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=o;o=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(se,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(le,{asChild:!0,children:(0,Y.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-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(xe,{children:`Experimental`})]})}):e?(0,Y.jsx)(se,{children:(0,Y.jsxs)(ce,{children:[(0,Y.jsx)(le,{asChild:!0,children:(0,Y.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,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(xe,{children:`Experimental`})]})}):(0,Y.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,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function X({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
2
|
`);return(0,Y.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,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.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,Y.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Ne=/^([a-z][a-z0-9+.-]*):/i;function Pe(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=Ne.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.`}:Fe(n):Fe(`http://${n}`)}function Fe(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 Ie(e){return e.replace(/^https?:\/\//i,``)}var Le=`https://github.com/hearsay-tools/squawk#environment-variables`;function Re({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(He,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(We,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(qe,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Xe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(tt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(rt,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(it,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(at,{actions:t});case`taken-over`:return(0,Y.jsx)(st,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,Y.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,Y.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,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function ze({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ne,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function Be({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.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,Y.jsx)(`span`,{children:n}),(0,Y.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,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ve({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(ze,{server:e})})]})}function He({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Q,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ue(e){return Math.round(e/1e6)}function We({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ue(e.received)} of ${Ue(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ge({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(W,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Q,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function qe({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Je=2;function Ye(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Xe({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:r?(0,Y.jsx)(q,{className:`text-pending-strong`}):(0,Y.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Q,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ve,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Ze({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Q,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function Qe({state:e,actions:t}){let{server:n}=e,r=Ye(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Je-(r-a)/1e3));return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Q,{children:`Squawk ran ${M(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(v,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(X,{text:e.logTail.join(`
|
|
3
3
|
`),source:M(n.command),onCopy:t.copy}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function $e({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(R,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Q,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(X,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Q,{children:`${M(n.command)} stopped.`}),(0,Y.jsx)(X,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}function tt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(ee,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Q,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Ie(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Ie(e.lastUrl)}.`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}var nt=[`browser`,`page`,`frame`];function rt({step:e,url:t}){let n=nt.indexOf(e),i=t?Ie(t):`the page`;return(0,Y.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,Y.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,Y.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,Y.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(v,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function it({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(L,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Q,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(S,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function at({actions:e}){return(0,Y.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,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(V,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Q,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ot(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 st({state:e,actions:t}){let n=ot(e.by);return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ct({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(w,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function lt({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`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,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Q,{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.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.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,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.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,Y.jsx)(`ul`,{children:e.map(e=>{let r=ve(e,t),i=_e(r);return(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:pe(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(_,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.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 ut({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.current=t,(0,J.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(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.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,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-card-edge bg-card p-4 shadow-modal`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},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,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(w,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var dt=10,ft=500,pt=500,mt=4,ht=16,gt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function _t(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function vt(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 yt=[`left`,`middle`,`right`];function bt(e,t,n,r){let i=_t(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:yt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:gt(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=_t(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(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)<=dt)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?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=ft;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[bt(`mouseMoved`,t,a,{button:`none`,buttons:0}),bt(`mousePressed`,t,a,{button:`left`,buttons:1}),bt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=pt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=mt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[bt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[bt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[bt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=_t(e.clientX,e.clientY,t,n),i=e.deltaMode===1?ht: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:gt(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(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:gt(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`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:gt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(vt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.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 wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(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(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.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 Mt(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 Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:o,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||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,J.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,Y.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,Y.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,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{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 It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:g},{w:820,h:1180,icon:G},{w:1440,h:900,icon:y}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem] max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(C,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(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 Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),p=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(U,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,Y.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,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,b={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:b}):(0,Y.jsx)(on,{props:e,elements:b,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=_e(ve(t,e.serverStates));return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,Y.jsx)(h,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Ie(s)),title:s||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`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.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,Y.jsx)(z,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(Ee,{"aria-hidden":`true`}):(0,Y.jsx)(y,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(E,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(Ee,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(E,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ie,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(re,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,role:`img`,"aria-label":t.label,title:t.label,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function rn({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(fe,{"aria-hidden":`true`})})}),(0,Y.jsxs)(k,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,Y.jsx)(T,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(n)}):null,(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(ge,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),o?(0,Y.jsxs)(E,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Te,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(E,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1 border-b border-border bg-background px-2 py-2 @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,children:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(oe,{"aria-hidden":`true`})}),h]})}function sn({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 cn(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,Y.jsx)(Re,{...n,actions:o})}case`empty`:return(0,Y.jsx)(lt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(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 hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(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 vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:s}){let l=un(),u=(0,J.useRef)(l);u.current=l;let d=o(),f=(0,J.useRef)(crypto.randomUUID()),p=(0,J.useRef)(!1),m=ae(),h=ye(ue,!1),[g,_]=(0,J.useState)(0),[v,y]=(0,J.useState)({state:`connecting`,attempt:0}),[ee,b]=(0,J.useState)(!1),[x,te]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[ne,w]=(0,J.useState)(``),[T,re]=(0,J.useState)(void 0),[E,D]=(0,J.useState)(!1),[O,k]=(0,J.useState)(void 0),[ie,A]=(0,J.useState)(!1),[j,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,de]=(0,J.useState)(void 0),[fe,pe]=(0,J.useState)(void 0),[me,M]=(0,J.useState)(`fit`),[he,N]=(0,J.useState)(Rt),[ge,_e]=(0,J.useState)(null),[ve,be]=(0,J.useState)(void 0),[xe,Se]=(0,J.useState)(0),P=(0,J.useRef)(void 0),Ce=(0,J.useRef)(null),F=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),we=(0,J.useRef)(he);we.current=he;let R=(0,J.useRef)({port:T,stage:S,agent:E});R.current={port:T,stage:S,agent:E};let z=(0,J.useRef)([]),Te=(0,J.useRef)(void 0),Ee=(0,J.useRef)(!1),B=(0,J.useRef)(!1),V=(0,J.useCallback)(e=>{B.current&&P.current?.send(e)},[]),H=(0,J.useRef)([]),U=(0,J.useCallback)(e=>{B.current?P.current?.send(e):H.current.push(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,oe(!0)),(Ce.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`)&&Se(e=>e+1),L.current!==void 0&&mn(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 w(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return de(e);case`pong`:Te.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`:te(e.by),B.current=!1,H.current=[],t?.close();return}},onTransport(e,n){if(B.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(H.current=[]),e===`open`){b(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:f.current,resume:p.current,quality:we.current,dpr:u.current}),p.current=!0);for(let e of H.current.splice(0))t?.send(e)}}}),P.current=t,()=>{B.current=!1,H.current=[],t?.close(),P.current===t&&(P.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&x===void 0,G=h||me===`fit`?ge:me;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&V({t:`resize`,w:G.w,h:G.h,...l===1?{}:{dpr:l}})},[G?.w,G?.h,l,W,S?.stage,xe,V]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){pe(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=pn);let t={fps:z.current.length,kbps:Math.round(z.current.reduce((e,t)=>e+t.bytes,0)/1024),...Te.current===void 0?{}:{rttMs:Te.current},...z.current.length>0?{lastFrameAt:z.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})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,A(!0),C(void 0),te(void 0),be(void 0),w(t),re(`port`in e?e.port:void 0),D(`agent`in e),k(vn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),De=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Oe=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;Oe();return}if(n?.url!==void 0){let e=Pe(n.url,t);e.kind===`server`?De(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||R.current.port===n.port&&R.current.stage?.stage===`streaming`&&n.run!==!0||De(n.port,n.run===!0))},[n]);let ke=!ie&&!x&&v.state!==`blocked`,Ae=_n(n,t);(0,J.useEffect)(()=>{ke&&!Ae&&F.current?.focus()},[ke,Ae]);let Y=e=>{let n=Pe(e,t);if(n.kind===`error`)return be(n.message);if(n.kind===`server`)return De(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,re(void 0),k({url:n.url}),be(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},Me=(0,J.useCallback)(e=>{we.current=e,N(e),zt(e),V({t:`quality`,quality:e})},[V]),X=()=>{p.current=!1,te(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:x,stage:S,url:ne,port:T,agent:E,hasFrame:j,cursor:se,dialog:le,setDialog:de,stats:fe,viewport:me,setViewport:M,quality:he,chooseQuality:Me,setStageSize:_e,addressError:ve,stageHandle:Ce,urlInput:F,send:V,connected:W,streaming:K,openServer:De,openAgent:Oe,empty:ke,navigate:Y,reconnect:X,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):c(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:s,useHere:X,copy:hn}),[V,U,s])}}function bn(e){return(0,Y.jsx)(be,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(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?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(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 Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(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:ee,chooseQuality:b,addressError:x,urlInput:te,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:re,actions:E}=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:A}=sn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),ae=cn(ie,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:E});return(0,Y.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,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:xn(l,u,d!==void 0,f),urlInputRef:te,onSession:a,onNavigate:re,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>ne(e),onPickAgent:w,onViewport:y,onQuality:b,onCopyUrl:()=>hn(p),onStop:E.stop,onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(wn,{transportState:s,overlay:ae,dim:A,lost:k})]})}function wn({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,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ct,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.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,Y.jsx)(ut,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=he(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of te(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=de(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Gt as o,It as s,Ot as c,Pt as l,St as u,dn as d,zt as f}from"./queries-EvENG6TN.js";import{hi as p,n as m,sn as h}from"./toaster-Cer2NOxt.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-B7MKxYjT.js";import{n as b,r as x,t as S}from"./popover-CZV6tz9i.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Gt as w,Ht as T,Jt as E,Kt as D,Ut as O,Vt as k,Wt as A,Zn as j,qt as M}from"./index-CIAFRUw6.js";import{t as N}from"./settings-select-CCIMGnyA.js";import{t as P}from"./save-cue-Cd3ZAPBS.js";import{n as F,t as I}from"./settings-field-DP9sYv5a.js";var L=t(n(),1),R=r();function z(){let e=c();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{m(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>m(e.message,{tone:`danger`})})}}function B({project:e,onOpenChange:t,onConfirm:n}){return(0,R.jsx)(k,{open:e!==null,onOpenChange:t,children:(0,R.jsxs)(A,{children:[(0,R.jsxs)(M,{children:[(0,R.jsxs)(E,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,R.jsxs)(w,{children:[`This only unregisters the project — `,(0,R.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,R.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-foreground`,title:e?.root,children:e?.root})]})]}),(0,R.jsxs)(D,{children:[(0,R.jsx)(O,{children:`Keep it`}),(0,R.jsx)(T,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var V=e({MaxParallelSelect:()=>Z,ProjectTagsEditor:()=>X,ProjectsSection:()=>G,STATUS_LABEL:()=>U}),H=1,U={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function G(){let e=s(),t=u();return e.isPending||t.isPending?(0,R.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,R.jsx)(C,{icon:(0,R.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,R.jsx)(K,{config:e.data,registry:t.data})}function K({config:e,registry:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,R.jsx)(q,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,R.jsx)(q,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,R.jsx)(J,{registry:t,workspaceMax:e.resources.maxParallel}),(0,R.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,R.jsx)(j,{open:!0,onOpenChange:r}):null]})}function q({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:s,footer:c,refreshProjects:l=!1}){let u=p(),f=d({mutationFn:t=>h(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(o.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:o.fsBrowseRoot}):l&&u.invalidateQueries({queryKey:o.projects})}}),[g,_]=(0,L.useState)(t),v=g.trim(),b=v===t,x=f.isError?f.error.message:null;return(0,R.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${a}-root`,value:g,disabled:f.isPending,placeholder:i,onChange:e=>{_(e.target.value),f.isError&&f.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,R.jsx)(P,{show:b&&v!==``&&!f.isPending,children:(0,R.jsx)(y,{type:`button`,variant:`primary`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:b||v===``||f.isPending,onClick:()=>f.mutate(v,{onSuccess:()=>m(`${s} set to ${v}`)}),children:`Save`})})]}),x===null?(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:c}):(0,R.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[x,` — setting unchanged`]})]})}function J({registry:e,workspaceMax:t}){let[n,r]=(0,L.useState)(null),i=z(),a=(0,L.useMemo)(()=>f(e.projects),[e.projects]);return(0,R.jsxs)(F,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,R.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:`104px`}}),(0,R.jsx)(`col`,{style:{width:`260px`}}),(0,R.jsx)(`col`,{style:{width:`150px`}}),(0,R.jsx)(`col`,{style:{width:`72px`}}),(0,R.jsx)(`col`,{style:{width:`92px`}})]}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.projects.map(n=>(0,R.jsx)(Y,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,R.jsx)(B,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Y({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,R.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,R.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,R.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-soft-foreground`,title:e.root,children:e.root})]}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,R.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:U[e.status]}),e.status===`missing`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsx)(X,{project:e,vocabulary:r})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:I,children:`Max parallel tasks`}),(0,R.jsx)(Z,{project:e,workspaceMax:n})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:W(e.addedAt)}),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,R.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,R.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,R.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function X({project:e,vocabulary:t}){let n=l(),[r,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[u,d]=(0,L.useState)(-1),f=(0,L.useRef)(null),p=e.tags??[],h=a(t,p,r),g=s&&h.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>m(r),onError:e=>m(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(p.length>=20){m(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,R.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,R.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,R.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,R.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,R.jsxs)(S,{open:g,onOpenChange:c,children:[(0,R.jsx)(b,{asChild:!0,children:(0,R.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":g,"aria-controls":g?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":g&&u>=0?`${w}-${u}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),d(-1),e.target.value.includes(`,`)){o(e.target.value.replace(/,/g,``));return}o(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&g){e.preventDefault(),c(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(u>=0?h[u]??r:r);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,R.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,R.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===u&&`bg-muted`),children:e},e))]})]})]})}function Z({project:e,workspaceMax:t}){let n=l(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,R.jsxs)(N,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>m(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>m(e.message,{tone:`danger`})})},className:`block w-full rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,R.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+H).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})}export{z as a,B as i,U as n,V as r,Z as t};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Gt as o,It as s,Ot as c,Pt as l,St as u,dn as d,zt as f}from"./queries-EvENG6TN.js";import{hi as p,n as m,sn as h}from"./toaster-Cer2NOxt.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-B7MKxYjT.js";import{n as b,r as x,t as S}from"./popover-CZV6tz9i.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Gt as w,Ht as T,Jt as E,Kt as D,Ut as O,Vt as k,Wt as A,Zn as j,qt as M}from"./index-BSZD2aai.js";import{t as N}from"./settings-select-CCIMGnyA.js";import{t as P}from"./save-cue-Cd3ZAPBS.js";import{n as F,t as I}from"./settings-field-DP9sYv5a.js";var L=t(n(),1),R=r();function z(){let e=c();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{m(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>m(e.message,{tone:`danger`})})}}function B({project:e,onOpenChange:t,onConfirm:n}){return(0,R.jsx)(k,{open:e!==null,onOpenChange:t,children:(0,R.jsxs)(A,{children:[(0,R.jsxs)(M,{children:[(0,R.jsxs)(E,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,R.jsxs)(w,{children:[`This only unregisters the project — `,(0,R.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,R.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-foreground`,title:e?.root,children:e?.root})]})]}),(0,R.jsxs)(D,{children:[(0,R.jsx)(O,{children:`Keep it`}),(0,R.jsx)(T,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var V=e({MaxParallelSelect:()=>Z,ProjectTagsEditor:()=>X,ProjectsSection:()=>G,STATUS_LABEL:()=>U}),H=1,U={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function G(){let e=s(),t=u();return e.isPending||t.isPending?(0,R.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,R.jsx)(C,{icon:(0,R.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,R.jsx)(K,{config:e.data,registry:t.data})}function K({config:e,registry:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,R.jsx)(q,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,R.jsx)(q,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,R.jsx)(J,{registry:t,workspaceMax:e.resources.maxParallel}),(0,R.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,R.jsx)(j,{open:!0,onOpenChange:r}):null]})}function q({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:s,footer:c,refreshProjects:l=!1}){let u=p(),f=d({mutationFn:t=>h(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(o.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:o.fsBrowseRoot}):l&&u.invalidateQueries({queryKey:o.projects})}}),[g,_]=(0,L.useState)(t),v=g.trim(),b=v===t,x=f.isError?f.error.message:null;return(0,R.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${a}-root`,value:g,disabled:f.isPending,placeholder:i,onChange:e=>{_(e.target.value),f.isError&&f.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,R.jsx)(P,{show:b&&v!==``&&!f.isPending,children:(0,R.jsx)(y,{type:`button`,variant:`primary`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:b||v===``||f.isPending,onClick:()=>f.mutate(v,{onSuccess:()=>m(`${s} set to ${v}`)}),children:`Save`})})]}),x===null?(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:c}):(0,R.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[x,` — setting unchanged`]})]})}function J({registry:e,workspaceMax:t}){let[n,r]=(0,L.useState)(null),i=z(),a=(0,L.useMemo)(()=>f(e.projects),[e.projects]);return(0,R.jsxs)(F,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,R.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:`104px`}}),(0,R.jsx)(`col`,{style:{width:`260px`}}),(0,R.jsx)(`col`,{style:{width:`150px`}}),(0,R.jsx)(`col`,{style:{width:`72px`}}),(0,R.jsx)(`col`,{style:{width:`92px`}})]}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.projects.map(n=>(0,R.jsx)(Y,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,R.jsx)(B,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Y({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,R.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,R.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,R.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-soft-foreground`,title:e.root,children:e.root})]}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,R.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:U[e.status]}),e.status===`missing`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsx)(X,{project:e,vocabulary:r})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:I,children:`Max parallel tasks`}),(0,R.jsx)(Z,{project:e,workspaceMax:n})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:W(e.addedAt)}),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,R.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,R.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,R.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function X({project:e,vocabulary:t}){let n=l(),[r,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[u,d]=(0,L.useState)(-1),f=(0,L.useRef)(null),p=e.tags??[],h=a(t,p,r),g=s&&h.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>m(r),onError:e=>m(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(p.length>=20){m(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,R.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,R.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,R.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,R.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,R.jsxs)(S,{open:g,onOpenChange:c,children:[(0,R.jsx)(b,{asChild:!0,children:(0,R.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":g,"aria-controls":g?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":g&&u>=0?`${w}-${u}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),d(-1),e.target.value.includes(`,`)){o(e.target.value.replace(/,/g,``));return}o(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&g){e.preventDefault(),c(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(u>=0?h[u]??r:r);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,R.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,R.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===u&&`bg-muted`),children:e},e))]})]})]})}function Z({project:e,workspaceMax:t}){let n=l(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,R.jsxs)(N,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>m(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>m(e.message,{tone:`danger`})})},className:`block w-full rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,R.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+H).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})}export{z as a,B as i,U as n,V as r,Z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Jt as i,Wt as a,dn as o,k as s}from"./queries-EvENG6TN.js";import{I as c,hi as l,n as u}from"./toaster-Cer2NOxt.js";import{J as d,W as f,at as p,c as m,ft as h,l as g,tt as _}from"./design-icons-CzEoMH9c.js";import{t as v}from"./button-B7MKxYjT.js";import{i as y,r as b,t as x}from"./popover-CZV6tz9i.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-KdW7aO0N.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-V15AR_qo.js";import{Xn as N,Z as P,et as F,fn as I,it as L,tt as R}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Jt as i,Wt as a,dn as o,k as s}from"./queries-EvENG6TN.js";import{I as c,hi as l,n as u}from"./toaster-Cer2NOxt.js";import{J as d,W as f,at as p,c as m,ft as h,l as g,tt as _}from"./design-icons-CzEoMH9c.js";import{t as v}from"./button-B7MKxYjT.js";import{i as y,r as b,t as x}from"./popover-CZV6tz9i.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-KdW7aO0N.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-V15AR_qo.js";import{Xn as N,Z as P,et as F,fn as I,it as L,tt as R}from"./index-BSZD2aai.js";import{t as z}from"./textarea-vJt9undk.js";import{n as B,t as V}from"./saved-draft-BwzBc-_Y.js";import{t as H}from"./save-cue-Cd3ZAPBS.js";import{t as U}from"./settings-field-DP9sYv5a.js";var W=e(t(),1),G=n();function K(){let e=s();return e.isPending?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,G.jsx)(M,{icon:(0,G.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,G.jsx)(q,{initial:R(e.data.promptTemplates)})}function q({initial:e}){let t=l(),n=i(),r=s(),[f,m]=B(e,V),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),x=o({mutationFn:e=>c({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(a.uiState,e),m(t=>V(t,n)?R(e.promptTemplates):t),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),S=JSON.stringify(f)!==JSON.stringify(e),C=g.trim()!==``||y.trim()!==``;I(S||C);let w=f.some(e=>e.label.trim()===``||e.text.trim()===``),T=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),E=(e,t)=>m(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),D=e=>m(t=>t.filter(t=>t.id!==e));return(0,G.jsx)(`div`,{"data-slot":`prompt-templates-section`,"data-reports-dirty":``,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,G.jsxs)(Y,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,G.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,G.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:U,children:`Template label`}),(0,G.jsx)(N,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>T(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,G.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:U,children:`Instructions`}),(0,G.jsx)(z,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>T(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsx)(`p`,{className:U,children:`Apply automatically with skills`}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(J,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>E(e.id,t)}),(e.skills??[]).map(t=>(0,G.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>E(e.id,t),className:`inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,G.jsx)(h,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,G.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>D(e.id),children:[(0,G.jsx)(p,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]},e.id))}),(0,G.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,G.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,G.jsx)(`label`,{htmlFor:`new-template-label`,className:U,children:`Label`}),(0,G.jsx)(N,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:g,maxLength:80,onChange:e=>_(e.target.value),className:`border-border bg-background`}),(0,G.jsx)(`label`,{htmlFor:`new-template-text`,className:U,children:`Instructions to insert`}),(0,G.jsx)(z,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:y,maxLength:2e3,onChange:e=>b(e.target.value),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!g.trim()||!y.trim(),onClick:()=>{let e=g.trim(),t=y.trim();!e||!t||(m(n=>[...n,{id:F(),label:e,text:t}]),_(``),b(``))},className:`self-start`,children:[(0,G.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(H,{show:!S&&!w&&!x.isPending,children:(0,G.jsx)(v,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!S||w||x.isPending,onClick:()=>x.mutate(f),children:`Save`})}),(0,G.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:x.isPending,onClick:()=>m(P.map(e=>({...e}))),children:`Reset to defaults`}),w?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function J({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useRef)(null),{mostUsed:d,project:f,global:p,ranked:h}=j(t,c,n),v=(e,t)=>{let n=i.includes(e.id);return(0,G.jsxs)(w,{value:O(e),keywords:A(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,G.jsx)(L,{skill:e,emphasized:t}),n?(0,G.jsx)(m,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,G.jsxs)(x,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`text-foreground`),children:[(0,G.jsx)(_,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,G.jsx)(g,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,G.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,G.jsxs)(D,{shouldFilter:!1,children:[(0,G.jsx)(S,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,G.jsxs)(E,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,G.jsx)(C,{children:(0,G.jsxs)(w,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(h?h.length===0:d.length===0&&f.length===0&&p.length===0)?(0,G.jsx)(T,{children:`Nothing matches.`}):null,h?h.length>0?(0,G.jsx)(C,{children:h.map(e=>v(e,k(e)))}):null:(0,G.jsxs)(G.Fragment,{children:[d.length>0?(0,G.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,G.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,p.length>0?(0,G.jsx)(C,{heading:`Global`,children:p.map(e=>v(e,!1))}):null]})]})]})})]})}function Y({title:e,hint:t,children:n}){return(0,G.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{K as PromptTemplatesSection};
|
package/web/dist/assets/{remote-settings-notice-_lT2fFKo.js → remote-settings-notice-BsKK4zWt.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gt as r,Wt as i,yt as a}from"./queries-EvENG6TN.js";import{hi as o}from"./toaster-Cer2NOxt.js";import{pn as s}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gt as r,Wt as i,yt as a}from"./queries-EvENG6TN.js";import{hi as o}from"./toaster-Cer2NOxt.js";import{pn as s}from"./index-BSZD2aai.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as ee}from"./queries-EvENG6TN.js";import{Fn as v,It as te,L as y,R as ne,ct as b,f as x,hi as S,l as C,n as w}from"./toaster-Cer2NOxt.js";import{Z as T}from"./live-protocol-DMhTnCmf.js";import{g as E,h as re}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as D}from"./tasks-table-DGBiE6ux.js";import{A as ie,C as O,E as ae,F as k,J as A,M as oe,X as se,Y as ce,at as le,j as ue,n as de,ot as j,s as fe,u as pe,v as me,x as he}from"./design-icons-CzEoMH9c.js";import{t as ge}from"./createLucideIcon-BHp8sXmF.js";import{n as _e,t as ve}from"./circle-x-7nTlobAF.js";import{_ as ye}from"./nav-row-styles-D5HpOmDZ.js";import{i as be,r as xe,t as Se}from"./git-toolbar-D513sAp1.js";import{t as M}from"./info-DA1x_4bz.js";import{t as Ce}from"./loader-circle-CPBhhDbB.js";import{n as we,r as Te}from"./diff-controls-Uj68AWl-.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-BLHAGMsc.js";import{t as N}from"./button-B7MKxYjT.js";import{i as P,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-BypHPat0.js";import{t as Ne}from"./status-dot-BRzVlF2X.js";import{a as Pe,o as Fe}from"./format-BU7D3IfE.js";import{d as Ie,n as Le,o as Re,s as ze,t as Be,u as Ve}from"./page-shell-7pLJMOgh.js";import{t as I}from"./centered-state-V15AR_qo.js";import{An as He,At as Ue,Bt as We,Dt as Ge,E as Ke,En as qe,Ft as L,Gt as R,Ht as z,It as Je,Jt as B,Kt as V,Lt as Ye,Mn as Xe,Mt as Ze,Nt as Qe,Ot as $e,Pt as et,Rt as tt,T as nt,Ut as H,Vt as U,Wt as W,Xn as G,Xt as K,dn as rt,fr as q,jn as it,jt as at,kt as ot,qt as J,rr as st,ur as ct,zt as lt}from"./index-CIAFRUw6.js";import{t as ut}from"./markdown-BBDDg-4t.js";import{t as dt}from"./diff-6Tr1DKFm.js";import{t as ft}from"./change-counts-npLATh-3.js";import{n as pt,r as mt}from"./commit-list-0tp9mxng.js";var Y=e(t(),1);function ht(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var gt=ge(`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`}]]),_t=ge(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function vt(){let e=r(),t=o(),n=S(),i=ht({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Ge(e,s,`screen`);return(0,X.jsx)(Ve,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(ze,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,X.jsx)(ce,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ue,{scope:e,repo:s,info:s.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)($e,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function yt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function bt({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=ee(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=S(),f=d({mutationFn:e=>C({name:e},n),onSuccess:async e=>{w(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ze(t,n,e.branch))},onError:e=>w(e.message,{tone:`danger`})}),[p,m]=(0,Y.useState)(``),[h,_]=(0,Y.useState)(``),v=h.trim().toLowerCase(),te=Z(e,c.data?.branches),y=v?te.filter(e=>e.toLowerCase().includes(v)):te;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,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)(se,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(G,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[y.map(e=>{let n=e===t.branch,r=l.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,X.jsx)(Tt,{entry:r}):null]}),r?(0,X.jsx)(yt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,X.jsx)(ie,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),y.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.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-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,X.jsx)(G,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,onChange:e=>m(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||f.isPending,children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,X.jsx)(xt,{}):null]})}function xt(){let e=p({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,X.jsx)(St,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function St({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-xs 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)(Ct,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function Ct({checks:e}){let t=e===`passing`?_e:e===`failing`?ve:ct;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var wt={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Tt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:wt[e.class]})}function Z(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 Et(){let e=c(),t=K(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=e.isError&&e.error instanceof v&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>xe(p),[p]),h=(0,Y.useMemo)(()=>p.some(ut),[p]),g=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:f?(0,X.jsx)(O,{size:16}):(0,X.jsx)(j,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(Se,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h?(0,X.jsx)(Te,{preview:o,onPreviewChange:s}):null,(0,X.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,X.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:1rem] md:flex-row md:items-start`,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-[288px]`,children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(be,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,X.jsx)(dt,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function Dt({repo:e,info:t}){let{sha:n}=re(),r=e.log,i=(0,Y.useMemo)(()=>We(r),[r]);if(n)return(0,X.jsx)(At,{sha:n});let a=Je(e,t),o=a&&a.behind>0?(0,X.jsx)(kt,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(ue,{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-4`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(pt,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:lt(e.when,e.at),children:tt(e.when,e.at)})]})]})]}),(0,X.jsx)(Ot,{source:e.source})]},e.hash))})]},e.label))]})}function Ot({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-xs text-muted-foreground md:flex`;return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"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)(fe,{"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 kt({info:e,tracking:t}){let n=Qe(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(gt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(de,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(at,{checkout:n,returnFocus:i})]})}function At({sha:e}){return(0,X.jsx)(mt,{commit:s(e),sha:e,backTo:K()?`/git`:et,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-9`})}var jt=`Squash-merged branches may show as not landed without GitHub`;function Mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function Nt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Pt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Mt(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=Nt(e.data.branches),u=l>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:L.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(De,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(Ft,{}),u,s.length===0?(0,X.jsx)(Be,{icon:(0,X.jsx)(st,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(It,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,X.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(Vt,{entry:a,onClose:()=>o(null)})]})}function Ft({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),jt,`.`]})}function It({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(zt,{entry:e,finishedAt:t}),(0,X.jsx)(Lt,{entry:e}),(0,X.jsx)(Rt,{entry:e,onDelete:n})]})}function Lt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(Oe,{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)(Bt,{entry:e})]}):null})}function Rt({entry:e,onDelete:t}){let n=S(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>b(e.runId),onSuccess:e=>{w(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>w(e instanceof v&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>w(`Copied ${e.name}`),()=>w(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(_t,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(me,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Me,{children:[(0,X.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(ke,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function zt({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Pe(i),o=e.runStatus?qe(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(ye,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(ft,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(yt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Bt({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Vt({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=d({mutationFn:e=>x({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;w(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:u.repo}),s()},onError:e=>w(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)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(R,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(Xe,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(G,{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)(V,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(z,{"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 Ht({base:e}){let t=g(),n=S(),[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],f=d({mutationFn:e=>x({names:e}),onSuccess:e=>{let t=e.refused.length;w(`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:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),w(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Ut,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:jt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Ut,{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)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(R,{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)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(z,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Ut({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(He,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(it,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function Wt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Gt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function Kt(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function qt(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function Jt(e,t){return e===0?`Reclaim now`:t?`Reclaim ${D(t)} now`:`Reclaim ${e} now`}function Yt(e,t,n){let r=t?D(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function Xt(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function Zt(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function Qt({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${D(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,Kt(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function $t({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?Yt(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(R,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${D(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(U,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(R,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${D(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(U,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(R,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,Gt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep it`}),(0,X.jsx)(z,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function en(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>te(e,t.id),onError:e=>w(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,p]=(0,Y.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>ne(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),w(qt(e.reclaimed.length,t,!!n))},onError:e=>w(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>y(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),w(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),w(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:ee,keep:v}=e.data,b=h.isPending||g.isPending,x=_.filter(e=>e.pastKeep),C=x.filter(e=>!e.reclaimBlocker),T=x.filter(e=>e.reclaimBlocker!==null),E=C.length>0,re=$(C),ie=$(x),O=Jt(C.length,re),ae=Yt(x.length,ie,E),k=ee?D(ee):null,A=Zt(v);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`,k?` · ${k}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[A.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:rt(`worktrees`,` › `)}),A.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:b||!E,title:Xt(E,T.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[12px]`}),O]})]}),T.length>0?(0,X.jsx)(Qt,{blocked:T,discardLabel:ae,disabled:b,onDiscard:()=>s(x)}):null,_.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,X.jsx)(rn,{worktree:e,keep:v,disabled:b,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)($t,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:C.length,cleanBytes:re,reclaimLabel:O,onConfirmClean:()=>{h.mutate({expected:C.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var tn=new Set([`queued`,`running`,`waiting`,`review`]);function nn(e,t){return tn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:Wt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function rn({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=nn(e,t),c=Pe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Fe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Gt(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:a(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),r?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:a(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function an(e){return e===`main`||e===`changes`?`Split`:`Table`}function on({section:e,index:t=!1}){let n=o(),r=K(),[i]=E(),a=an(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(vt,{});if(n.isPending)return(0,X.jsx)(nt,{});if(n.isError)return(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,X.jsx)(sn,{repo:n.data,info:s,section:e}):(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(ie,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function sn({repo:e,info:t,section:n}){let r=an(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Z(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Re,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(a),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(Ke,{}),header:{title:ot(n,t.branch),headerSlot:`repo-header`,subtitle:(0,X.jsx)(cn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,X.jsx)(Dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(Pt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(en,{}),(0,X.jsx)(Ht,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(bt,{repo:e,info:t}):(0,X.jsx)(Et,{})})}function cn({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?` · ${Ye(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)(ln,{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 ln({repo:e,info:t}){let n=Z(e,g().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{on as RepoGitRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as ee}from"./queries-EvENG6TN.js";import{Fn as v,It as te,L as y,R as ne,ct as b,f as x,hi as S,l as C,n as w}from"./toaster-Cer2NOxt.js";import{Z as T}from"./live-protocol-DMhTnCmf.js";import{g as E,h as re}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as D}from"./tasks-table-DGBiE6ux.js";import{A as ie,C as O,E as ae,F as k,J as A,M as oe,X as se,Y as ce,at as le,j as ue,n as de,ot as j,s as fe,u as pe,v as me,x as he}from"./design-icons-CzEoMH9c.js";import{t as ge}from"./createLucideIcon-BHp8sXmF.js";import{n as _e,t as ve}from"./circle-x-7nTlobAF.js";import{_ as ye}from"./nav-row-styles-D5HpOmDZ.js";import{i as be,r as xe,t as Se}from"./git-toolbar-p0Gt04pZ.js";import{t as M}from"./info-DA1x_4bz.js";import{t as Ce}from"./loader-circle-CPBhhDbB.js";import{n as we,r as Te}from"./diff-controls-CY3bqJPO.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-BLHAGMsc.js";import{t as N}from"./button-B7MKxYjT.js";import{i as P,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-BypHPat0.js";import{t as Ne}from"./status-dot-BRzVlF2X.js";import{a as Pe,o as Fe}from"./format-BU7D3IfE.js";import{d as Ie,n as Le,o as Re,s as ze,t as Be,u as Ve}from"./page-shell-7pLJMOgh.js";import{t as I}from"./centered-state-V15AR_qo.js";import{An as He,At as Ue,Bt as We,Dt as Ge,E as Ke,En as qe,Ft as L,Gt as R,Ht as z,It as Je,Jt as B,Kt as V,Lt as Ye,Mn as Xe,Mt as Ze,Nt as Qe,Ot as $e,Pt as et,Rt as tt,T as nt,Ut as H,Vt as U,Wt as W,Xn as G,Xt as K,dn as rt,fr as q,jn as it,jt as at,kt as ot,qt as J,rr as st,ur as ct,zt as lt}from"./index-BSZD2aai.js";import{t as ut}from"./markdown-BBDDg-4t.js";import{t as dt}from"./diff-ZGlCIC2o.js";import{t as ft}from"./change-counts-npLATh-3.js";import{n as pt,r as mt}from"./commit-list-Ogvgv0V9.js";var Y=e(t(),1);function ht(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var gt=ge(`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`}]]),_t=ge(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function vt(){let e=r(),t=o(),n=S(),i=ht({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Ge(e,s,`screen`);return(0,X.jsx)(Ve,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(ze,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,X.jsx)(ce,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ue,{scope:e,repo:s,info:s.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)($e,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function yt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function bt({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=ee(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=S(),f=d({mutationFn:e=>C({name:e},n),onSuccess:async e=>{w(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ze(t,n,e.branch))},onError:e=>w(e.message,{tone:`danger`})}),[p,m]=(0,Y.useState)(``),[h,_]=(0,Y.useState)(``),v=h.trim().toLowerCase(),te=Z(e,c.data?.branches),y=v?te.filter(e=>e.toLowerCase().includes(v)):te;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,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)(se,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(G,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[y.map(e=>{let n=e===t.branch,r=l.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,X.jsx)(Tt,{entry:r}):null]}),r?(0,X.jsx)(yt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,X.jsx)(ie,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),y.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.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-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,X.jsx)(G,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,onChange:e=>m(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||f.isPending,children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,X.jsx)(xt,{}):null]})}function xt(){let e=p({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,X.jsx)(St,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function St({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-xs 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)(Ct,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function Ct({checks:e}){let t=e===`passing`?_e:e===`failing`?ve:ct;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var wt={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Tt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:wt[e.class]})}function Z(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 Et(){let e=c(),t=K(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=e.isError&&e.error instanceof v&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>xe(p),[p]),h=(0,Y.useMemo)(()=>p.some(ut),[p]),g=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:f?(0,X.jsx)(O,{size:16}):(0,X.jsx)(j,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(Se,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h?(0,X.jsx)(Te,{preview:o,onPreviewChange:s}):null,(0,X.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,X.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:1rem] md:flex-row md:items-start`,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-[288px]`,children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(be,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,X.jsx)(dt,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function Dt({repo:e,info:t}){let{sha:n}=re(),r=e.log,i=(0,Y.useMemo)(()=>We(r),[r]);if(n)return(0,X.jsx)(At,{sha:n});let a=Je(e,t),o=a&&a.behind>0?(0,X.jsx)(kt,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(ue,{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-4`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(pt,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:lt(e.when,e.at),children:tt(e.when,e.at)})]})]})]}),(0,X.jsx)(Ot,{source:e.source})]},e.hash))})]},e.label))]})}function Ot({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-xs text-muted-foreground md:flex`;return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"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)(fe,{"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 kt({info:e,tracking:t}){let n=Qe(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(gt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(de,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(at,{checkout:n,returnFocus:i})]})}function At({sha:e}){return(0,X.jsx)(mt,{commit:s(e),sha:e,backTo:K()?`/git`:et,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-9`})}var jt=`Squash-merged branches may show as not landed without GitHub`;function Mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function Nt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Pt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Mt(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=Nt(e.data.branches),u=l>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:L.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(De,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(Ft,{}),u,s.length===0?(0,X.jsx)(Be,{icon:(0,X.jsx)(st,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(It,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,X.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(Vt,{entry:a,onClose:()=>o(null)})]})}function Ft({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),jt,`.`]})}function It({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(zt,{entry:e,finishedAt:t}),(0,X.jsx)(Lt,{entry:e}),(0,X.jsx)(Rt,{entry:e,onDelete:n})]})}function Lt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(Oe,{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)(Bt,{entry:e})]}):null})}function Rt({entry:e,onDelete:t}){let n=S(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>b(e.runId),onSuccess:e=>{w(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>w(e instanceof v&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>w(`Copied ${e.name}`),()=>w(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(_t,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(me,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Me,{children:[(0,X.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(ke,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function zt({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Pe(i),o=e.runStatus?qe(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(ye,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(ft,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(yt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Bt({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Vt({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=d({mutationFn:e=>x({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;w(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:u.repo}),s()},onError:e=>w(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)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(R,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(Xe,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(G,{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)(V,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(z,{"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 Ht({base:e}){let t=g(),n=S(),[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],f=d({mutationFn:e=>x({names:e}),onSuccess:e=>{let t=e.refused.length;w(`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:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),w(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Ut,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:jt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Ut,{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)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(R,{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)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(z,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Ut({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(He,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(it,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function Wt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Gt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function Kt(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function qt(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function Jt(e,t){return e===0?`Reclaim now`:t?`Reclaim ${D(t)} now`:`Reclaim ${e} now`}function Yt(e,t,n){let r=t?D(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function Xt(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function Zt(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function Qt({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${D(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,Kt(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function $t({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?Yt(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(R,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${D(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(U,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(R,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${D(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(U,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(R,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,Gt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep it`}),(0,X.jsx)(z,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function en(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>te(e,t.id),onError:e=>w(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,p]=(0,Y.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>ne(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),w(qt(e.reclaimed.length,t,!!n))},onError:e=>w(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>y(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),w(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),w(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:ee,keep:v}=e.data,b=h.isPending||g.isPending,x=_.filter(e=>e.pastKeep),C=x.filter(e=>!e.reclaimBlocker),T=x.filter(e=>e.reclaimBlocker!==null),E=C.length>0,re=$(C),ie=$(x),O=Jt(C.length,re),ae=Yt(x.length,ie,E),k=ee?D(ee):null,A=Zt(v);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`,k?` · ${k}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[A.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:rt(`worktrees`,` › `)}),A.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:b||!E,title:Xt(E,T.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[12px]`}),O]})]}),T.length>0?(0,X.jsx)(Qt,{blocked:T,discardLabel:ae,disabled:b,onDiscard:()=>s(x)}):null,_.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,X.jsx)(rn,{worktree:e,keep:v,disabled:b,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)($t,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:C.length,cleanBytes:re,reclaimLabel:O,onConfirmClean:()=>{h.mutate({expected:C.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var tn=new Set([`queued`,`running`,`waiting`,`review`]);function nn(e,t){return tn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:Wt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function rn({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=nn(e,t),c=Pe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Fe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Gt(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:a(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),r?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:a(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function an(e){return e===`main`||e===`changes`?`Split`:`Table`}function on({section:e,index:t=!1}){let n=o(),r=K(),[i]=E(),a=an(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(vt,{});if(n.isPending)return(0,X.jsx)(nt,{});if(n.isError)return(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,X.jsx)(sn,{repo:n.data,info:s,section:e}):(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(ie,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function sn({repo:e,info:t,section:n}){let r=an(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Z(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Re,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(a),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(Ke,{}),header:{title:ot(n,t.branch),headerSlot:`repo-header`,subtitle:(0,X.jsx)(cn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,X.jsx)(Dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(Pt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(en,{}),(0,X.jsx)(Ht,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(bt,{repo:e,info:t}):(0,X.jsx)(Et,{})})}function cn({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?` · ${Ye(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)(ln,{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 ln({repo:e,info:t}){let n=Z(e,g().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{on as RepoGitRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-EvENG6TN.js";import{Fn as a,nt as o}from"./toaster-Cer2NOxt.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-EvENG6TN.js";import{Fn as a,nt as o}from"./toaster-Cer2NOxt.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-CBme1fo_.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{_ as S,g as C,v as w}from"./index-BSZD2aai.js";import{r as T}from"./html-report-BX3msvci.js";import{t as E}from"./html-report-frame-uuqkBC0u.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=w(C,!0),p=w(S,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function L(e){return e!==null&&(!T(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 u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),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 c=n.data;return c.type===`file`?o&&!T(c.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)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.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)(y,{path:c.path,text:c.content??``})}):(0,O.jsx)(E,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(v,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(b,{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)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
|