@hearsay-tools/squawk 0.19.0-dev.9308 → 0.19.0-dev.9310
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/server.d.ts +58 -58
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-B8X63Wvk.js → accounts-section-DJ_M9Wt5.js} +1 -1
- package/web/dist/assets/{activity-motion-BX7w9uwa.js → activity-motion-CeNmzIIs.js} +1 -1
- package/web/dist/assets/{activity-route-D6OhCzkJ.js → activity-route-CYn-qQq2.js} +1 -1
- package/web/dist/assets/{agent-config-section-RluVjTDv.js → agent-config-section-C89KQhYI.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-Bl67Iurg.js → agent-defaults-section-CsIHvRnd.js} +1 -1
- package/web/dist/assets/{appearance-ChGEz79A.js → appearance-xdlVXLZN.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-DtMYAmPH.js → archive-on-merge-field-vYZF1Wln.js} +1 -1
- package/web/dist/assets/{ask-card-Bk87kXMi.js → ask-card-CTkwopg6.js} +1 -1
- package/web/dist/assets/{automations-route-DpEqMGRx.js → automations-route-DhkRC_XY.js} +1 -1
- package/web/dist/assets/{commit-list-DGLW8f7_.js → commit-list-B3px5blI.js} +1 -1
- package/web/dist/assets/{diff-BQIvq2Ar.js → diff-4OKh2896.js} +2 -2
- package/web/dist/assets/{diff-controls-CcYIa7pJ.js → diff-controls-CQuYWKK_.js} +1 -1
- package/web/dist/assets/{diff-view-BSYPKJkF.js → diff-view-BZi9U7Rt.js} +6 -6
- package/web/dist/assets/{discard-changes-dialog-CEeuND_i.js → discard-changes-dialog-DRLVQrRX.js} +1 -1
- package/web/dist/assets/{file-preview-BPSpXZ6G.js → file-preview-DwDnEbjs.js} +1 -1
- package/web/dist/assets/{git-toolbar-D3O7S7vw.js → git-toolbar-CnbRMfPP.js} +1 -1
- package/web/dist/assets/{github-b6pU4RVM.js → github-BFdjku0b.js} +1 -1
- package/web/dist/assets/{global-activity-route-sTvejVUG.js → global-activity-route-CYV5tNqR.js} +1 -1
- package/web/dist/assets/{index-CIyGnGfm.js → index-BlqAIDwd.js} +4 -4
- package/web/dist/assets/index-DrL3MqE4.css +1 -0
- package/web/dist/assets/{markdown-DnBvknF9.js → markdown-BA-2Hv-H.js} +1 -1
- package/web/dist/assets/{option-select-HC8juekO.js → option-select-Bz-6fs6-.js} +1 -1
- package/web/dist/assets/{preferences-section-DuV8JFqQ.js → preferences-section-CGPTMvPb.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-E8n0RgYL.js → preview-pane-connected-Km1_yTQu.js} +1 -1
- package/web/dist/assets/{project-location-bPiIsStE.js → project-location-DgWnz24i.js} +1 -1
- package/web/dist/assets/{projects-section-0eQ2TVqw.js → projects-section-C5Lm9E1X.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-CVNw5v0w.js → prompt-templates-section-BSqqmMzn.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-tNcad9fA.js → remote-settings-notice-CPMHtuyk.js} +1 -1
- package/web/dist/assets/{repo-git-DA66978k.js → repo-git-Dr-LPs33.js} +1 -1
- package/web/dist/assets/{report-reader-DHB5teJQ.js → report-reader-BXPtT3jw.js} +1 -1
- package/web/dist/assets/{reports-Oxg0v5bR.js → reports-BztUxdF1.js} +1 -1
- package/web/dist/assets/{resources-section-BAj-A1Ou.js → resources-section-CKxYxZlu.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-agZQaBcF.js → review-notes-drafts-B7QtBlMK.js} +1 -1
- package/web/dist/assets/{review-panel-858YvYOc.js → review-panel-WjhjBT-O.js} +1 -1
- package/web/dist/assets/review-strip-lK-KV-Bh.js +1 -0
- package/web/dist/assets/{run-diff-BDFptONx.js → run-diff-BzL5y9aa.js} +1 -1
- package/web/dist/assets/{run-header-CEIKmo_0.js → run-header-D_I9i1FK.js} +2 -2
- package/web/dist/assets/{select-C4s2-ztq.js → select-C3I9ZinR.js} +1 -1
- package/web/dist/assets/{session-context-section-CihFGtUL.js → session-context-section-Bko3JFzB.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-B-LnnccN.js → settings-agent-picker-CA5KEY0b.js} +1 -1
- package/web/dist/assets/{settings-save-bar-l5vO-fT3.js → settings-save-bar-DXlarWtq.js} +1 -1
- package/web/dist/assets/{settings-shell-B_o8TQYi.js → settings-shell-BvkTyfyu.js} +1 -1
- package/web/dist/assets/{sidebar-section-BTjJD2PF.js → sidebar-section-BWGMQzwD.js} +1 -1
- package/web/dist/assets/{skills-C-PLlLf0.js → skills-khuz63Be.js} +1 -1
- package/web/dist/assets/task-changes-BZiv3oW9.js +5 -0
- package/web/dist/assets/task-commits-C319iu69.js +1 -0
- package/web/dist/assets/{task-file-scope-npOd7AhM.js → task-file-scope-CVzNnBlI.js} +1 -1
- package/web/dist/assets/{task-files--54CdvAw.js → task-files-BwWE5iwD.js} +1 -1
- package/web/dist/assets/{task-github-item-QzP9IPGg.js → task-github-item--JaIohoc.js} +1 -1
- package/web/dist/assets/{task-thread-BgxYbzJU.js → task-thread-D_Yc4SUV.js} +1 -1
- package/web/dist/assets/{thread-state-CfmY7F3h.js → thread-state-DAlHXYiH.js} +1 -1
- package/web/dist/assets/{unified-diff-DdU6bcRV.js → unified-diff-C46MIUZz.js} +1 -1
- package/web/dist/assets/{use-finish-run-Bv7_Ezz_.js → use-finish-run-0YNEOl4g.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-dHej93ZU.js → use-hand-to-agent-state-CkqtX66f.js} +1 -1
- package/web/dist/assets/use-path-bases-Dpl3ksiL.js +1 -0
- package/web/dist/assets/{workflows-CeUWNdYH.js → workflows-D5gUtDwQ.js} +1 -1
- package/web/dist/assets/{workspace-tools-BwMECWWr.js → workspace-tools-CCQ42oji.js} +1 -1
- package/web/dist/assets/{worktrees-section-CytHZvmT.js → worktrees-section-B_8wVdPI.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BToDejlf.css +0 -1
- package/web/dist/assets/review-strip-tiqQt7qS.js +0 -1
- package/web/dist/assets/task-changes-BZ7Hlj9q.js +0 -5
- package/web/dist/assets/task-commits-Jf35_1k0.js +0 -1
- package/web/dist/assets/use-path-bases-B6yYqrmU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{it as r,sn as i}from"./queries-CPNrCEon.js";import{a,fn as o,ha as s}from"./project-scope-context-_6sNMsAf.js";import{t as c}from"./switch-B9OfOEzC.js";import{gt as l,ht as u}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{it as r,sn as i}from"./queries-CPNrCEon.js";import{a,fn as o,ha as s}from"./project-scope-context-_6sNMsAf.js";import{t as c}from"./switch-B9OfOEzC.js";import{gt as l,ht as u}from"./index-BlqAIDwd.js";import{n as d,t as f}from"./save-cue-CpHgT93o.js";import{n as p}from"./archive-on-merge-field-vYZF1Wln.js";var m=e(t(),1),h=n();function g(){let e=s(),t=r(),[n,p]=m.useState(!1),[g,_]=m.useState(l),v=d(),y=t.data;m.useEffect(()=>{y!==void 0&&p(u(y.notifications).enabled)},[y]);let b=m.useCallback(t=>{p(t),o({notifications:{enabled:t}}).then(t=>{e.setQueryData(i.uiState,t),v.flash()}).catch(t=>{a(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:i.uiState})})},[e,v.flash]),x=m.useCallback(e=>{if(!e){b(!1);return}if(l()!=="default"){b(!0);return}b(!0),Notification.requestPermission().then(e=>_(e)).catch(()=>_(l()))},[b]),S=g===`unsupported`;return(0,h.jsxs)(`section`,{"data-slot":`notifications-section`,className:`settings-field flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,h.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,h.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default. `,(0,h.jsx)(f,{saved:v.saved})]})]}),(0,h.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:S,onCheckedChange:x})]}),S?null:(0,h.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":g,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,g===`granted`?`Allowed`:g===`denied`?`Blocked`:`Not requested`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),S?(0,h.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!S&&n&&g===`denied`?(0,h.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,h.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})}function _(){return(0,h.jsxs)(`div`,{"data-slot":`preferences-section`,className:`flex w-full flex-col gap-7`,children:[(0,h.jsx)(g,{}),(0,h.jsx)(p,{})]})}export{_ as PreferencesSection};
|
package/web/dist/assets/{preview-pane-connected-E8n0RgYL.js → preview-pane-connected-Km1_yTQu.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{d as r}from"./host-context-KsSKxKbI.js";import{a as i,dr as a,ji as o,lr as s,ur as c}from"./project-scope-context-_6sNMsAf.js";import{o as l}from"./dist-CCX8mhHc.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{t as f}from"./check-OP-CVgZG.js";import{t as p}from"./chevron-down-CHGyCDBH.js";import{n as m,t as h}from"./circle-x-7nTlobAF.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{t as y}from"./loader-circle-CPBhhDbB.js";import{n as ee,t as te}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-CTbToGmi.js";import{n as S,r as C,t as ne}from"./preview-7NPVVq1D.js";import{t as w}from"./square-terminal-B6RYYieR.js";import{t as T}from"./button-BV_AiLj2.js";import{a as E,c as re,i as D,l as O,p as k,r as A,s as ie,t as j}from"./dropdown-menu-NJZfnQCU.js";import{s as ae}from"./project-router-l_pJCK5X.js";import{t as M}from"./status-dot-Dvy-rnDJ.js";import{$n as oe,Qn as se,Sr as N,Xn as ce,Zn as le,_ as ue,d as de,f as P,fr as fe,hr as pe,p as me,s as he,u as ge,v as _e,wr as ve,xr as ye}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{d as r}from"./host-context-KsSKxKbI.js";import{a as i,dr as a,ji as o,lr as s,ur as c}from"./project-scope-context-_6sNMsAf.js";import{o as l}from"./dist-CCX8mhHc.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{t as f}from"./check-OP-CVgZG.js";import{t as p}from"./chevron-down-CHGyCDBH.js";import{n as m,t as h}from"./circle-x-7nTlobAF.js";import{n as g,t as _}from"./smartphone-Lr8Ug2z_.js";import{t as v}from"./info-DA1x_4bz.js";import{t as y}from"./loader-circle-CPBhhDbB.js";import{n as ee,t as te}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-CTbToGmi.js";import{n as S,r as C,t as ne}from"./preview-7NPVVq1D.js";import{t as w}from"./square-terminal-B6RYYieR.js";import{t as T}from"./button-BV_AiLj2.js";import{a as E,c as re,i as D,l as O,p as k,r as A,s as ie,t as j}from"./dropdown-menu-NJZfnQCU.js";import{s as ae}from"./project-router-l_pJCK5X.js";import{t as M}from"./status-dot-Dvy-rnDJ.js";import{$n as oe,Qn as se,Sr as N,Xn as ce,Zn as le,_ as ue,d as de,f as P,fr as fe,hr as pe,p as me,s as he,u as ge,v as _e,wr as ve,xr as ye}from"./index-BlqAIDwd.js";import{n as be,o as xe}from"./thread-state-DAlHXYiH.js";var F=u(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Se=u(`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=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),I=u(`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`}]]),L=u(`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`}]]),we=u(`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`}]]),R=u(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),z=u(`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`}]]),Te=u(`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`}]]),Ee=u(`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`}]]),B=u(`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`}]]),V=u(`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`}]]),H=u(`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`}]]),U=u(`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`}]]),W=u(`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`}]]),G=u(`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`}]]),K=u(`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`}]]),q=u(`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`}]]),J=u(`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=u(`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`}]]),Y=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){if(r())return t.onTransport(`blocked`),{send(){},close(){}};let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,i=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,a=null,l,u=!1,d=!1,f=0,p=0,m=()=>typeof document>`u`||s(),h=()=>{if(u||!m())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(i());n.binaryType=`blob`,a=n,n.addEventListener(`open`,()=>{n===a&&(d=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==a)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=o.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(p=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==a||u)return;if(a=null,!d){if(f+=1,f>=2){u=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,f),l=setTimeout(h,Oe);return}if(p>=5){u=!0,t.onTransport(`closed`);return}let e=ke[Math.min(p,ke.length-1)];p+=1,t.onTransport(`reconnecting`,p),l=setTimeout(h,e)})},g=c(e=>{if(!u)if(e)a||h();else{clearTimeout(l),l=void 0;let e=a;a=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),h(),{send(e){a?.readyState===Ae&&a.send(JSON.stringify(e))},close(){u=!0,g(),clearTimeout(l),l=void 0;let e=a;a=null,e?.close()}}}var X=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,X.jsx)(se,{children:(0,X.jsxs)(ce,{children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:l(`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,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,X.jsx)(le,{children:`Experimental`})]})}):e?(0,X.jsx)(se,{children:(0,X.jsxs)(ce,{children:[(0,X.jsx)(oe,{asChild:!0,children:(0,X.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:l(`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,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(le,{children:`Experimental`})]})}):(0,X.jsxs)(`span`,{"data-slot":`preview-experimental`,className:l(`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,X.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:r}){let i=e.replace(/\s+$/,``).split(`
|
|
2
2
|
`);return(0,X.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:l(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,r),children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${i.length} ${i.length===1?`line`:`lines`} · ${t}`]}),(0,X.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,X.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,X.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(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=Pe.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.`}:Ie(n):Ie(`http://${n}`)}function Ie(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 Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,X.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,X.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,X.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,X.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,X.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,X.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,X.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,X.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,X.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,X.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,X.jsx)(nt,{state:e,actions:t});case`loading`:return(0,X.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,X.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,X.jsx)(ot,{actions:t});case`taken-over`:return(0,X.jsx)(ct,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,X.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,X.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,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Be({server:e}){return(0,X.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(w,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:`Runs ${P(e.command)} in this task's worktree, on the host.`})]})}function Ve({copy:e,command:t,label:n}){return(0,X.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,X.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,X.jsx)(`span`,{children:n}),(0,X.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,X.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]}),(0,X.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function He({server:e,status:t}){return(0,X.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,X.jsx)(M,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,X.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,X.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,X.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,X.jsx)(`span`,{children:`cwd`}),(0,X.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,X.jsx)(`div`,{className:`mt-2.5`,children:(0,X.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(I,{}),title:`This host has no browser yet`,children:[(0,X.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,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:t.download,children:[(0,X.jsx)(I,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,X.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,Y.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,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(I,{}),title:`Downloading Chromium`,children:[(0,X.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.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,X.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:`${We(e.received)} of ${We(e.total)} MB · ${r}%`}),o===void 0?null:(0,X.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(q,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,X.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,X.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.download,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(G,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,X.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,X.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,X.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({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,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(h,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,X.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,X.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,X.jsxs)(T,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(e){let[t,n]=(0,Y.useState)(()=>Date.now());return(0,Y.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ze({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:r?(0,X.jsx)(J,{className:`text-pending-strong`}):(0,X.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,X.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,X.jsx)(He,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(q,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,X.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,X.jsx)($,{children:(0,X.jsx)(T,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,Y.useState)(()=>Date.now());(0,Y.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Ye-(r-a)/1e3));return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,X.jsx)(Q,{children:`Squawk ran ${P(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,X.jsx)(y,{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,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,X.jsx)(Ne,{text:e.logTail.join(`
|
|
3
3
|
`),source:P(n.command),onCopy:t.copy}):null,(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(z,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,X.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,X.jsx)(Ne,{text:e.logTail,source:P(n.command),onCopy:t.copy}),(0,X.jsxs)($,{children:[(0,X.jsx)(T,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,X.jsx)(T,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(h,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,X.jsx)(Q,{children:`${P(n.command)} stopped.`}),(0,X.jsx)(Ne,{text:e.logTail,source:P(n.command),onCopy:t.copy}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,X.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(te,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,X.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 ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,X.jsx)($,{children:(0,X.jsxs)(T,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,X.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),r=t?Le(t):`the page`;return(0,X.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,X.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 ${r}`,active:`Opening ${r}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let r=t<n,i=t===n;return(0,X.jsxs)(`li`,{"aria-current":i?`step`:void 0,className:l(`flex items-center gap-3`,i?`font-semibold text-foreground`:r?`text-foreground`:`text-soft-foreground`),children:[r?(0,X.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):i?(0,X.jsx)(y,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,X.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),r?e.done:i?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(we,{}),title:`This task's worktree is gone`,children:[(0,X.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,X.jsx)(xe,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,X.jsx)($,{children:(0,X.jsx)(T,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({actions:e}){return(0,X.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,X.jsx)(`div`,{children:(0,X.jsx)(Me,{})}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,X.jsx)(H,{})}),(0,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,X.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,X.jsxs)($,{children:[(0,X.jsx)(T,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,X.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(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 ct({state:e,actions:t}){let n=st(e.by);return(0,X.jsxs)(Z,{state:e.stage,icon:(0,X.jsx)(V,{}),title:`Preview is open somewhere else`,children:[(0,X.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,X.jsxs)($,{children:[(0,X.jsxs)(T,{variant:`contrast`,onClick:t.useHere,children:[(0,X.jsx)(I,{"aria-hidden":`true`}),`Use it here`]}),(0,X.jsx)(T,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){return(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,X.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,X.jsx)(T,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,X.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,X.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,X.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,X.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,X.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,X.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,X.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,X.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,X.jsx)(M,{tone:`success`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,X.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,X.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,X.jsx)(`ul`,{children:e.map(e=>{let r=ge(e,t),i=me(r);return(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,X.jsx)(M,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>n(e.port),children:de(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,X.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(v,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.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 dt({dialog:e,onResult:t}){let[n,r]=(0,Y.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,Y.useRef)(null),o=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,Y.useRef)(t);s.current=t,(0,Y.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,X.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,X.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,X.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,X.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,X.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,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,X.jsx)(T,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,X.jsx)(T,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(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 bt=[`left`,`middle`,`right`];function xt(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=vt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=ft)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=pt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[xt(`mouseMoved`,t,a,{button:`none`,buttons:0}),xt(`mousePressed`,t,a,{button:`left`,buttons:1}),xt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[xt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[xt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[xt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt: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:_t(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:_t(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:_t(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,Y.useRef)(null),i=(0,Y.useRef)(yt({left:0,top:0},e)),a=(0,Y.useRef)(e);a.current=e;let o=(0,Y.useRef)(t);o.current=t;let s=(0,Y.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,Y.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,Y.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,Y.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,Y.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,X.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:r,onSize:i,renderInput:a,children:o}){let c=(0,Y.useRef)(0),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(null),m=(0,Y.useRef)(i);m.current=i,(0,Y.useImperativeHandle)(e,()=>({async draw(e){let t=++c.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!s()))try{let i=await Nt(e);try{if(t!==c.current||!s()||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,Y.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,X.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:l(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,X.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:r},className:l(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,X.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),a?.({canvas:d.current,scale:g,viewport:h})]}):null,o]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:_},{w:820,h:1180,icon:K},{w:1440,h:900,icon:ee}],Ht=`shrink-0`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,Y.useState)(()=>Date.now());return(0,Y.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,X.jsx)(M,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,X.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,X.jsx)(M,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem]`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,X.jsx)(M,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,X.jsx)(C,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:r}),e?(0,X.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,X.jsx)(M,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,Y.useRef)(null),a=e.urlInputRef??i,o=(0,Y.useRef)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),f=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,X.jsx)(F,{"aria-hidden":`true`})}),p=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,X.jsx)(d,{"aria-hidden":`true`})}),m=(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,X.jsx)(W,{"aria-hidden":`true`})}),h=e.onSession?(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1`,onClick:e.onSession,children:[(0,X.jsx)(ve,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,X.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,X.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,X.jsx)($t,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:u}),{agentListed:v}=Xt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,te={back:f,forward:p,reload:m,address:_,more:(0,X.jsx)(an,{props:e,compact:t}),session:h,progress:g};return t?(0,X.jsx)(on,{props:e,elements:te}):(0,X.jsx)(sn,{props:e,elements:te,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(qt,{current:i,agentShown:o})}),(0,X.jsxs)(A,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,X.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=me(ge(t,e.serverStates));return(0,X.jsxs)(D,{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,X.jsx)(M,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,X.jsx)(O,{}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,X.jsx)(g,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:t,draft:n,setDraft:r,focused:i,setFocused:a}){let{url:o,adopted:s}=e;return(0,X.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,X.jsx)(g,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,X.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??(i?o:Le(o)),title:o||void 0,className:l(`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`,s?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;a(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{a(!1),r(null)},onChange:e=>r(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??o),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),s&&!i?(0,X.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,X.jsx)(Te,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,X.jsx)(B,{"aria-hidden":`true`}):(0,X.jsx)(ee,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:l(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,X.jsxs)(A,{align:`start`,className:`min-w-56`,children:[(0,X.jsxs)(D,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,X.jsx)(B,{"aria-hidden":`true`}),`Fit`,(0,X.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,X.jsx)(f,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,X.jsxs)(D,{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,X.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,X.jsx)(f,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,X.jsx)(ie,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,X.jsx)(re,{value:e.value,"data-quality":e.value,className:l(`items-start`,n&&`min-h-11`),children:(0,X.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsxs)(T,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,X.jsx)(R,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Rt(t)}),(0,X.jsx)(p,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,X.jsxs)(A,{align:`start`,className:`w-64`,children:[(0,X.jsx)(E,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,X.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,X.jsx)(Kt,{stats:e,shrunk:n}):t?(0,X.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,X.jsx)(M,{tone:t.tone,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function an({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,X.jsxs)(j,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,X.jsx)(ye,{"aria-hidden":`true`})})}),(0,X.jsxs)(A,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,X.jsx)(E,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(n)}):null,(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,X.jsx)(U,{"aria-hidden":`true`}),`Reload without cache`]}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,X.jsx)(pe,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{}),o?(0,X.jsxs)(D,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,X.jsx)(Ee,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,X.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,X.jsxs)(D,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{}),(0,X.jsx)(E,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,X.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,X.jsx)(O,{}),(0,X.jsxs)(D,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,X.jsx)(fe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,X.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,X.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,X.jsx)(M,{tone:`success`,"aria-hidden":`true`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher: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,X.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,X.jsx)(Qt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,X.jsx)(en,{props:e}),(0,X.jsx)(nn,{props:e}),(0,X.jsx)(rn,{stats:s,status:c,crowded:r}),o?(0,X.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,X.jsx)(T,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,X.jsx)(fe,{"aria-hidden":`true`})}),h]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,X.jsx)(ze,{...n,actions:o})}case`empty`:return(0,X.jsx)(ut,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,Y.useState)(un);return(0,Y.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>i(`Copied`),()=>i(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:o,onClose:c}){let l=dn(),u=(0,Y.useRef)(l);u.current=l;let d=a(),f=(0,Y.useRef)(crypto.randomUUID()),p=(0,Y.useRef)(!1),m=ae(),h=_e(ue,!1),[g,_]=(0,Y.useState)(0),[v,y]=(0,Y.useState)({state:`connecting`,attempt:0}),[ee,te]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(void 0),[S,C]=(0,Y.useState)(void 0),[ne,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(void 0),[re,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(void 0),[A,ie]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(void 0),[N,ce]=(0,Y.useState)(void 0),[le,de]=(0,Y.useState)(void 0),[P,fe]=(0,Y.useState)(`fit`),[pe,me]=(0,Y.useState)(zt),[he,ge]=(0,Y.useState)(null),[ve,ye]=(0,Y.useState)(void 0),[be,xe]=(0,Y.useState)(0),F=(0,Y.useRef)(void 0),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null),I=(0,Y.useRef)(void 0),L=(0,Y.useRef)(void 0),we=(0,Y.useRef)(pe);we.current=pe;let R=(0,Y.useRef)({port:T,stage:S,agent:re});R.current={port:T,stage:S,agent:re};let z=(0,Y.useRef)([]),Te=(0,Y.useRef)(void 0),Ee=(0,Y.useRef)(!1),B=(0,Y.useRef)(!1),V=(0,Y.useCallback)(e=>{B.current&&F.current?.send(e)},[]),H=(0,Y.useRef)([]),U=(0,Y.useCallback)(e=>{B.current?F.current?.send(e):H.current.push(e)},[]);(0,Y.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!s())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,M(!0)),(Se.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`)&&xe(e=>e+1),L.current!==void 0&&hn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return w(e.url);case`cursor`:return se(e.cursor);case`dialog`:return ce(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`:x(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`){te(!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)}}}),F.current=t,()=>{B.current=!1,H.current=[],t?.close(),F.current===t&&(F.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&b===void 0,G=h||P===`fit`?he:P;(0,Y.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,be,V]),(0,Y.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,Y.useEffect)(()=>{if(!K){de(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=mn);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}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[K]),(0,Y.useEffect)(()=>(o?.(K),()=>o?.(!1)),[K,o]),(0,Y.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,Y.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,ie(!0),C(void 0),x(void 0),ye(void 0),w(t),E(`port`in e?e.port:void 0),D(`agent`in e),k(yn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),J=(0,Y.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,q]),De=(0,Y.useCallback)(()=>q({agent:!0},``),[q]);(0,Y.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;De();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?J(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||J(n.port,n.run===!0))},[n]);let Oe=!A&&!b&&v.state!==`blocked`,ke=vn(n,t);(0,Y.useEffect)(()=>{Oe&&!ke&&Ce.current?.focus()},[Oe,ke]);let Ae=e=>{let n=Fe(e,t);if(n.kind===`error`)return ye(n.message);if(n.kind===`server`)return J(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,E(void 0),k({url:n.url}),ye(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},X=(0,Y.useCallback)(e=>{we.current=e,me(e),Bt(e),V({t:`quality`,quality:e})},[V]),Me=()=>{p.current=!1,x(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:b,stage:S,url:ne,port:T,agent:re,hasFrame:j,cursor:oe,dialog:N,setDialog:ce,stats:le,viewport:P,setViewport:fe,quality:pe,chooseQuality:X,setStageSize:ge,addressError:ve,stageHandle:Se,urlInput:Ce,send:V,connected:W,streaming:K,openServer:J,openAgent:De,empty:Oe,navigate:Ae,reconnect:Me,actions:(0,Y.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):i(`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:c,useHere:Me,copy:gn}),[V,U,c])}}function xn(e){return(0,X.jsx)(S,{onClose:e.onClose,children:(0,X.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:te,addressError:b,urlInput:x,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:E,actions:re}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:A,dim:ie}=cn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),j=ln(A,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:re});return(0,X.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,X.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:Sn(l,u,d!==void 0,f),urlInputRef:x,onSession:a,onNavigate:E,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:te,onCopyUrl:()=>gn(p),onStop:re.stop,onClose:o}),b?(0,X.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:b}):null,(0,X.jsx)(Tn,{transportState:s,overlay:j,dim:ie,lost:k})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,X.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,X.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,X.jsx)(lt,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,X.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,X.jsx)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=ne(e);return(0,Y.useMemo)(()=>{let e=new Map;for(let n of be(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=he(e.run.id);return(0,X.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{Rt as t,U as n,rt as r,zn as i}from"./queries-CPNrCEon.js";import{Rt as a,a as o}from"./project-scope-context-_6sNMsAf.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-D07DgRwh.js";import{s as u}from"./project-router-l_pJCK5X.js";import{Rn as d}from"./index-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{Rt as t,U as n,rt as r,zn as i}from"./queries-CPNrCEon.js";import{Rt as a,a as o}from"./project-scope-context-_6sNMsAf.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-D07DgRwh.js";import{s as u}from"./project-router-l_pJCK5X.js";import{Rn as d}from"./index-BlqAIDwd.js";import{n as f}from"./settings-field-AyinSFR_.js";var p=e();function m(){let e=u(),t=n().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function h(e){navigator.clipboard.writeText(e).then(()=>o(`Project folder copied`)).catch(()=>o(e))}function g(){let e=m(),t=r().data?.homeDir??null;return e===null?null:(0,p.jsx)(f,{wide:!0,title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,p.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,p.jsx)(d,{"data-slot":`project-location-path`,value:e,bases:{home:t,root:null},wrap:!0,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] text-foreground`}),(0,p.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>h(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,p.jsx)(s,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,p.jsx)(_,{root:e})]})]})})}function _({root:e}){let n=t(),r=i({mutationFn:e=>a(e),onError:e=>o(e.message,{tone:`danger`})}),s=(n.data?.targets??[]).filter(e=>c(e.id)===void 0).map(e=>({target:e}));return s.length===0?null:(0,p.jsx)(l,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:r.isPending,choices:s,onPick:e=>r.mutate(e,{onSuccess:()=>o(`Opening the project folder in ${s.find(t=>t.target.id===e)?.target.label??e}`)})})}export{m as n,g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{U as i,Y as a,ot as o,rt as s,sn as c,st as l,tt as u,zn as d}from"./queries-CPNrCEon.js";import{a as f,dn as p,ha as m}from"./project-scope-context-_6sNMsAf.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as ee}from"./popover-BQolmvDR.js";import{t as S}from"./centered-state-N8vWM_Hw.js";import{$t as C,Rn as w,an as te,en as T,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-CIyGnGfm.js";import{t as M}from"./option-select-HC8juekO.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-B6yYqrmU.js";import{r as R}from"./settings-save-bar-l5vO-fT3.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=a();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{f(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>f(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:s().data?.homeDir??null,root:null};return(0,H.jsx)(C,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(te,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.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.`,e?(0,H.jsx)(w,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(T,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=s(),t=i();return e.isPending||t.isPending?(0,H.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,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{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`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,footer:o,refreshProjects:s=!1}){let l=m(),u=d({mutationFn:t=>p(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{l.setQueryData(c.config,t),e===`browseRoot`?l.invalidateQueries({queryKey:c.fsBrowseRoot}):s&&l.invalidateQueries({queryKey:c.projects})}}),[f,h]=z(t),g=f.trim();R({dirty:g!==t,invalid:g===``,save:()=>u.mutateAsync(g),discard:()=>{h(t),u.reset()}});let _=u.isError?u.error.message:null;return(0,H.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,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${a}-root`,value:f,disabled:u.isPending,placeholder:i,onChange:e=>{h(e.target.value),u.isError&&u.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`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:o}):(0,H.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),s=U(),c=(0,V.useMemo)(()=>o(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:c,disabled:s.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),s.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(w,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(w,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.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 Q({project:e,vocabulary:t,onSaved:n}){let r=u(),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),[c,d]=(0,V.useState)(-1),p=(0,V.useRef)(null),m=e.tags??[],h=l(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>f(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){f(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},C=e=>{y(m.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.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,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(ee,{open:_,onOpenChange:s,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:p,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&c>=0?`${w}-${c}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=c+t;d(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(c>=0?h[c]??i:i);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.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,H.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,H.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,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===c,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),p.current?.focus()},onMouseEnter:()=>d(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===c&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=u(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>f(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{U as i,Y as a,ot as o,rt as s,sn as c,st as l,tt as u,zn as d}from"./queries-CPNrCEon.js";import{a as f,dn as p,ha as m}from"./project-scope-context-_6sNMsAf.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as ee}from"./popover-BQolmvDR.js";import{t as S}from"./centered-state-N8vWM_Hw.js";import{$t as C,Rn as w,an as te,en as T,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-BlqAIDwd.js";import{t as M}from"./option-select-Bz-6fs6-.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-Dpl3ksiL.js";import{r as R}from"./settings-save-bar-DXlarWtq.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=a();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{f(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>f(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:s().data?.homeDir??null,root:null};return(0,H.jsx)(C,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(te,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.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.`,e?(0,H.jsx)(w,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(T,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=s(),t=i();return e.isPending||t.isPending?(0,H.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,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{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`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,footer:o,refreshProjects:s=!1}){let l=m(),u=d({mutationFn:t=>p(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{l.setQueryData(c.config,t),e===`browseRoot`?l.invalidateQueries({queryKey:c.fsBrowseRoot}):s&&l.invalidateQueries({queryKey:c.projects})}}),[f,h]=z(t),g=f.trim();R({dirty:g!==t,invalid:g===``,save:()=>u.mutateAsync(g),discard:()=>{h(t),u.reset()}});let _=u.isError?u.error.message:null;return(0,H.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,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${a}-root`,value:f,disabled:u.isPending,placeholder:i,onChange:e=>{h(e.target.value),u.isError&&u.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`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:o}):(0,H.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),s=U(),c=(0,V.useMemo)(()=>o(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:c,disabled:s.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),s.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(w,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(w,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.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 Q({project:e,vocabulary:t,onSaved:n}){let r=u(),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),[c,d]=(0,V.useState)(-1),p=(0,V.useRef)(null),m=e.tags??[],h=l(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>f(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){f(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},C=e=>{y(m.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.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,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(ee,{open:_,onOpenChange:s,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:p,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&c>=0?`${w}-${c}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=c+t;d(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(c>=0?h[c]??i:i);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.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,H.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,H.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,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===c,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),p.current?.focus()},onMouseEnter:()=>d(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===c&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=u(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>f(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{O as r,dt as i,on as a,zn as o}from"./queries-CPNrCEon.js";import{R as s,a as c,ha as l}from"./project-scope-context-_6sNMsAf.js";import{o as u}from"./dist-CCX8mhHc.js";import{K as d,X as f,l as p,mt as m,rt as h,st as g,u as _}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-BV_AiLj2.js";import{i as y,r as b,t as x}from"./popover-BQolmvDR.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-4D8sPZJy.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-N8vWM_Hw.js";import{at as N,ct as P,ft as F,lr as I,lt as L}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{O as r,dt as i,on as a,zn as o}from"./queries-CPNrCEon.js";import{R as s,a as c,ha as l}from"./project-scope-context-_6sNMsAf.js";import{o as u}from"./dist-CCX8mhHc.js";import{K as d,X as f,l as p,mt as m,rt as h,st as g,u as _}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-BV_AiLj2.js";import{i as y,r as b,t as x}from"./popover-BQolmvDR.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-4D8sPZJy.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-N8vWM_Hw.js";import{at as N,ct as P,ft as F,lr as I,lt as L}from"./index-BlqAIDwd.js";import{t as R}from"./textarea-BGp28xFr.js";import{n as z,t as B}from"./settings-field-AyinSFR_.js";import{r as V}from"./settings-save-bar-DXlarWtq.js";import{n as H,t as U}from"./saved-draft-BwzBc-_Y.js";import{t as W}from"./settings-list-detail-BlEEuyae.js";var G=e(t(),1),K=n();function q({template:e}){let t=e.text.trim().split(`
|
|
2
2
|
`)[0]??``,n=e.skills?.length??0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`settings-list-row-title`,children:e.label.trim()||`Untitled template`}),(0,K.jsxs)(`span`,{className:`settings-list-row-meta`,children:[t||`No instructions yet`,n>0?` · ${n} skill${n===1?``:`s`}`:``]})]})}function J(){let e=r();return e.isPending?(0,K.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,K.jsx)(M,{icon:(0,K.jsx)(d,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,K.jsx)(Y,{initial:L(e.data.promptTemplates)})}function Y({initial:e}){let t=l(),n=i(),u=r(),[d,p]=H(e,U),[h,_]=(0,G.useState)(null),y=o({mutationFn:e=>s({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(a.uiState,e),p(t=>U(t,n)?L(e.promptTemplates):t)},onError:e=>c(e.message,{tone:`danger`})}),b=JSON.stringify(d)!==JSON.stringify(e),x=d.some(e=>e.label.trim()===``||e.text.trim()===``);V({dirty:b,invalid:x,save:()=>y.mutateAsync(d),discard:()=>p(e)});let S=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),C=(e,t)=>p(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})),w=e=>{let t=d.findIndex(t=>t.id===e),n=d.filter(t=>t.id!==e);p(n),_(n[Math.min(t,n.length-1)]?.id??null)};return(0,K.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,K.jsxs)(z,{wide:!0,title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,K.jsx)(W,{slot:`prompt-template-list`,label:`Prompt templates`,items:d,itemKey:e=>e.id,selectedKey:h,onSelect:_,empty:(0,K.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one, or reset to the built-ins.`}),row:e=>(0,K.jsx)(q,{template:e}),detail:e=>(0,K.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:B,children:`Template label`}),(0,K.jsx)(I,{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=>S(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,K.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:B,children:`Instructions`}),(0,K.jsx)(R,{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=>S(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,K.jsx)(`p`,{className:B,children:`Apply automatically with skills`}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(X,{label:e.label,skills:n.data??[],skillUsage:u.data?.skillUsage,selected:e.skills??[],onToggle:t=>C(e.id,t)}),(e.skills??[]).map(t=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>C(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,K.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,K.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>w(e.id),children:[(0,K.jsx)(g,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,onClick:()=>{let e=P();p(t=>[...t,{id:e,label:``,text:``}]),_(e)},children:[(0,K.jsx)(f,{"aria-hidden":`true`,className:`size-3.5`}),`New template`]}),(0,K.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:y.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),x?(0,K.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function X({label:e,skills:t,skillUsage:n,selected:r,onToggle:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),{mostUsed:d,project:f,global:m,ranked:g}=j(t,s,n),v=(e,t)=>{let n=r.includes(e.id);return(0,K.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:()=>i(e.id),children:[(0,K.jsx)(F,{skill:e,emphasized:t}),n?(0,K.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,K.jsxs)(x,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(y,{asChild:!0,children:(0,K.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:u(`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`,r.length>0&&`text-foreground`),children:[(0,K.jsx)(h,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,K.jsx)(_,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(D,{shouldFilter:!1,children:[(0,K.jsx)(S,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>l.current?.scrollTo(0,0)}),(0,K.jsxs)(E,{ref:l,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!t.some(e=>e.id===s.trim())?(0,K.jsx)(C,{children:(0,K.jsxs)(w,{value:`typed-skill`,onSelect:()=>i(s.trim()),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(g?g.length===0:d.length===0&&f.length===0&&m.length===0)?(0,K.jsx)(T,{children:`Nothing matches.`}):null,g?g.length>0?(0,K.jsx)(C,{children:g.map(e=>v(e,k(e)))}):null:(0,K.jsxs)(K.Fragment,{children:[d.length>0?(0,K.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,K.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,m.length>0?(0,K.jsx)(C,{heading:`Global`,children:m.map(e=>v(e,!1))}):null]})]})]})})]})}export{J as PromptTemplatesSection};
|
package/web/dist/assets/{remote-settings-notice-tNcad9fA.js → remote-settings-notice-CPMHtuyk.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{B as r,on as i,sn as a}from"./queries-CPNrCEon.js";import{ha as o}from"./project-scope-context-_6sNMsAf.js";import{Tn 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{B as r,on as i,sn as a}from"./queries-CPNrCEon.js";import{ha as o}from"./project-scope-context-_6sNMsAf.js";import{Tn as s}from"./index-BlqAIDwd.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:a.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return r().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{A as r,C as i,H as a,Qt as o,Rt as s,S as c,T as l,on as u,ut as d,w as f,zn as p}from"./queries-CPNrCEon.js";import{g as m}from"./host-context-KsSKxKbI.js";import{B as h,Bt as ee,T as g,a as _,f as v,ha as y,ut as b,w as x,wn as S,z as te}from"./project-scope-context-_6sNMsAf.js";import{Z as C}from"./live-protocol-CNUmr-VT.js";import{_ as w,g as T}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as E,f as D,i as O,t as ne}from"./reference-chip-B32qTHb5.js";import{o as k,s as re}from"./dist-CCX8mhHc.js";import{D as ie,F as ae,I as oe,M as se,N as ce,P as le,Q as ue,S as de,X as fe,Z as pe,c as me,ct as A,d as he,j as ge,l as _e,n as ve,st as ye,w as be,y as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./createLucideIcon-BHp8sXmF.js";import{n as Ce,t as we}from"./circle-x-7nTlobAF.js";import{_ as Te}from"./nav-row-styles-CIedRn3A.js";import{i as Ee,r as De,t as Oe}from"./git-toolbar-D3O7S7vw.js";import{t as j}from"./info-DA1x_4bz.js";import{t as ke}from"./loader-circle-CPBhhDbB.js";import{a as Ae,i as je,n as Me,r as Ne}from"./diff-controls-CcYIa7pJ.js";import{t as M}from"./button-BV_AiLj2.js";import{i as N,l as Pe,p as Fe,r as Ie,t as Le}from"./dropdown-menu-NJZfnQCU.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./dialog-DKr-j9S6.js";import{t as P}from"./project-router-l_pJCK5X.js";import{t as Ge}from"./status-dot-Dvy-rnDJ.js";import{c as Ke,d as qe,f as Je,m as F,n as Ye,s as I,t as Xe}from"./page-shell-BdjH5hyc.js";import{a as Ze,o as Qe}from"./format-BU7D3IfE.js";import{t as $e}from"./control-locations-kCPVEtOM.js";import{t as L}from"./centered-state-N8vWM_Hw.js";import{$t as R,A as z,Bn as et,Bt as tt,Cr as nt,Gt as rt,Ht as it,Jt as at,Kt as ot,Pn as st,Qt as ct,Rn as lt,Rt as ut,Tr as dt,Ut as ft,Vt as pt,Wt as mt,Xt as ht,Yt as gt,Zt as _t,an as B,en as V,gr as vt,in as H,k as yt,lr as U,nn as W,on as G,qt as K,rn as q,tn as J,zn as bt,zt as xt}from"./index-CIyGnGfm.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-BQIvq2Ar.js";import{t as wt}from"./change-counts-BLLRvt46.js";import{t as Tt}from"./code-workbench-B0GIezrD.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-DGLW8f7_.js";var Y=e(t(),1);function At(e,t){let n=y(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=Se(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=Se(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=m(),t=c(),n=y(),r=At({queryKey:u.repo})>0,i=t.data?.info?t.data:null,a=ut(e,i,`screen`);return(0,X.jsx)(qe,{route:`repo-git`,density:i?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ke,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,X.jsx)(pe,{size:17,"aria-hidden":`true`,className:k(`size-[17px]`,r&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:i,info:i.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)(xt,{branch:i?.info?.branch??null,counts:a,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ke,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:rt(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=mt(m()),i=rt(m()),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),l=a.trim(),u=Pt(l),d=u??s;return(0,X.jsx)(We,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(He,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!l||u||i)&&(c(null),r.mutate(l,{onSuccess:n,onError:e=>c(e.message)}))},children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Ue,{children:`New branch`}),(0,X.jsxs)(ze,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(Be,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(U,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:a,"aria-invalid":d?!0:void 0,"aria-describedby":d?`new-branch-name-hint`:void 0,onChange:e=>{o(e.target.value),c(null)}}),d?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":u?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:d}):null]}),(0,X.jsxs)(Re,{children:[(0,X.jsx)(M,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(M,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!l||u!==null||i,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=i(),r=new Map((n.data?.branches??[]).map(e=>[e.name,e])),a=n.data?.base??e.baseBranch??t.branch,o=mt(m(),e=>_(e.message,{tone:`danger`})),s=rt(m()),[c,l]=(0,Y.useState)(``),u=c.trim().toLowerCase(),d=Gt(e,n.data?.branches),f=u?d.filter(e=>e.toLowerCase().includes(u)):d;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(U,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:c,onChange:e=>l(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:[f.map(e=>{let n=e===t.branch,i=r.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(P,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:k(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:a}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(M,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:s,onClick:()=>o.mutate(e),children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),f.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,c.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:oe,className:`border-success/40 text-semantic-green`},draft:{icon:ae,className:`border-border text-muted-foreground`},merged:{icon:ce,className:`border-merged-strong/35 text-merged-text`},closed:{icon:le,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],r=(0,X.jsxs)(`span`,{className:k(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),i=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return re(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:k(i,`group focus-visible:outline-2 focus-visible:outline-ring`),children:r}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:i,children:r})}function Ht({checks:e}){let t=e===`passing`?Ce:e===`failing`?we:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:k(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:k(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=f(),t=F(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof S&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>De(p),[p]),h=(0,Y.useMemo)(()=>p.some(St),[p]),ee=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)(L,{icon:d?(0,X.jsx)(be,{size:16}):(0,X.jsx)(A,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(be,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(Oe,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,X.jsx)(je,{}):null,h?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(Ae,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Ne,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o}),(0,X.jsx)(Me,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:h?s:void 0,disabled:h&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ee,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:p,viewRef:u,mode:ee,wrap:i,preview:o,loadFileText:e=>Et(()=>g(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=T(),r=F(),i=e.log,a=(0,Y.useMemo)(()=>ct(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=at(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(L,{icon:(0,X.jsx)(se,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:k(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(P,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=k(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(P,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:k(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ft(m(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(ke,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ve,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(it,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:l(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:l(e),sha:e,backTo:ot,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>x(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=i(),t=o(),n=m(),r=a(),[s,c]=(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)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let l=en(e.data.branches),u=l.reduce((e,t)=>e+t.rows.length,0),d=tn(e.data.branches),f=d>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[d,` finished task`,d===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,d===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(P,{to:K.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,p=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(O,{projectId:n,repoBase:r,requests:l.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),f,l.length===0?(0,X.jsx)(Xe,{icon:(0,X.jsx)(vt,{size:16}),title:d>0?`Nothing else waiting to land`:`Everything landed`,description:d>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:K.cleanup,children:`Check cleanup`})}),(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:l.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?p.get(e.runId):void 0,onDelete:()=>c(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),u<=3?(0,X.jsx)(Ye,{summary:`${u} ${u===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:K.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:s,onClose:()=>c(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:k(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(ne,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=y(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=p({mutationFn:()=>b(e.runId),onSuccess:e=>{_(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>_(e instanceof S&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{_(`Copied ${e.name}`),l.current!==null&&clearTimeout(l.current),c(!0),l.current=setTimeout(()=>c(!1),2e3)},()=>_(`Could not copy the branch name`,{tone:`danger`})),f=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":s||void 0,"aria-live":`polite`,onClick:d,className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[s?(0,X.jsx)(_e,{"aria-hidden":`true`}):(0,X.jsx)(xe,{"aria-hidden":`true`}),s?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Le,{children:[(0,X.jsx)(Fe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(N,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(P,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(N,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Draft PR`}):null,(0,X.jsx)(N,{className:k(!r&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Pe,{className:`md:hidden`}),(0,X.jsx)(N,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Ze(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Te,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ge,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(P,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=d(E(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=y(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=p({mutationFn:e=>v({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;_(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=>_(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)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(q,{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)(et,{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)(U,{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)(H,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(V,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=y(),[r,a]=(0,Y.useState)({merged:!1,empty:!1}),[o,s]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),d=[...c,...l],f=p({mutationFn:e=>v({names:e}),onSuccess:e=>{let t=e.refused.length;_(`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}),_(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 m=d.length,h=`branch${m===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 · `,m]}),(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:m===0||f.isPending,onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(ye,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${m} ${h}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>a(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>a(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:o,onOpenChange:s,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,m,` `,h,`?`]}),(0,X.jsxs)(q,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(V,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(d.map(e=>e.name)),s(!1)},children:[`Delete `,m,` `,h]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:k(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(lt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(bt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${D(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?D(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${D(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{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)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(R,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(q,{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)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"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)(R,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(q,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(V,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=r(),t=s().data?.targets.find(e=>e.id===`finder`),n=p({mutationFn:e=>ee(e,t.id),onError:e=>_(e.message,{tone:`danger`})}),i=y(),[a,o]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:u.worktrees}),i.invalidateQueries({queryKey:u.repoBranches})]),g=p({mutationFn:({runIds:e})=>h(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),_(gn(e.reclaimed.length,t,!!n))},onError:e=>_(e.message,{tone:`danger`})}),v=p({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),_(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),_(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:b,totalBytes:x,keep:S}=e.data,C=g.isPending||v.isPending,w=b.filter(e=>e.pastKeep),T=w.filter(e=>!e.reclaimBlocker),E=w.filter(e=>e.reclaimBlocker!==null),O=T.length>0,ne=$(T),k=$(w),re=_n(T.length,ne),ie=vn(w.length,k,O),ae=x?D(x):null,oe=bn(S);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`,ae?` · ${ae}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[oe.prefix,(0,X.jsx)(P,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:$e(`worktrees`,` › `)}),oe.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:C||!O,title:yn(O,E.length),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)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),re]})]}),E.length>0?(0,X.jsx)(xn,{blocked:E,discardLabel:ie,disabled:C,onDiscard:()=>l(w)}):null,b.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:b.map(e=>(0,X.jsx)(En,{worktree:e,keep:S,disabled:C,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?f(e):v.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:a,onCloseClean:()=>o(!1),cleanCount:T.length,cleanBytes:ne,reclaimLabel:re,onConfirmClean:()=>{g.mutate({expected:T.length}),o(!1)},discardBatch:c,onCloseDiscardBatch:()=>l(null),onConfirmDiscardBatch:e=>{g.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:d,onCloseRow:()=>f(null),onConfirmRow:e=>v.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=Tn(e,t),s=Ze(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Qe(s)}`:e.status,l=o.tone===`in-use`?`text-status-running`:o.tone===`blocked`?`text-danger`:`text-soft-foreground`,u=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,d=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.state,title:u,className:k(`text-xs`,l),children:o.label}),f=`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`,p=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,m=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),` · `,c,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.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:d}),r?(0,X.jsx)(`button`,{type:`button`,className:f,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":p,title:m,disabled:n,onClick:a,className:k(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=c(),r=F(),[i]=w(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(yt,{});if(n.isError)return(0,X.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(ge,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),a=i(),o=An(n),s=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,a.data?.branches).length:n===`not-landed`?a.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(I,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:Je(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(z,{}),header:{title:o?.title??tt(n,t.branch),headerSlot:`repo-header`,subtitle:o?(0,X.jsxs)(X.Fragment,{children:[`Commit `,o.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=T(),n=F(),r=e===`main`&&!n?t:void 0,i=l(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${gt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,i().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{A as r,C as i,H as a,Qt as o,Rt as s,S as c,T as l,on as u,ut as d,w as f,zn as p}from"./queries-CPNrCEon.js";import{g as m}from"./host-context-KsSKxKbI.js";import{B as h,Bt as ee,T as g,a as _,f as v,ha as y,ut as b,w as x,wn as S,z as te}from"./project-scope-context-_6sNMsAf.js";import{Z as C}from"./live-protocol-CNUmr-VT.js";import{_ as w,g as T}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as E,f as D,i as O,t as ne}from"./reference-chip-B32qTHb5.js";import{o as k,s as re}from"./dist-CCX8mhHc.js";import{D as ie,F as ae,I as oe,M as se,N as ce,P as le,Q as ue,S as de,X as fe,Z as pe,c as me,ct as A,d as he,j as ge,l as _e,n as ve,st as ye,w as be,y as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./createLucideIcon-BHp8sXmF.js";import{n as Ce,t as we}from"./circle-x-7nTlobAF.js";import{_ as Te}from"./nav-row-styles-CIedRn3A.js";import{i as Ee,r as De,t as Oe}from"./git-toolbar-CnbRMfPP.js";import{t as j}from"./info-DA1x_4bz.js";import{t as ke}from"./loader-circle-CPBhhDbB.js";import{a as Ae,i as je,n as Me,r as Ne}from"./diff-controls-CQuYWKK_.js";import{t as M}from"./button-BV_AiLj2.js";import{i as N,l as Pe,p as Fe,r as Ie,t as Le}from"./dropdown-menu-NJZfnQCU.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./dialog-DKr-j9S6.js";import{t as P}from"./project-router-l_pJCK5X.js";import{t as Ge}from"./status-dot-Dvy-rnDJ.js";import{c as Ke,d as qe,f as Je,m as F,n as Ye,s as I,t as Xe}from"./page-shell-BdjH5hyc.js";import{a as Ze,o as Qe}from"./format-BU7D3IfE.js";import{t as $e}from"./control-locations-kCPVEtOM.js";import{t as L}from"./centered-state-N8vWM_Hw.js";import{$t as R,A as z,Bn as et,Bt as tt,Cr as nt,Gt as rt,Ht as it,Jt as at,Kt as ot,Pn as st,Qt as ct,Rn as lt,Rt as ut,Tr as dt,Ut as ft,Vt as pt,Wt as mt,Xt as ht,Yt as gt,Zt as _t,an as B,en as V,gr as vt,in as H,k as yt,lr as U,nn as W,on as G,qt as K,rn as q,tn as J,zn as bt,zt as xt}from"./index-BlqAIDwd.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-4OKh2896.js";import{t as wt}from"./change-counts-BLLRvt46.js";import{t as Tt}from"./code-workbench-B0GIezrD.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-B3px5blI.js";var Y=e(t(),1);function At(e,t){let n=y(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=Se(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=Se(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=m(),t=c(),n=y(),r=At({queryKey:u.repo})>0,i=t.data?.info?t.data:null,a=ut(e,i,`screen`);return(0,X.jsx)(qe,{route:`repo-git`,density:i?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ke,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,X.jsx)(pe,{size:17,"aria-hidden":`true`,className:k(`size-[17px]`,r&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:i,info:i.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)(xt,{branch:i?.info?.branch??null,counts:a,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ke,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:rt(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=mt(m()),i=rt(m()),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),l=a.trim(),u=Pt(l),d=u??s;return(0,X.jsx)(We,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(He,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!l||u||i)&&(c(null),r.mutate(l,{onSuccess:n,onError:e=>c(e.message)}))},children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Ue,{children:`New branch`}),(0,X.jsxs)(ze,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(Be,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(U,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:a,"aria-invalid":d?!0:void 0,"aria-describedby":d?`new-branch-name-hint`:void 0,onChange:e=>{o(e.target.value),c(null)}}),d?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":u?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:d}):null]}),(0,X.jsxs)(Re,{children:[(0,X.jsx)(M,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(M,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!l||u!==null||i,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=i(),r=new Map((n.data?.branches??[]).map(e=>[e.name,e])),a=n.data?.base??e.baseBranch??t.branch,o=mt(m(),e=>_(e.message,{tone:`danger`})),s=rt(m()),[c,l]=(0,Y.useState)(``),u=c.trim().toLowerCase(),d=Gt(e,n.data?.branches),f=u?d.filter(e=>e.toLowerCase().includes(u)):d;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(U,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:c,onChange:e=>l(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:[f.map(e=>{let n=e===t.branch,i=r.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(P,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:k(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:a}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(M,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:s,onClick:()=>o.mutate(e),children:[(0,X.jsx)(ge,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),f.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,c.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:oe,className:`border-success/40 text-semantic-green`},draft:{icon:ae,className:`border-border text-muted-foreground`},merged:{icon:ce,className:`border-merged-strong/35 text-merged-text`},closed:{icon:le,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],r=(0,X.jsxs)(`span`,{className:k(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),i=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return re(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:k(i,`group focus-visible:outline-2 focus-visible:outline-ring`),children:r}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:i,children:r})}function Ht({checks:e}){let t=e===`passing`?Ce:e===`failing`?we:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:k(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:k(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=f(),t=F(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof S&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>De(p),[p]),h=(0,Y.useMemo)(()=>p.some(St),[p]),ee=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)(L,{icon:d?(0,X.jsx)(be,{size:16}):(0,X.jsx)(A,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(be,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(Oe,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,X.jsx)(je,{}):null,h?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(Ae,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Ne,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o}),(0,X.jsx)(Me,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:h?s:void 0,disabled:h&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ee,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:p,viewRef:u,mode:ee,wrap:i,preview:o,loadFileText:e=>Et(()=>g(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=T(),r=F(),i=e.log,a=(0,Y.useMemo)(()=>ct(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=at(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(L,{icon:(0,X.jsx)(se,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:k(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(P,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=k(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(P,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:k(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ft(m(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(ke,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ve,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(it,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:l(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:l(e),sha:e,backTo:ot,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>x(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=i(),t=o(),n=m(),r=a(),[s,c]=(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)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let l=en(e.data.branches),u=l.reduce((e,t)=>e+t.rows.length,0),d=tn(e.data.branches),f=d>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[d,` finished task`,d===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,d===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(P,{to:K.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,p=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(O,{projectId:n,repoBase:r,requests:l.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),f,l.length===0?(0,X.jsx)(Xe,{icon:(0,X.jsx)(vt,{size:16}),title:d>0?`Nothing else waiting to land`:`Everything landed`,description:d>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:K.cleanup,children:`Check cleanup`})}),(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:l.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?p.get(e.runId):void 0,onDelete:()=>c(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),u<=3?(0,X.jsx)(Ye,{summary:`${u} ${u===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(P,{to:K.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:s,onClose:()=>c(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:k(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(ne,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=y(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=p({mutationFn:()=>b(e.runId),onSuccess:e=>{_(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>_(e instanceof S&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{_(`Copied ${e.name}`),l.current!==null&&clearTimeout(l.current),c(!0),l.current=setTimeout(()=>c(!1),2e3)},()=>_(`Could not copy the branch name`,{tone:`danger`})),f=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":s||void 0,"aria-live":`polite`,onClick:d,className:k(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[s?(0,X.jsx)(_e,{"aria-hidden":`true`}):(0,X.jsx)(xe,{"aria-hidden":`true`}),s?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Le,{children:[(0,X.jsx)(Fe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(N,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(P,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(N,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Draft PR`}):null,(0,X.jsx)(N,{className:k(!r&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Pe,{className:`md:hidden`}),(0,X.jsx)(N,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Ze(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Te,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ge,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(P,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=d(E(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=y(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=p({mutationFn:e=>v({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;_(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=>_(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)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(q,{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)(et,{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)(U,{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)(H,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(V,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=y(),[r,a]=(0,Y.useState)({merged:!1,empty:!1}),[o,s]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),d=[...c,...l],f=p({mutationFn:e=>v({names:e}),onSuccess:e=>{let t=e.refused.length;_(`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}),_(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 m=d.length,h=`branch${m===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 · `,m]}),(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:m===0||f.isPending,onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(ye,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${m} ${h}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>a(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>a(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:o,onOpenChange:s,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,m,` `,h,`?`]}),(0,X.jsxs)(q,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(V,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(d.map(e=>e.name)),s(!1)},children:[`Delete `,m,` `,h]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:k(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(lt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(P,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(bt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${D(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?D(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${D(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{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)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(R,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(q,{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)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"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)(R,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(q,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(V,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=r(),t=s().data?.targets.find(e=>e.id===`finder`),n=p({mutationFn:e=>ee(e,t.id),onError:e=>_(e.message,{tone:`danger`})}),i=y(),[a,o]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:u.worktrees}),i.invalidateQueries({queryKey:u.repoBranches})]),g=p({mutationFn:({runIds:e})=>h(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),_(gn(e.reclaimed.length,t,!!n))},onError:e=>_(e.message,{tone:`danger`})}),v=p({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),_(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),_(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:b,totalBytes:x,keep:S}=e.data,C=g.isPending||v.isPending,w=b.filter(e=>e.pastKeep),T=w.filter(e=>!e.reclaimBlocker),E=w.filter(e=>e.reclaimBlocker!==null),O=T.length>0,ne=$(T),k=$(w),re=_n(T.length,ne),ie=vn(w.length,k,O),ae=x?D(x):null,oe=bn(S);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`,ae?` · ${ae}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[oe.prefix,(0,X.jsx)(P,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:$e(`worktrees`,` › `)}),oe.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:C||!O,title:yn(O,E.length),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)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),re]})]}),E.length>0?(0,X.jsx)(xn,{blocked:E,discardLabel:ie,disabled:C,onDiscard:()=>l(w)}):null,b.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:b.map(e=>(0,X.jsx)(En,{worktree:e,keep:S,disabled:C,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?f(e):v.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:a,onCloseClean:()=>o(!1),cleanCount:T.length,cleanBytes:ne,reclaimLabel:re,onConfirmClean:()=>{g.mutate({expected:T.length}),o(!1)},discardBatch:c,onCloseDiscardBatch:()=>l(null),onConfirmDiscardBatch:e=>{g.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:d,onCloseRow:()=>f(null),onConfirmRow:e=>v.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=Tn(e,t),s=Ze(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Qe(s)}`:e.status,l=o.tone===`in-use`?`text-status-running`:o.tone===`blocked`?`text-danger`:`text-soft-foreground`,u=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,d=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.state,title:u,className:k(`text-xs`,l),children:o.label}),f=`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`,p=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,m=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),` · `,c,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.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:d}),r?(0,X.jsx)(`button`,{type:`button`,className:f,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":p,title:m,disabled:n,onClick:a,className:k(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=c(),r=F(),[i]=w(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(yt,{});if(n.isError)return(0,X.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(A,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(ge,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),a=i(),o=An(n),s=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,a.data?.branches).length:n===`not-landed`?a.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(I,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:Je(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(z,{}),header:{title:o?.title??tt(n,t.branch),headerSlot:`repo-header`,subtitle:o?(0,X.jsxs)(X.Fragment,{children:[`Commit `,o.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=T(),n=F(),r=e===`main`&&!n?t:void 0,i=l(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${gt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,i().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};
|