orc-ai 0.1.63 → 0.1.64
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/README.md +3 -2
- package/dist/index.js +897 -803
- package/dist/skills/orc-platform/SKILL.md +1 -1
- package/dist/skills/orc-platform/references/html-kit.md +154 -0
- package/dist/skills/orc-platform/references/scratchpads.md +6 -2
- package/dist/web/assets/{Agents-DmrIiUAL.js → Agents-G5dt5_s6.js} +2 -2
- package/dist/web/assets/Audit-De9E5Tfd.js +1 -0
- package/dist/web/assets/ChatUiRenderer-B1D3eTfy.js +4 -0
- package/dist/web/assets/ConfirmDialog-Cp1PcD4R.js +1 -0
- package/dist/web/assets/{Dashboard-Dh9P-zTd.js → Dashboard-DWorNfLX.js} +1 -1
- package/dist/web/assets/DocumentWorkspace-DZI0NvGD.js +1 -0
- package/dist/web/assets/FileEditor-CarhD1G9.js +1 -0
- package/dist/web/assets/{IntegrationCallback-CUZ5N-88.js → IntegrationCallback-CuUd_OOy.js} +1 -1
- package/dist/web/assets/JobWebhooks-8emXf4c1.js +1 -0
- package/dist/web/assets/Jobs-ComQ_dFU.js +3 -0
- package/dist/web/assets/Knowledge-Cm2ZVDRs.js +1 -0
- package/dist/web/assets/{MarkdownRenderer-fsBqw-wB.js → MarkdownRenderer-CHALCapQ.js} +5 -5
- package/dist/web/assets/{NativeFolderField-BuHwey26.js → NativeFolderField-CdaIEZa-.js} +1 -1
- package/dist/web/assets/PackageCatalog-CcPUM8f8.js +8 -0
- package/dist/web/assets/{PackageRunDialog-C8m43ZhJ.js → PackageRunDialog-DV1E6WX3.js} +19 -19
- package/dist/web/assets/{Pager-Dbs7fj3d.js → Pager-DZtibAkl.js} +1 -1
- package/dist/web/assets/Projects-BxrWujMD.js +3 -0
- package/dist/web/assets/{ResponsiveFilters-HzhzzjyL.js → ResponsiveFilters-C3siPRT-.js} +1 -1
- package/dist/web/assets/{ResumeActions-e6YpUhEq.js → ResumeActions-0eJvpGmW.js} +1 -1
- package/dist/web/assets/Rules-CHdgAIUd.js +18 -0
- package/dist/web/assets/{ScratchpadDiagramEditor-DkW_SmM8.js → ScratchpadDiagramEditor-6R8JsXS3.js} +1 -1
- package/dist/web/assets/Scratchpads-uD9R68sw.js +10 -0
- package/dist/web/assets/{SessionHomeLink-BAWO86fJ.js → SessionHomeLink-CMCZb7Vy.js} +1 -1
- package/dist/web/assets/Sessions-BD9AlzAN.js +4 -0
- package/dist/web/assets/Settings-Bt1even4.js +14 -0
- package/dist/web/assets/Skills-BSsN8kq-.js +3 -0
- package/dist/web/assets/{SourceEditor-B6pT-Rc0.js → SourceEditor-V5vL7Aof.js} +4 -4
- package/dist/web/assets/{TagInput-ChFu05vJ.js → TagInput-DU4zMpED.js} +1 -1
- package/dist/web/assets/TaskDetailSheet-C8dGHMsb.js +1 -0
- package/dist/web/assets/{Tasks-CC92r1kL.js → Tasks-wxRlyx-L.js} +6 -6
- package/dist/web/assets/Terminals-BFRG72xa.js +2 -0
- package/dist/web/assets/{ViewHeader-D-lhe59Y.js → ViewHeader-CKIR1ZTZ.js} +1 -1
- package/dist/web/assets/{Webhooks-BxpA1QBK.js → Webhooks-Bg3pm4rJ.js} +1 -1
- package/dist/web/assets/{badge-BqTVr27Z.js → badge-DfvoXiLp.js} +1 -1
- package/dist/web/assets/check-DrnDUgkq.js +1 -0
- package/dist/web/assets/chevron-down-C1WyGsAA.js +1 -0
- package/dist/web/assets/chevron-up-ZnWliPW7.js +1 -0
- package/dist/web/assets/{chunk-OB3PAWPO-1IihCzFx.js → chunk-OB3PAWPO-BD6ylT0A.js} +1 -1
- package/dist/web/assets/{circle-check-DWP3C_MJ.js → circle-check-CnioupGj.js} +1 -1
- package/dist/web/assets/{client-954dj6K2.js → client-DigivyCS.js} +1 -1
- package/dist/web/assets/{download-BD7lYc4O.js → download-CNwtbYo1.js} +1 -1
- package/dist/web/assets/{highlighted-body-JLMTFACH-CAMR1LA5.js → highlighted-body-JLMTFACH-dpkthrjz.js} +1 -1
- package/dist/web/assets/{index-XIDqokJX.js → index-Bc-Nka6Y.js} +50 -49
- package/dist/web/assets/index-BrDTqMtQ.css +1 -0
- package/dist/web/assets/{live-sessions-C6D_vHcN.js → live-sessions-BG3mNXnQ.js} +1 -1
- package/dist/web/assets/{maximize-2-BUxUwGbf.js → maximize-2-CcupqYE8.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-BX9NWlJb.js +1 -0
- package/dist/web/assets/orc-kit-BZEVA3Qv.js +317 -0
- package/dist/web/assets/{scratchpad-kinds-B0Y6McXL.js → scratchpad-kinds-RGciqVT1.js} +1 -1
- package/dist/web/assets/{scratchpad-routes-BtsIfhUW.js → scratchpad-routes-Q2TRGUnx.js} +1 -1
- package/dist/web/assets/send-0IpktRLv.js +1 -0
- package/dist/web/assets/{upload-CPf6QZHl.js → upload-CaDKCpy5.js} +1 -1
- package/dist/web/assets/{useDetailRoute-DOhAbdV7.js → useDetailRoute-B-xjWsyW.js} +1 -1
- package/dist/web/assets/{useIntegrations-C0MAVKB4.js → useIntegrations-C6zijOMH.js} +1 -1
- package/dist/web/assets/{useJobs-BlWldKP0.js → useJobs-Dly6n-pv.js} +1 -1
- package/dist/web/assets/{useMemories-CAf8HcOI.js → useMemories-jakANU6m.js} +1 -1
- package/dist/web/assets/useProjectScope-DpgzthH7.js +1 -0
- package/dist/web/assets/{useSessions-DiUU2FN8.js → useSessions-tFa1FZ9M.js} +1 -1
- package/dist/web/assets/{view-params-DD7i9s5g.js → view-params-YEmeZppw.js} +1 -1
- package/dist/web/assets/{x-tY-z3woy.js → x-BayoBYp_.js} +1 -1
- package/dist/web/index.html +11 -18
- package/dist/web/sw.js +26 -17
- package/package.json +1 -1
- package/dist/web/assets/Audit-DGSNmToV.js +0 -1
- package/dist/web/assets/ChatUiRenderer-Dddr55cW.js +0 -4
- package/dist/web/assets/ConfirmDialog-B5es4nUp.js +0 -1
- package/dist/web/assets/DocumentWorkspace-I81K42yx.js +0 -1
- package/dist/web/assets/FileEditor-wRs221QU.js +0 -1
- package/dist/web/assets/JobWebhooks-oaF694Af.js +0 -1
- package/dist/web/assets/Jobs-Lmyw5700.js +0 -3
- package/dist/web/assets/Knowledge-V4JuZnUZ.js +0 -1
- package/dist/web/assets/Markdown-D-AaJ4bU.js +0 -2
- package/dist/web/assets/MarkdownEditor-5U4_BhYm.js +0 -2
- package/dist/web/assets/PackageCatalog-BC-yAjPQ.js +0 -8
- package/dist/web/assets/Projects-C280nbHV.js +0 -3
- package/dist/web/assets/Rules-BwsnRQBe.js +0 -18
- package/dist/web/assets/Scratchpads-BtUKOhup.js +0 -10
- package/dist/web/assets/Sessions-Cn2dIJBt.js +0 -4
- package/dist/web/assets/Settings-Bb01CfFw.js +0 -14
- package/dist/web/assets/Skills-Vw41zPVg.js +0 -3
- package/dist/web/assets/TaskDetailSheet-DuTfo6rZ.js +0 -1
- package/dist/web/assets/Terminals-dCbgpRsm.js +0 -2
- package/dist/web/assets/check-Cg2_C_4I.js +0 -1
- package/dist/web/assets/chevron-down-KBvm_HoX.js +0 -1
- package/dist/web/assets/dialog-DNIYhwi4.js +0 -1
- package/dist/web/assets/file-kind-BYU1kv95.js +0 -1
- package/dist/web/assets/index-hvCYuRJb.css +0 -1
- package/dist/web/assets/label-Bm_d0NKL.js +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-Bzg8wVqT.js +0 -1
- package/dist/web/assets/select-cyLFVkkB.js +0 -1
- package/dist/web/assets/tabs-bEwJLtA0.js +0 -1
- package/dist/web/assets/textarea-CovStda2.js +0 -1
- package/dist/web/assets/useProjectScope-DtEj9j-P.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{D as i,a,b as o,c as s,d as c,i as l,j as u,k as d,l as f,n as p,o as m,p as h,s as g,t as _,u as v,v as y}from"./useMutation-CRAWY7v2.js";import{t as b}from"./button-By-NN7c7.js";import{h as x,n as S}from"./client-954dj6K2.js";import{t as C}from"./chevron-down-KBvm_HoX.js";import{t as w}from"./download-BD7lYc4O.js";import{t as T}from"./MarkdownEditor-5U4_BhYm.js";import{t as E}from"./ResponsiveFilters-HzhzzjyL.js";import{t as ee}from"./upload-CPf6QZHl.js";import{t as D}from"./label-Bm_d0NKL.js";import{a as O,i as k,n as A,o as j,t as M}from"./dialog-DNIYhwi4.js";import{t as te}from"./bulk-actions-C8S1Gt4W.js";import{Ir as N,Nr as ne,O as re,Or as ie,Ur as ae,_r as oe,_t as se,ai as ce,dn as le,dr as ue,dt as P,et as F,fr as de,ft as fe,gr as I,gt as pe,ht as me,lr as he,ot as ge,ri as L,ut as R,wr as _e,z as ve}from"./index-XIDqokJX.js";import{t as ye}from"./ConfirmDialog-B5es4nUp.js";import{t as be}from"./ErrorState-DB0nWfcc.js";import{t as xe}from"./ViewHeader-D-lhe59Y.js";import{t as Se}from"./useDetailRoute-DOhAbdV7.js";import{t as Ce}from"./view-params-DD7i9s5g.js";import{t as we}from"./EmptyState-YM4VSLR9.js";import{a as Te,i as z,n as Ee,o as De,r as B,t as Oe}from"./table-COm8Aml-.js";import{t as ke}from"./useProjectScope-DtEj9j-P.js";import{n as Ae,t as je}from"./useListSelection-BnMxiGpC.js";import{n as Me,t as V}from"./DocumentWorkspace-I81K42yx.js";import{i as Ne,n as H,r as Pe,t as Fe}from"./NativeFolderField-BuHwey26.js";import{t as U}from"./primitive-files-BKGHFjYN.js";function Ie(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var W=class extends o{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,y.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!u(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ie(e,n).forEach(e=>{e.destroy()}),Ie(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=d(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new h(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&y.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},G=e(t(),1);function Le({queries:e,...t},n){let o=r(n),u=c(),d=v(),p=t.subscribed!==!1,_=G.useMemo(()=>e.map(e=>{let t=o.defaultQueryOptions(e);return t._optimisticResults=u?`isRestoring`:p?`optimistic`:void 0,t}),[e,o,u,p]);_.forEach(e=>{l(e);let t=o.getQueryCache().get(e.queryHash);g(e,d,t)}),f(d);let[b]=G.useState(()=>new W(o,_,t)),[x,S,C]=b.getOptimisticResult(_,t.combine),w=!u&&p;G.useSyncExternalStore(G.useCallback(e=>w?b.subscribe(y.batchCalls(e)):i,[b,w]),()=>b.getCurrentResult(),()=>b.getCurrentResult()),G.useEffect(()=>{b.setQueries(_,t)},[_,t,b]);let T=x.some((e,t)=>m(_[t],e))?x.flatMap((e,t)=>{let n=_[t];if(n&&m(n,e)){let e=new h(o,n);return a(n,e,d)}return[]}):[];if(T.length>0)throw Promise.all(T);let E=x.find((e,t)=>{let n=_[t];return n&&s({result:e,errorResetBoundary:d,throwOnError:n.throwOnError,query:o.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(E)throw E.error;return S(C())}var Re={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};Re.node;var K=x(Re),ze={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};ze.node;var Be=x(ze),q={name:`toggle-right`,size:24,node:[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};q.node;var Ve=x(q),J=n();function He({files:e,selected:t,onSelect:n,testId:r=`document-file-tab`,entryTestId:i}){return(0,J.jsxs)(`nav`,{"aria-label":`Document files`,className:`min-w-0 space-y-2`,"data-testid":`document-tabs`,children:[(0,J.jsx)(`div`,{role:`tablist`,"aria-label":`Open a file`,className:`flex max-w-full gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-surface-highest p-1`,children:e.map((a,o)=>(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a===t,"data-testid":o===0&&i?i:r,"data-file-name":a,title:a,tabIndex:a===t?0:-1,onKeyDown:t=>{if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(t.key))return;t.preventDefault();let r=o;t.key===`ArrowRight`&&(r=(o+1)%e.length),t.key===`ArrowLeft`&&(r=(o+e.length-1)%e.length),t.key===`Home`&&(r=0),t.key===`End`&&(r=e.length-1),n(e[r])!==!1&&(t.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`))?.[r]?.focus()},onClick:()=>n(a),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${a===t?`bg-surface-highest text-on-surface`:`text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:[(0,J.jsx)(ae,{size:14,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`max-w-[180px] truncate`,children:a.split(`/`).pop()})]},a))}),(0,J.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm text-outline sm:hidden`,children:[`File`,(0,J.jsx)(`select`,{"aria-label":`Choose document file`,"data-testid":`document-file-picker`,value:t,onChange:e=>n(e.target.value),className:`min-h-11 min-w-0 flex-1 rounded border border-control-border bg-surface px-2 text-on-surface`,children:e.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))})]})]})}var Y={new:``,identical:`Already there`,near:`Near copy there, overwrite to replace`,conflict:`Different skill with this name there, overwrite to replace`,duplicate:`Already there under another name`,blocked:`Cannot be written`},X=`__folder__`;function Ue({onClose:e}){let[t,n]=(0,G.useState)(``),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)({}),u=r(),d=p({queryKey:[`skills`,`local-agents`,``],queryFn:()=>S.skills.localAgents()}),f=t===X?o?{path:o}:null:t.startsWith(`project:`)?{path:t.slice(Pe.length)}:t?{agent:t}:null,m=p({queryKey:[`skills`,`export-plan`,f],queryFn:()=>S.skills.previewExport(f??{path:``}),enabled:!!f}),h=_({mutationFn:e=>S.skills.exportTo(f??{path:``},e.names,e.overwrite),onSuccess:async t=>{l({}),await u.invalidateQueries({queryKey:[`skills`]}),t.skipped.length||e()}}),g=h.isPending,v=f?m.data?.skills??[]:[],y=v.filter(e=>(e.status===`new`||e.can_overwrite)&&c[e.name]),x=v.filter(e=>e.status===`new`),C=e=>{n(e),l({}),h.reset()};return(0,J.jsx)(M,{open:!0,onOpenChange:t=>!t&&!g&&e(),children:(0,J.jsxs)(A,{closeDisabled:g,className:`flex min-w-0 w-[min(800px,calc(100vw-2rem))] max-w-none max-h-[calc(var(--app-height,100dvh)-2rem)] flex-col gap-0 overflow-hidden p-0`,children:[(0,J.jsxs)(O,{className:`shrink-0 flex-row items-center gap-1 border-b px-4 py-3 pr-12 sm:px-6`,children:[(0,J.jsx)(j,{children:`Export to agents`}),(0,J.jsx)(oe,{label:`skill exports`,children:`Writes ORC skills as native skill folders (SKILL.md plus supporting files) into your agent skills folders, a project checkout (.claude/skills, .agents/skills, ...) or any folder. Project checkouts come from the project's folder and its agent sessions. Existing folders are only replaced when you select them, and a backup is kept.`})]}),(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-4 py-4 sm:px-6`,"data-testid":`skill-export-body`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`skill-export-target`,className:`text-sm font-medium`,children:`Destination`}),(0,J.jsxs)(`select`,{id:`skill-export-target`,"data-testid":`skill-export-target`,className:`block h-11 w-full rounded-md border border-input bg-background px-3 text-sm sm:h-8`,value:t,disabled:g,onChange:e=>C(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a destination`}),(0,J.jsx)(`optgroup`,{label:`Your agent skill folders`,children:(d.data?.agents??[]).map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.dir,`)`]},e.id))}),(0,J.jsx)(Ne,{}),(0,J.jsx)(`option`,{value:X,children:`Custom folder`})]}),t===X&&(0,J.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault(),l({}),s(i.trim())},children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(H,{id:`skill-export-folder`,label:`Folder`,value:i,disabled:g,onChange:a})}),(0,J.jsx)(b,{type:`submit`,variant:`outline`,"data-testid":`skill-export-folder-apply`,disabled:g||!i.trim(),children:`Compare`})]})]}),m.isLoading&&f&&(0,J.jsx)(`p`,{role:`status`,children:`Comparing with the destination…`}),m.data&&f&&(0,J.jsxs)(`section`,{"data-testid":`skill-export-plan`,className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-outline wrap-break-word`,children:m.data.dir}),(0,J.jsxs)(b,{size:`sm`,variant:`outline`,"data-testid":`skill-export-select-new`,disabled:g||!x.length,onClick:()=>l({...c,...Object.fromEntries(x.map(e=>[e.name,!0]))}),children:[`Select all new (`,x.length,`)`]})]}),(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:v.map(e=>{let t=e.status===`new`||e.can_overwrite;return(0,J.jsxs)(`label`,{className:`flex min-h-11 min-w-0 items-start gap-3 py-2 text-sm`,"data-testid":`skill-export-item`,"data-skill-name":e.name,"data-status":e.status,children:[(0,J.jsx)(`input`,{type:`checkbox`,"aria-label":`Export ${e.name}`,className:`mt-1 shrink-0`,"data-testid":`skill-export-select`,checked:t&&!!c[e.name],disabled:g||!t,onChange:t=>l({...c,[e.name]:t.target.checked})}),(0,J.jsxs)(`span`,{className:`min-w-0 wrap-break-word`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),Y[e.status]&&(0,J.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:Y[e.status]}),(0,J.jsx)(Fe,{match:e.match,folder:`the destination`}),e.reason&&e.status===`blocked`&&(0,J.jsx)(`span`,{className:`block text-xs text-destructive`,children:e.reason})]})]},e.name)})})]}),h.data?.skipped.map(e=>(0,J.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Skipped `,e.name,`: `,e.reason]},e.name)),(d.error||m.error||h.error)&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:(d.error||m.error||h.error)?.message})]}),(0,J.jsxs)(k,{className:`shrink-0 border-t px-4 py-3 sm:px-6`,children:[(0,J.jsx)(b,{variant:`ghost`,disabled:g,onClick:e,children:`Close`}),(0,J.jsx)(b,{"data-testid":`skill-export-submit`,disabled:g||!y.length,onClick:()=>h.mutate({names:y.map(e=>e.name),overwrite:y.filter(e=>e.status!==`new`).map(e=>e.name)}),children:g?`Exporting…`:`Export selected${y.length?` (${y.length})`:``}`})]})]})})}var We={new:``,installed:`Already in ORC`,duplicate:`Already in ORC under another name`,conflict:`Name taken in ORC (different content)`,changed:`Changed since import`,invalid:`Invalid`},Z=e=>`${e.agent}:${e.path}`;function Ge({onClose:e}){let[t,n]=(0,G.useState)([]),[i,a]=(0,G.useState)(`agents`),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(``),u=r(),d=i.startsWith(`project:`)?i.slice(Pe.length):i===`folder`?c:``,f=i===`agents`||!!d,m=p({queryKey:[`skills`,`local-agents`,d],queryFn:()=>S.skills.localAgents(d||void 0),enabled:f}),h=_({mutationFn:e=>S.skills.importLocal(e.map(e=>({agent:e.agent,name:e.name,...d?{path:e.path}:{}})),d||void 0),onSuccess:async t=>{n([]),await u.invalidateQueries({queryKey:[`skills`]}),t.skipped.length||e()}}),g=h.isPending,v=f?m.data?.agents??[]:[],y=new Set(t.map(Z)),x=new Set(t.map(e=>e.name)),C=(e,r)=>n(r?[...t,e]:t.filter(t=>Z(t)!==Z(e))),w=e=>{let r=[...t],i=new Set(x);for(let t of e)t.status!==`new`||i.has(t.name)||(r.push(t),i.add(t.name));n(r)},T=e=>{a(e),n([]),h.reset()};return(0,J.jsx)(M,{open:!0,onOpenChange:t=>!t&&!g&&e(),children:(0,J.jsxs)(A,{closeDisabled:g,className:`flex min-w-0 w-[min(800px,calc(100vw-2rem))] max-w-none max-h-[calc(var(--app-height,100dvh)-2rem)] flex-col gap-0 overflow-hidden p-0`,children:[(0,J.jsxs)(O,{className:`shrink-0 flex-row items-center gap-1 border-b px-4 py-3 pr-12 sm:px-6`,children:[(0,J.jsx)(j,{children:`Import from local agents`}),(0,J.jsx)(oe,{label:`local skill imports`,children:`Copies skills from agent folders such as ~/.claude/skills and ~/.codex/skills, a project checkout's skill folders, or any folder of skill folders, into ORC. The originals are not changed. Near copies of skills already in ORC are flagged so a one-letter edit does not create a duplicate.`})]}),(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-4 py-4 sm:px-6`,"data-testid":`local-skill-import-body`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`local-skill-source`,className:`text-sm font-medium`,children:`Source`}),(0,J.jsxs)(`select`,{id:`local-skill-source`,"data-testid":`local-skill-source`,className:`block h-11 w-full rounded-md border border-input bg-background px-3 text-sm sm:h-8`,value:i,disabled:g,onChange:e=>T(e.target.value),children:[(0,J.jsx)(`option`,{value:`agents`,children:`Your agent skill folders`}),(0,J.jsx)(Ne,{withSkillsOnly:!0}),(0,J.jsx)(`option`,{value:`folder`,children:`Custom folder`})]}),i===`folder`&&(0,J.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault(),n([]),l(o.trim())},children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(H,{id:`local-skill-folder`,label:`Folder`,value:o,disabled:g,onChange:s})}),(0,J.jsx)(b,{type:`submit`,variant:`outline`,"data-testid":`local-skill-folder-scan`,disabled:g||!o.trim(),children:`Scan`})]})]}),m.isLoading&&f&&(0,J.jsx)(`p`,{role:`status`,children:`Scanning skill folders…`}),m.data&&f&&!v.length&&(0,J.jsx)(`p`,{role:`status`,children:`No local agent skill folders found.`}),m.data&&d&&v.length>0&&!v[0]?.skills.length&&(0,J.jsx)(`p`,{role:`status`,children:`No skills found in this folder.`}),(0,J.jsx)(`div`,{className:`space-y-4`,children:v.map(e=>{let t=e.skills.filter(e=>e.status===`new`);return(0,J.jsxs)(`section`,{"data-testid":`local-agent`,"data-agent":e.id,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,J.jsxs)(`details`,{className:`text-xs text-outline`,children:[(0,J.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer items-center md:min-h-6 pointer-coarse:min-h-11`,children:`Source folder`}),(0,J.jsx)(`p`,{className:`wrap-break-word`,children:e.dir})]})]}),(0,J.jsxs)(b,{size:`sm`,variant:`outline`,"data-testid":`local-agent-select-all`,disabled:g||!t.length,onClick:()=>w(e.skills),children:[`Select all new (`,t.length,`)`]})]}),(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:e.skills.map(t=>{let n=y.has(Z(t)),r=!n&&x.has(t.name);return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-2`,"data-testid":`local-skill`,"data-skill-name":t.name,children:[(0,J.jsxs)(`label`,{className:`flex min-h-11 min-w-0 flex-1 items-start gap-3 text-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${t.name}`,className:`mt-1 shrink-0`,"data-testid":`local-skill-select`,checked:n,disabled:g||t.status!==`new`||r,onChange:e=>C(t,e.target.checked)}),(0,J.jsxs)(`span`,{className:`min-w-0 text-sm wrap-break-word`,children:[(0,J.jsx)(`span`,{className:`block truncate font-medium`,children:t.name}),We[t.status]&&(0,J.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:We[t.status]}),(0,J.jsx)(`span`,{className:`mt-0.5 line-clamp-2 text-xs leading-4 text-outline`,children:t.description}),(0,J.jsx)(Fe,{match:t.match,folder:e.label}),t.error&&(0,J.jsx)(`span`,{className:`block text-xs text-destructive wrap-break-word`,children:t.error})]})]}),(0,J.jsxs)(he,{children:[(0,J.jsx)(de,{asChild:!0,children:(0,J.jsx)(b,{type:`button`,size:`icon`,variant:`ghost`,actionHelp:!1,"data-testid":`local-skill-details`,"aria-label":`Details for ${t.name}`,className:`shrink-0`,children:(0,J.jsx)(N,{"aria-hidden":!0})})}),(0,J.jsxs)(ue,{"data-testid":`local-skill-details-content`,"aria-label":`Details for ${t.name}`,align:`end`,className:`max-h-[60dvh] w-96 max-w-[calc(100vw-2rem)] overflow-y-auto space-y-2 text-sm wrap-break-word`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:t.name}),(0,J.jsx)(`p`,{children:t.description}),t.extra_fields.length>0&&(0,J.jsxs)(`span`,{className:`block text-xs text-outline`,"data-testid":`local-skill-extra-fields`,children:[`Extra fields: `,t.extra_fields.join(`, `)]}),t.also_in.length>0&&(0,J.jsxs)(`span`,{className:`block text-xs text-outline`,children:[`Also in `,t.also_in.join(`, `)]})]})]})]},Z(t))})})]},e.id)})}),h.data?.skipped.map(e=>(0,J.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Skipped `,e.name,`: `,e.reason]},`${e.agent}/${e.name}`)),(m.error||h.error)&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:(m.error||h.error)?.message})]}),(0,J.jsxs)(k,{className:`shrink-0 border-t px-4 py-3 sm:px-6`,children:[(0,J.jsx)(b,{variant:`ghost`,disabled:g,onClick:e,children:`Close`}),(0,J.jsx)(b,{"data-testid":`local-skill-import-submit`,disabled:g||!t.length,onClick:()=>h.mutate(t),children:h.isPending?`Importing…`:`Import selected${t.length?` (${t.length})`:``}`})]})]})})}function Ke({onClose:e}){let[t,n]=(0,G.useState)(``),[i,a]=(0,G.useState)([]),o=r(),s=_({mutationFn:S.skills.discover,onSuccess:()=>{c.clear(),a([])}}),c=je((s.data?.skills??[]).filter(e=>!e.installed&&!i.includes(e.path)).map(e=>e.path),`${t}:${s.data?.commit??``}`),l=c.selectedIds,u=_({mutationFn:async()=>{if(!s.data)throw Error(`Discover skills first`);let e=[],n=[];for(let r=0;r<l.length;r+=16){let i=l.slice(r,r+16);try{await S.skills.import({source:t.trim(),commit:s.data.commit,paths:i}),n.push(...i)}catch(t){e.push(...i.map(e=>({path:e,error:t instanceof Error?t.message:`Import failed`})))}}return{imported:n,failed:e}},onSuccess:async t=>{await o.invalidateQueries({queryKey:[`skills`]}),a(e=>[...e,...t.imported]),c.select(t.failed.map(e=>e.path)),t.failed.length||e()}}),d=s.isPending||u.isPending;return(0,J.jsx)(M,{open:!0,onOpenChange:t=>!t&&!d&&e(),children:(0,J.jsxs)(A,{closeDisabled:d,className:`flex min-w-0 w-[min(800px,calc(100vw-2rem))] max-w-none max-h-[calc(var(--app-height,100dvh)-2rem)] flex-col gap-0 overflow-hidden p-0`,children:[(0,J.jsxs)(O,{className:`shrink-0 flex-row items-center gap-1 border-b px-4 py-3 pr-12 sm:px-6`,children:[(0,J.jsx)(j,{children:`Import from GitHub`}),(0,J.jsx)(oe,{label:`skill imports`,children:`GitHub repositories, owner/repo, skill-folder URLs and skills.sh links are supported. Private repositories use gh login on the execution host or ORC_GITHUB_TOKEN on the ORC server. Supporting files are included.`})]}),(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-4 py-4 sm:px-6`,"data-testid":`skill-import-body`,children:[(0,J.jsxs)(`form`,{className:`relative`,onSubmit:e=>{e.preventDefault(),!d&&t.trim()&&s.mutate(t.trim())},children:[(0,J.jsx)(D,{htmlFor:`skill-repository`,className:`sr-only`,children:`Repository or skills.sh link`}),(0,J.jsx)(I,{id:`skill-repository`,"data-testid":`skill-repository-input`,value:t,disabled:d,onChange:e=>{n(e.target.value),s.reset(),u.reset(),c.clear(),a([])},placeholder:`Repository or skills.sh link`,className:`pr-12`,autoFocus:!0}),(0,J.jsx)(b,{type:`submit`,"data-testid":`skill-discover`,"aria-label":`Discover skills`,title:`Find skills in this repository`,"aria-busy":s.isPending,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-full w-11 rounded-l-none`,disabled:d||!t.trim(),children:s.isPending?(0,J.jsx)(ne,{"aria-hidden":!0,className:`animate-spin`}):(0,J.jsx)(_e,{"aria-hidden":!0})})]}),s.data&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`p`,{className:`text-xs text-outline`,children:[s.data.skills.length,` skills found · `,s.data.commit.slice(0,8)]}),!s.data.skills.length&&(0,J.jsx)(`p`,{role:`status`,children:`No valid skills found in this source.`}),(0,J.jsx)(Ae,{resourceLabel:`new skills`,count:l.length,allSelected:c.allSelected,someSelected:c.someSelected,onSelectAll:c.selectAll,onClear:c.clear,disabled:d,children:null}),(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:s.data.skills.map(e=>(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-2`,"data-testid":`remote-skill`,"data-skill-name":e.name,children:[(0,J.jsxs)(`label`,{className:`flex min-h-11 min-w-0 flex-1 items-start gap-3 text-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,className:`mt-1 shrink-0`,"data-testid":`remote-skill-select`,checked:l.includes(e.path),disabled:d||e.installed||i.includes(e.path),onChange:()=>c.toggle(e.path)}),(0,J.jsxs)(`span`,{className:`min-w-0 text-sm wrap-break-word`,children:[(0,J.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(e.installed||i.includes(e.path))&&(0,J.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:`Already installed`}),(0,J.jsx)(`span`,{className:`mt-0.5 line-clamp-2 text-xs leading-4 text-outline`,children:e.description})]})]}),(0,J.jsxs)(he,{children:[(0,J.jsx)(de,{asChild:!0,children:(0,J.jsx)(b,{type:`button`,variant:`ghost`,size:`icon`,actionHelp:!1,"data-testid":`remote-skill-details`,"aria-label":`Details for ${e.name}`,className:`shrink-0`,children:(0,J.jsx)(N,{"aria-hidden":!0})})}),(0,J.jsxs)(ue,{"data-testid":`remote-skill-details-content`,"aria-label":`Details for ${e.name}`,align:`end`,className:`max-h-[60dvh] w-96 max-w-[calc(100vw-2rem)] overflow-y-auto space-y-2 text-sm wrap-break-word`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:e.name}),(0,J.jsx)(`p`,{children:e.description}),(0,J.jsx)(`p`,{className:`text-xs text-outline`,children:e.path||`Repository root`})]})]})]},e.path))}),s.data.issues.map(e=>(0,J.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[e.path,`: `,e.error]},e.path))]}),(s.error||u.error)&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:(s.error||u.error)?.message}),!!u.data?.failed.length&&(0,J.jsxs)(`div`,{role:`alert`,className:`text-sm text-destructive`,children:[(0,J.jsxs)(`p`,{children:[u.data.imported.length,` imported; `,u.data.failed.length,` failed. Failed selections retained for retry.`]}),u.data.failed.map(e=>(0,J.jsxs)(`p`,{children:[e.path||`Repository root`,`: `,e.error]},e.path))]})]}),(0,J.jsxs)(k,{className:`shrink-0 border-t px-4 py-3 sm:px-6`,children:[(0,J.jsx)(b,{variant:`ghost`,disabled:d,onClick:e,children:`Cancel`}),(0,J.jsx)(b,{"data-testid":`skill-import-submit`,disabled:d||!s.data||!l.length,onClick:()=>u.mutate(),children:u.isPending?`Importing…`:`Import selected${l.length?` (${l.length})`:``}`})]})]})})}function Q({name:e,scope:t,mutation:n}){let i=r(),[a,o]=(0,G.useState)(``),s=p({queryKey:[`skill-history`,e,t],queryFn:()=>S.skills.history(e,t)}),c=_({mutationFn:t=>{if(!n)throw Error(`No active instruction edit`);return S.skills.revert(e,{project_id:n.project_id,change_id:t,expected_change_id:n.id,reason:a.trim()})},onSuccess:()=>{i.invalidateQueries({queryKey:[`skill`]}),i.invalidateQueries({queryKey:[`skills`]}),i.invalidateQueries({queryKey:[`skill-history`]}),o(``)}});return!s.data?.changes.length&&!s.error?null:(0,J.jsxs)(`section`,{"data-testid":`skill-history-panel`,className:`mb-5 space-y-3`,children:[n&&(0,J.jsxs)(`p`,{"data-testid":`skill-mutated-label`,className:`text-xs text-primary`,children:[`Mutated · `,n.project_id?`Project`:`Global`,` ·`,` `,new Date(n.updated_at*1e3).toLocaleString(),` · `,n.author]}),(0,J.jsx)(`h3`,{className:`text-sm font-medium`,children:`Instruction history`}),(0,J.jsx)(I,{"data-testid":`skill-revert-reason`,"aria-label":`Reason for reverting instructions`,value:a,onChange:e=>o(e.target.value),placeholder:`Reason for reverting...`}),s.error&&(0,J.jsx)(`p`,{role:`alert`,children:s.error.message}),c.error&&(0,J.jsx)(`p`,{role:`alert`,children:c.error.message}),s.data?.changes.map(e=>(0,J.jsxs)(`details`,{"data-testid":`skill-history-change`,className:`border-b border-outline-variant p-3`,children:[(0,J.jsxs)(`summary`,{className:`text-xs cursor-pointer`,children:[e.action,` · `,e.reason,` · `,e.author,` ·`,` `,(0,J.jsx)(`time`,{dateTime:new Date(e.created_at*1e3).toISOString(),children:new Date(e.created_at*1e3).toLocaleString()})]}),(0,J.jsx)($,{before:e.previous_raw,after:e.raw}),(0,J.jsx)(b,{"data-testid":`skill-revert-change`,size:`sm`,variant:`outline`,disabled:!a.trim()||c.isPending,onClick:()=>c.mutate(e.id),children:`Restore instructions before this change`})]},e.id))]})}function $({before:e,after:t}){let[n,r]=(0,G.useState)(!1),i=le(e,t).filter(e=>e.added||e.removed);return(0,J.jsxs)(`div`,{className:`my-3 space-y-2`,children:[(0,J.jsx)(`pre`,{"data-testid":`skill-change-diff`,className:`text-xs whitespace-pre-wrap break-all`,children:i.length===0?`No instruction changes`:i.map(e=>(0,J.jsxs)(`span`,{className:e.added?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,children:[e.value.split(/(?<=\n)/).filter(Boolean).map(t=>`${e.added?`+ `:`- `}${t}`).join(``),!e.value.endsWith(`
|
|
2
|
-
`)&&`
|
|
3
|
-
`]},`${i.indexOf(e)}-${e.added?`added`:`removed`}`))}),(0,J.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>r(!n),children:n?`Hide full skill`:`Show full skill`}),n&&(0,J.jsxs)(`div`,{"data-testid":`skill-change-full`,children:[(0,J.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:`Before`}),(0,J.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-all`,children:e}),(0,J.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:`After`}),(0,J.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-all`,children:t})]})]})}function qe({name:e}){let t=r(),[n,i]=(0,G.useState)(!1),a=p({queryKey:[`skill-origin`,e],queryFn:()=>S.skills.origin(e)}),o=_({mutationFn:t=>S.skills.sync(e,t),onSuccess:async n=>{i(!1),n.applied&&await Promise.all([t.invalidateQueries({queryKey:[`skill`,e]}),t.invalidateQueries({queryKey:[`skills`]}),t.invalidateQueries({queryKey:[`skill-origin`,e]})])}});if(a.error)return(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a.error.message});if(!a.data)return null;let s=o.data,c=s&&!s.applied&&s.conflicts.length>0;return(0,J.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,J.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Imported from`,` `,(0,J.jsx)(`a`,{className:`text-primary underline`,href:`https://github.com/${a.data.repository}/tree/${encodeURIComponent(a.data.ref===`HEAD`?a.data.commit:a.data.ref)}/${a.data.path}`,target:`_blank`,rel:`noreferrer`,children:a.data.repository}),` `,`· `,a.data.commit.slice(0,8)]}),(0,J.jsx)(b,{"data-testid":`skill-sync`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({}),children:o.isPending?`Syncing…`:`Sync from GitHub`}),s?.applied&&(0,J.jsx)(`p`,{role:`status`,"data-testid":`skill-sync-status`,className:`text-xs`,children:s.changed.length?`Synced ${s.changed.length} files. Local edits preserved outside confirmed conflicts.`:`Up to date. Local edits preserved.`}),c&&(0,J.jsxs)(`div`,{"data-testid":`skill-sync-conflicts`,className:`space-y-2`,children:[(0,J.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`Sync paused. Both you and GitHub changed these files:`}),(0,J.jsx)(`ul`,{className:`text-xs space-y-1`,children:s.conflicts.map(e=>(0,J.jsx)(`li`,{children:e},e))}),(0,J.jsx)(b,{"data-testid":`skill-sync-review-override`,variant:`outline`,size:`sm`,onClick:()=>i(!0),children:`Review override`})]}),o.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o.error.message}),(0,J.jsx)(M,{open:n,onOpenChange:e=>!o.isPending&&i(e),children:(0,J.jsxs)(A,{children:[(0,J.jsx)(O,{children:(0,J.jsx)(j,{children:`Replace conflicting local edits?`})}),(0,J.jsxs)(`p`,{className:`text-sm`,children:[`GitHub's version at `,s?.commit.slice(0,8),` will replace or remove these files. Your other local edits will be kept. The current skill folder will be backed up.`]}),(0,J.jsx)(`ul`,{className:`text-sm space-y-1`,children:s?.conflicts.map(e=>(0,J.jsx)(`li`,{children:e},e))}),(0,J.jsxs)(k,{children:[(0,J.jsx)(b,{variant:`ghost`,disabled:o.isPending,onClick:()=>i(!1),children:`Keep local edits`}),(0,J.jsx)(b,{"data-testid":`skill-sync-confirm-override`,disabled:o.isPending,onClick:()=>s&&o.mutate({override:!0,expectedCommit:s.commit,expectedRevision:s.revision}),children:o.isPending?`Syncing…`:`Replace listed files`})]})]})})]})}function Je(e){return p({queryKey:[`skills`,e],queryFn:()=>S.skills.list(e)})}function Ye(){return p({queryKey:[`skill-visibility`],queryFn:()=>S.skills.visibility()})}function Xe(){let e=r();return _({mutationFn:e=>S.skills.setVisibility(e),onSuccess:t=>{e.setQueryData([`skill-visibility`],t),e.invalidateQueries({queryKey:[`skills`]})}})}function Ze(e,t,n={}){return p({queryKey:[`skill`,e,t,n],queryFn:()=>S.skills.get(e,t,n),enabled:!!e})}function Qe(){let e=r();return _({mutationFn:e=>S.skills.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`skills`]})})}var $e={default:`none`,asc:`ascending`,desc:`descending`},et={default:K,asc:L,desc:ce},tt=[{value:`all`,label:`All`},{value:`builtin`,label:`Built-in`},{value:`user`,label:`User`}],nt={sync:`synced`,delete:`deleted`,hide:`hidden`,show:`shown`},rt={builtin:`text-muted-foreground`,user:`text-muted-foreground`};function it({projectId:e}){let t=se(`xl`),n=ke(e),{data:i}=ge(),[a,o]=(0,G.useState)(!1),s=n===`all`||n===`unassigned`?{scope:`global`}:{project_id:n},c=n===`all`?{scope:`all`}:s,[l,u]=Ce(`skillQuery`,``),[d,f]=(0,G.useState)(l),[p,m]=Ce(`source`,`all`,[`all`,`builtin`,`user`]),[h,g]=Ce(`skillRepositorySort`,`default`,[`default`,`asc`,`desc`]),v=et[h];(0,G.useEffect)(()=>f(l),[l]);let y=(0,G.useRef)(u);y.current=u,(0,G.useEffect)(()=>{if(d===l)return;let e=window.setTimeout(()=>y.current(d,{replace:!0}),250);return()=>window.clearTimeout(e)},[d,l]);let{selectedId:x,openDetail:T,closeDetail:D}=Se(`/skills`,`skillName`),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(!1),[ne,ae]=(0,G.useState)(!1),[ce,le]=(0,G.useState)(!1),P=Ye(),F=Xe(),fe=JSON.stringify([n,l,p]),[pe,me]=(0,G.useState)({scope:fe,offset:0}),L=pe.scope===fe?pe.offset:0,{data:R,isLoading:ve,error:Ae,refetch:Me}=Je({...c,q:l||void 0,source:p===`all`?void 0:p,include_hidden:!0,limit:30,offset:L}),V=R?.skills,Ne=d!==l,H=e=>e.project_ids?.length?e.project_ids.map(e=>i?.find(t=>t.id===e)?.name??e).join(`, `):`Global`,Pe=r(),Fe=(V??[]).filter(e=>e.source===`user`),U=Le({queries:Fe.map(e=>({queryKey:[`skill-origin`,e.name],queryFn:()=>S.skills.origin(e.name)}))}),Ie=Fe.filter((e,t)=>!!U[t]?.data).map(e=>e.name),W=new Map(Fe.map((e,t)=>[e.name,U[t]?.data?.repository])),Re=[...V??[]];!l&&h!=="default"&&Re.sort((e,t)=>{let n=W.get(e.name),r=W.get(t.name);if(!n&&r)return 1;if(n&&!r)return-1;let i=(n??``).localeCompare(r??``,void 0,{sensitivity:`base`});return i?h===`asc`?i:-i:e.name.localeCompare(t.name)});let K=JSON.stringify([n,l,d,p,L]),ze=(0,G.useRef)(K);ze.current=K;let q=je((V??[]).map(e=>e.name),K),He=(V??[]).filter(e=>q.selectedIds.includes(e.name)),Y=He.filter(e=>Ie.includes(e.name)),X=He.filter(e=>e.source===`user`),[We,Z]=(0,G.useState)(!1),Q=_({mutationFn:async({action:e,names:t,scope:n})=>{if(e===`hide`||e===`show`){let r=new Set(P.data?.hidden_skills??[]),i=new Set(P.data?.hidden_builtins??[]);for(let n of t)e===`hide`?r.add(n):(r.delete(n),i.delete(n));return await F.mutateAsync({hidden_skills:[...r],hidden_builtins:[...i]}),{action:e,scope:n,succeeded:t,failed:[]}}return{action:e,scope:n,...await te(t,async t=>{if(e===`delete`)return S.skills.delete(t);let n=await S.skills.sync(t);if(!n.applied)throw Error(`Conflicts: ${n.conflicts.join(`, `)}. Open this skill to review.`)})}},onSettled:async()=>{await Promise.all([Pe.invalidateQueries({queryKey:[`skills`]}),Pe.invalidateQueries({queryKey:[`skill`]}),Pe.invalidateQueries({queryKey:[`skill-origin`]})])}}),$=Q.data?.scope===K?Q.data:void 0;async function qe(e,t){let n=await Q.mutateAsync({action:e,names:t,scope:K});n.scope===ze.current&&q.select(n.failed.map(e=>e.id))}if(Ae)return(0,J.jsx)(be,{message:Ae.message,onRetry:()=>Me()});let Ze=(e,t=!1)=>(0,J.jsxs)(`button`,{type:`button`,role:`switch`,"aria-label":`${e.name} visible to agents`,"aria-checked":!e.discovery_hidden,"data-testid":`skill-visibility-${e.name}`,disabled:!P.data||F.isPending,className:t?`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-primary hover:bg-surface disabled:opacity-50`:`inline-flex min-h-11 items-center gap-2 text-xs text-primary disabled:opacity-50`,title:e.discovery_hidden?`Hidden from agent discovery. Still loadable by name and in flows.`:`Hide from agent discovery`,onClick:()=>{let t=new Set(P.data?.hidden_skills??[]),n=new Set(P.data?.hidden_builtins??[]);e.discovery_hidden?(t.delete(e.name),n.delete(e.name)):t.add(e.name),F.mutate({hidden_skills:[...t],hidden_builtins:[...n]})},children:[e.discovery_hidden?(0,J.jsx)(Be,{size:22,"aria-hidden":`true`,className:`text-muted-foreground`}):(0,J.jsx)(Ve,{size:22,"aria-hidden":`true`}),!t&&(e.discovery_hidden?`Hidden`:`Visible`),!t&&e.mutation&&` (Modified)`]});return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(xe,{title:`Skills`,meta:(V??[]).length,help:`Reusable agent instructions stored in skill folders. Import existing skills or create your own.`,action:(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsxs)(he,{open:ce,onOpenChange:le,children:[(0,J.jsx)(de,{asChild:!0,children:(0,J.jsxs)(b,{"data-testid":`skill-import-menu`,"aria-label":`Import or export skills`,size:`sm`,variant:`ghost`,children:[(0,J.jsx)(w,{size:14}),(0,J.jsx)(`span`,{className:`hidden sm:inline`,children:`Import / export`}),(0,J.jsx)(C,{size:12,className:`hidden sm:block`})]})}),(0,J.jsxs)(ue,{"aria-label":`Import or export skills`,align:`end`,className:`w-56 space-y-1 p-1`,children:[(0,J.jsxs)(b,{"data-testid":`import-skill-button`,size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{le(!1),j(!0)},children:[(0,J.jsx)(w,{size:12,className:`mr-1`}),` Import from GitHub`]}),(0,J.jsxs)(b,{"data-testid":`import-local-skills-button`,size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{le(!1),N(!0)},children:[(0,J.jsx)(w,{size:12,className:`mr-1`}),` Import from agents`]}),(0,J.jsxs)(b,{"data-testid":`export-skills-button`,size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{le(!1),ae(!0)},children:[(0,J.jsx)(ee,{size:12,className:`mr-1`}),` Export to agents`]}),(0,J.jsx)(`a`,{className:`block rounded-md px-3 py-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus`,href:`https://agentskills.io/specification`,target:`_blank`,rel:`noreferrer`,children:`Agent Skills specification`})]})]}),(0,J.jsxs)(b,{"data-testid":`new-skill-button`,size:`sm`,onClick:()=>k(!0),className:`font-label text-sm `,children:[(0,J.jsx)(ie,{size:12,className:`mr-1`}),` New skill`]})]})}),(P.error||F.error)&&(0,J.jsx)(`p`,{role:`alert`,className:`text-destructive text-xs mb-2`,children:(P.error||F.error)?.message}),R?.broken?.map(e=>(0,J.jsxs)(`p`,{role:`alert`,className:`text-destructive text-xs mb-2`,children:[e.path,`: `,e.error]},e.path)),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,J.jsxs)(E,{activeCount:Number(p!==`all`)+Number(h!=="default"),children:[(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:tt.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(e.value),"data-testid":`skill-source-${e.value}`,"aria-pressed":p===e.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${p===e.value?`bg-surface-highest text-on-surface border-transparent`:`bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:e.label},e.value))}),!t&&(0,J.jsxs)(b,{variant:`ghost`,size:`sm`,"data-testid":`skill-repository-sort`,"aria-label":`Sort by repository, ${h} order`,title:`Cycle repository order: ascending, descending, then default`,onClick:()=>g(h==="default"?`asc`:h===`asc`?`desc`:`default`),children:[(0,J.jsx)(v,{size:14}),`Repository order`]})]}),(0,J.jsxs)(`div`,{className:`relative order-first min-w-40 flex-1 lg:max-w-md`,children:[(0,J.jsx)(_e,{size:12,className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,J.jsx)(I,{"data-testid":`skill-search-input`,"aria-label":`Search skills`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&u(e.currentTarget.value),placeholder:`Search skills...`,className:`pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground`})]}),(!!V?.length||a)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 ${a?`basis-full md:basis-auto`:``}`,children:[(0,J.jsx)(b,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":a?`skills-select-displayed`:`skills-multiselect`,disabled:Q.isPending||a&&(!V?.length||Ne),"aria-pressed":a?q.allSelected:void 0,onClick:()=>{a?q.allSelected?q.clear():q.selectAll():o(!0)},children:a?q.allSelected?`Deselect displayed`:`Select displayed`:`Multiselect`}),a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(b,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`clear-selection`,disabled:Q.isPending||!q.selectedIds.length,onClick:q.clear,children:`Clear`}),(0,J.jsx)(b,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`skills-multiselect-exit`,disabled:Q.isPending,onClick:()=>{q.clear(),o(!1)},children:`Done`})]})]})]}),a&&q.selectedIds.length>0&&(0,J.jsxs)(`fieldset`,{className:`mb-3 flex flex-wrap items-center gap-2 border-y border-border py-1`,"data-testid":`bulk-actions`,"aria-label":`Selected skills and actions`,children:[(0,J.jsxs)(`span`,{className:`text-[13px]`,children:[q.selectedIds.length,` selected`]}),(0,J.jsxs)(`fieldset`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,J.jsx)(`legend`,{className:`sr-only`,children:`Agent discovery`}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-muted-foreground`,children:`Agent discovery`}),(0,J.jsx)(oe,{label:`Agent discovery`,children:`Hide excludes selected skills from agent discovery on this ORC installation. Hidden skills stay in Skills and can still be loaded by name or used in flows. Show restores discovery. This setting applies across projects.`}),(0,J.jsx)(b,{"data-testid":`skills-bulk-hide`,variant:`outline`,size:`sm`,disabled:Q.isPending||!P.data,onClick:()=>void qe(`hide`,q.selectedIds),children:`Hide`}),(0,J.jsx)(b,{"data-testid":`skills-bulk-show`,variant:`outline`,size:`sm`,disabled:Q.isPending||!P.data,onClick:()=>void qe(`show`,q.selectedIds),children:`Show`})]}),(0,J.jsx)(b,{"data-testid":`skills-bulk-sync`,variant:`outline`,size:`sm`,title:`Local edits are kept; conflicts need review`,disabled:Q.isPending||!Y.length||U.some(e=>e.isPending),onClick:()=>void qe(`sync`,Y.map(e=>e.name)),children:Q.isPending&&Q.variables?.action===`sync`?`Syncing…`:`Sync from GitHub${Y.length?` (${Y.length})`:``}`}),(0,J.jsx)(b,{"data-testid":`skills-bulk-delete`,variant:`outline`,size:`sm`,className:`text-destructive`,title:`Built-in skills cannot be deleted`,disabled:Q.isPending||!X.length,onClick:()=>Z(!0),children:`Delete${X.length?` (${X.length})`:``}`})]}),(0,J.jsx)(ye,{open:We,title:`Delete skills`,description:`Delete ${X.map(e=>e.name).join(`, `)}? This removes the skill folders and cannot be undone.`,isPending:Q.isPending,onCancel:()=>Z(!1),onConfirm:()=>{Z(!1),qe(`delete`,X.map(e=>e.name))}}),U.some(e=>e.error)&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not check GitHub origins: `,U.find(e=>e.error)?.error?.message]}),$&&(0,J.jsxs)(`div`,{"data-testid":`skills-bulk-result`,role:`status`,className:`mb-3 text-sm`,children:[(0,J.jsxs)(`p`,{children:[$.succeeded.length,` `,nt[$.action],$.failed.length?`; ${$.failed.length} need attention.`:`.`]}),$.failed.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`block text-left text-destructive underline`,onClick:()=>T(e.id),children:[e.id,`: `,e.error]},e.id))]}),ve?(0,J.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,J.jsx)(re,{className:`h-10 w-full bg-surface-highest`},t))}):(V??[]).length===0?(0,J.jsx)(we,{message:l?`No skills match your search`:`No skills found`}):t?(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsxs)(Oe,{children:[(0,J.jsx)(Te,{children:(0,J.jsxs)(De,{className:`border-b border-outline-variant hover:bg-transparent`,children:[a&&(0,J.jsx)(z,{className:`w-12`,children:(0,J.jsx)(`span`,{className:`sr-only`,children:`Select skills`})}),(0,J.jsx)(z,{className:`font-label text-sm text-muted-foreground`,children:`Name`}),(0,J.jsx)(z,{className:`font-label text-sm text-muted-foreground`,children:`Description`}),(0,J.jsx)(z,{className:`font-label text-sm text-muted-foreground w-24`,children:`Source`}),(0,J.jsx)(z,{className:`text-sm text-muted-foreground`,children:`Scope`}),(0,J.jsx)(z,{"data-testid":`skill-repository-header`,"aria-sort":$e[h],children:(0,J.jsxs)(`button`,{type:`button`,"data-testid":`skill-repository-sort`,className:`flex min-h-11 items-center gap-2 text-sm text-muted-foreground hover:text-on-surface`,onClick:()=>{g(h==="default"?`asc`:h===`asc`?`desc`:`default`)},title:`Sort by GitHub repository: ascending, descending, then default order`,children:[`GitHub repository `,(0,J.jsx)(v,{size:14,"aria-hidden":`true`})]})}),(0,J.jsx)(z,{className:`text-xs text-muted-foreground`,children:`Agent discovery`})]})}),(0,J.jsx)(Ee,{children:Re.map(e=>(0,J.jsxs)(De,{"data-testid":`skill-row`,"data-skill-name":e.name,className:`border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer`,onClick:()=>T(e.name),children:[a&&(0,J.jsx)(B,{onClick:e=>e.stopPropagation(),children:(0,J.jsx)(`label`,{className:`flex size-11 items-center justify-center`,children:(0,J.jsx)(`input`,{type:`checkbox`,"data-testid":`skill-select`,"aria-label":`Select ${e.name}`,checked:q.selectedIds.includes(e.name),disabled:Q.isPending||Ne,onChange:()=>q.toggle(e.name),className:`size-4 accent-primary`})})}),(0,J.jsxs)(B,{className:`font-body text-sm font-medium text-on-surface`,children:[(0,J.jsx)(`button`,{type:`button`,"data-testid":`skill-open`,className:`min-h-11 text-left hover:text-primary`,onClick:t=>{t.stopPropagation(),T(e.name)},children:e.name}),e.mutation&&(0,J.jsx)(`span`,{className:`ml-2 text-primary text-xs`,title:`Instructions were edited`,children:`Modified`})]}),(0,J.jsx)(B,{className:`font-body text-sm text-muted-foreground max-w-md truncate`,children:e.description||`—`}),(0,J.jsx)(B,{"data-testid":`skill-source-cell`,children:(0,J.jsx)(`span`,{className:`inline-flex py-0.5 font-label text-sm ${rt[e.source]}`,children:e.source})}),(0,J.jsx)(B,{"data-testid":`skill-scope-cell`,title:H(e),className:`max-w-48 truncate text-sm text-muted-foreground`,children:H(e)}),(0,J.jsx)(B,{"data-testid":`skill-repository-cell`,onClick:e=>e.stopPropagation(),className:`max-w-56 truncate text-sm text-muted-foreground`,children:W.get(e.name)?(0,J.jsx)(`a`,{"data-testid":`skill-repository-link`,href:`https://github.com/${W.get(e.name)}`,target:`_blank`,rel:`noreferrer`,className:`text-primary hover:underline`,title:W.get(e.name),children:W.get(e.name)}):`—`}),(0,J.jsx)(B,{onClick:e=>e.stopPropagation(),children:Ze(e)})]},e.name))})]})}):(0,J.jsx)(`div`,{className:`divide-y divide-outline-variant`,children:Re.map(e=>(0,J.jsxs)(`div`,{"data-testid":`skill-row`,"data-skill-name":e.name,className:`flex min-w-0 items-center gap-1 py-2`,children:[a&&(0,J.jsx)(`label`,{className:`flex size-11 shrink-0 items-center justify-center`,children:(0,J.jsx)(`input`,{type:`checkbox`,"data-testid":`skill-select`,"aria-label":`Select ${e.name}`,checked:q.selectedIds.includes(e.name),disabled:Q.isPending||Ne,onChange:()=>q.toggle(e.name),className:`size-4 accent-primary`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`button`,{type:`button`,"data-testid":`skill-open`,className:`block min-h-11 w-full min-w-0 text-left text-sm`,title:e.name,onClick:()=>T(e.name),children:[(0,J.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),e.description&&(0,J.jsx)(`span`,{className:`block truncate text-muted-foreground`,children:e.description})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{"data-testid":`skill-source-cell`,className:`shrink-0`,children:e.source}),(0,J.jsxs)(`span`,{"data-testid":`skill-scope-cell`,title:H(e),className:`min-w-0 truncate`,children:[(0,J.jsx)(`span`,{className:`sr-only`,children:`Scope: `}),H(e)]}),e.mutation&&(0,J.jsx)(`span`,{className:`shrink-0 text-primary`,children:`Modified`}),(0,J.jsx)(`span`,{"data-testid":`skill-repository-cell`,className:`min-w-0 flex-1 truncate`,children:W.get(e.name)?(0,J.jsx)(`a`,{"data-testid":`skill-repository-link`,href:`https://github.com/${W.get(e.name)}`,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,title:W.get(e.name),children:W.get(e.name)}):null})]})]}),Ze(e,!0)]},e.name))}),R&&R.total>30&&(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-4`,"data-testid":`skills-pagination`,children:[(0,J.jsxs)(`span`,{className:`text-sm text-muted-foreground`,"data-testid":`skills-page-summary`,children:[L+1,`–`,Math.min(L+R.skills.length,R.total),` of`,` `,R.total]}),(0,J.jsx)(b,{variant:`outline`,size:`sm`,"data-testid":`skills-previous`,disabled:L===0||ve,onClick:()=>me({scope:fe,offset:Math.max(0,L-30)}),children:`Previous`}),(0,J.jsx)(b,{variant:`outline`,size:`sm`,"data-testid":`skills-next`,disabled:R.next_offset===null||ve,onClick:()=>me({scope:fe,offset:R.next_offset??L}),children:`Next`})]}),(0,J.jsx)(at,{scope:s,allProjects:n===`all`,projects:i??[],skillName:x,open:!!x,onClose:D},x),O&&(0,J.jsx)(ot,{open:O,onClose:()=>k(!1)}),A&&(0,J.jsx)(Ke,{onClose:()=>j(!1)}),M&&(0,J.jsx)(Ge,{onClose:()=>N(!1)}),ne&&(0,J.jsx)(Ue,{onClose:()=>ae(!1)})]})}function at({skillName:e,scope:t,allProjects:n,projects:i,open:a,onClose:o}){let[s,c]=Ce(`skillProject`,``),l=(0,G.useId)(),u=p({queryKey:[`skill-projects`,e],queryFn:()=>S.skills.projects(e),enabled:n&&a&&!!e,staleTime:1/0,refetchOnMount:`always`,retry:!1}),d=[...new Set(u.data?.project_ids??[])].sort(),f=d.includes(s)?s:d[0],m=n?f?{project_id:f}:{scope:`global`}:t,h=!n||u.isSuccess&&!u.isFetching,g=h?e:null,{data:_,isLoading:v,error:y,refetch:b}=Ze(g,void 0,m),x=_,[C,w]=Ce(`skillFile`,`SKILL.md`),T=Ze(g,C??`SKILL.md`,m),E=T.data,ee=r(),[O,k]=(0,G.useState)(!1),A=`skill:${m.project_id??`global`}:${e}:${C??`SKILL.md`}`,j=e=>e?i.find(t=>t.id===e)?.name??e:`Global`,M=n&&u.error||y;function te(e){return(e??`SKILL.md`)===(C??`SKILL.md`)?!0:Me(A)?(w(e??`SKILL.md`),!0):!1}let N=x?(0,J.jsx)(He,{files:[`SKILL.md`,...(x.files??[]).map(e=>e.name)],selected:C??`SKILL.md`,onSelect:e=>te(e===`SKILL.md`?void 0:e),testId:`skill-file`,entryTestId:`skill-show-entry`}):null;return(0,J.jsx)(R,{open:a,onOpenChange:e=>!e&&Me(A)&&o(),children:(0,J.jsxs)(fe,{defaultWidth:1120,resizeKey:`skills`,children:[(0,J.jsxs)(me,{children:[(0,J.jsx)(pe,{children:x?.name??`Skill Details`}),x?.description&&(0,J.jsx)(`p`,{className:`font-body text-sm text-muted-foreground mt-1`,children:x.description}),h&&(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:n&&d.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{htmlFor:l,children:`Instructions for`}),(0,J.jsx)(`select`,{id:l,"aria-label":`Instructions for`,"data-testid":`skill-instruction-project`,className:`form-control form-control-single w-auto max-w-full`,value:f,onChange:e=>{let t=e.target.value;t!==f&&d.includes(t)&&Me(A)&&c(t)},children:d.map(e=>(0,J.jsx)(`option`,{value:e,children:j(e)},e))})]}):(0,J.jsxs)(`span`,{"data-testid":`skill-instruction-context`,children:[`Instructions for `,j(m.project_id)]})})]}),(0,J.jsx)(P,{children:(0,J.jsxs)(J.Fragment,{children:[h&&e&&x&&(0,J.jsx)(Q,{name:e,scope:m,mutation:x.mutation},m.project_id??`global`),h&&e&&x&&(0,J.jsx)(qe,{name:e}),M?(0,J.jsx)(be,{message:M.message,onRetry:()=>void(u.error?u.refetch():b())}):!h||v||!x?(0,J.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,]].map((e,t)=>(0,J.jsx)(re,{className:`h-8 w-full bg-surface-highest`},t))}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,J.jsx)(ve,{label:`Source`,children:(0,J.jsx)(`span`,{className:`inline-flex py-0.5 font-label text-sm ${rt[x.source]}`,children:x.source})}),(0,J.jsx)(ve,{label:`Path`,children:(0,J.jsx)(`code`,{className:`font-mono text-sm text-muted-foreground break-all`,children:x.path})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:C??`SKILL.md`}),(0,J.jsxs)(`div`,{className:`overflow-hidden`,children:[E?.encoding===`base64`&&(0,J.jsx)(`div`,{className:`p-3`,children:N}),T.error?(0,J.jsx)(`p`,{role:`alert`,children:T.error.message}):T.isLoading?(0,J.jsx)(`p`,{children:`Loading...`}):E?.encoding===`base64`?(0,J.jsx)(F,{path:C??`SKILL.md`,value:E?.content??``,readOnly:!0,hidePreview:!0,height:400,testId:`skill-file-content`}):(0,J.jsx)(V,{compact:!0,documentId:A,expanded:O,onExpandedChange:k,navigation:N,path:C??`SKILL.md`,content:E?.content??``,testId:`skill-file-content`,onSave:x.source===`user`&&E?.encoding===`utf8`?async(e,t)=>{let n=C??`SKILL.md`;return x.mutation&&n===`SKILL.md`?await S.skills.updateInstructions(x.name,{project_id:m.project_id??null,content:e,expected_content:t,reason:`Manual instruction edit`,author:`human`}):await S.skills.editFile(x.name,{path:n,content:e,expectedContent:t}),await ee.invalidateQueries({queryKey:[`skill`,x.name]}),await ee.invalidateQueries({queryKey:[`skills`]}),await ee.invalidateQueries({queryKey:[`skill-history`,x.name]}),e}:void 0},A),E?.encoding===`base64`&&(0,J.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:`Binary asset shown as base64 (read-only).`})]})]})]})]})})]})})}function ot({open:e,onClose:t}){let[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)(``),o=Qe(),[s,c]=(0,G.useState)([]),[l,u]=(0,G.useState)(),[d,f]=(0,G.useState)(!1),p=!!(n||i||s.length);(0,G.useEffect)(()=>{if(!p)return;function e(e){e.preventDefault(),e.returnValue=``}return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[p]);function m(){o.isPending||d||(!p||window.confirm(`Discard this unsaved skill?`))&&t()}async function h(e){if(e?.length){f(!0),u(void 0);try{let t=(await U(e)).map(e=>({...e,encoding:e.encoding??`utf8`,id:crypto.randomUUID()})),n=t.find(e=>e.path===`SKILL.md`);if(!n)throw Error(`Choose a skill folder containing SKILL.md`);if(n.encoding!==`utf8`)throw Error(`SKILL.md must be UTF-8 text`);a(n.content),r(e[0].webkitRelativePath.split(`/`)[0]),c(t.filter(e=>e!==n))}catch(e){u(e.message)}finally{f(!1)}}}let g=()=>{!n.trim()||!i.trim()||o.isPending||d||s.some(e=>!e.path.trim())||o.mutate({name:n.trim(),content:i.trim(),files:s.map(({path:e,content:t,encoding:n})=>({path:e,content:t,encoding:n}))},{onSuccess:t})};return(0,J.jsx)(M,{open:e,onOpenChange:e=>!e&&m(),children:(0,J.jsxs)(A,{className:`bg-surface border-outline-variant w-[calc(100%-1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto`,children:[(0,J.jsx)(O,{children:(0,J.jsx)(j,{className:`font-headline text-base text-on-surface`,children:`New skill`})}),(0,J.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`space-y-3 mt-2`,children:[(0,J.jsx)(D,{htmlFor:`skill-folder-input`,children:`Import skill folder`}),(0,J.jsx)(I,{id:`skill-folder-input`,"data-testid":`skill-folder-input`,type:`file`,multiple:!0,webkitdirectory:``,onChange:e=>void h(e.target.files)}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(D,{className:`font-label text-sm text-muted-foreground`,children:`Name *`}),(0,J.jsx)(I,{"aria-label":`Name`,"data-testid":`skill-name-input`,value:n,onChange:e=>r(e.target.value),placeholder:`my-skill`,className:`bg-background text-on-surface font-body text-sm`,autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(D,{className:`font-label text-sm text-muted-foreground`,children:`SKILL.md *`}),(0,J.jsx)(T,{compact:!0,testId:`skill-content-input`,path:`SKILL.md`,value:i,onChange:a,onSave:g})]}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(b,{"data-testid":`skill-add-file`,type:`button`,variant:`outline`,onClick:()=>c([...s,{id:crypto.randomUUID(),path:``,content:``,encoding:`utf8`}]),children:`Add file`}),s.map(e=>(0,J.jsxs)(`div`,{"data-testid":`skill-supporting-file`,className:`space-y-2 border border-outline-variant p-3`,children:[(0,J.jsx)(I,{"data-testid":`skill-file-path-input`,"aria-label":`File path`,placeholder:`references/guide.md or scripts/check.py`,value:e.path,onChange:t=>c(s.map(n=>n.id===e.id?{...n,path:t.target.value}:n))}),(0,J.jsx)(F,{compact:!0,testId:`skill-file-content-input`,path:e.path||`supporting.txt`,readOnly:e.encoding===`base64`,label:`Content of ${e.path||`supporting file`}`,value:e.content,height:180,onChange:t=>c(s.map(n=>n.id===e.id?{...n,content:t}:n))}),e.encoding===`base64`&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Binary asset (base64)`}),(0,J.jsx)(b,{type:`button`,variant:`ghost`,onClick:()=>c(s.filter(t=>t.id!==e.id)),children:`Remove file`})]},e.id))]}),(l||o.error)&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:l??o.error?.message}),(0,J.jsxs)(k,{children:[(0,J.jsx)(b,{type:`button`,variant:`ghost`,size:`sm`,onClick:m,className:`font-label text-sm text-muted-foreground`,children:`Cancel`}),(0,J.jsx)(b,{"data-testid":`skill-submit`,type:`submit`,size:`sm`,disabled:d||o.isPending||!n.trim()||!i.trim()||s.some(e=>!e.path.trim()),className:`font-label text-sm `,children:o.isPending?`Creating...`:`Create`})]})]})]})})}export{it as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{m as r,t as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as a}from"./button-By-NN7c7.js";import{h as o}from"./client-954dj6K2.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-cyLFVkkB.js";import{t as f}from"./textarea-CovStda2.js";import{t as p}from"./label-Bm_d0NKL.js";import{t as m}from"./Markdown-D-AaJ4bU.js";import{a as h,i as g,o as _}from"./dialog-DNIYhwi4.js";import{A as v,B as y,C as b,D as x,Dt as S,E as C,Et as w,F as T,Fr as E,H as ee,I as D,L as O,M as k,N as A,O as j,Or as te,P as M,R as N,St as P,T as F,Tt as I,Z as L,b as R,dt as ne,ei as z,ft as re,gr as B,gt as ie,hr as V,ht as ae,j as oe,jr as se,k as H,kt as U,mr as W,mt as ce,ot as le,pr as G,ut as ue,w as de,wt as fe,x as pe,xt as me,yr as he,z as K,zr as q}from"./index-XIDqokJX.js";import{t as ge}from"./ConfirmDialog-B5es4nUp.js";import{t as _e}from"./PriorityBadge-DOfXvpzs.js";import{t as ve}from"./StatusBadge-CKL0hTFN.js";import{i as J,n as ye,r as be,s as xe}from"./live-sessions-C6D_vHcN.js";import{t as Se}from"./ErrorState-DB0nWfcc.js";import{s as Ce}from"./useSessions-DiUU2FN8.js";import{t as we}from"./ResumeActions-e6YpUhEq.js";var Te={name:`circle-stop`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]],aliases:[`stop-circle`]};Te.node;var Ee=o(Te),De={name:`user-check`,size:24,node:[[`path`,{d:`m16 11 2 2 4-4`,key:`9rsbq5`}],[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};De.node;var Oe=o(De),Y=e(t(),1),X=n(),ke=new Set([`task_id`,`task_title`,`project_id`,`skill_name`,`required_review`,`max_review_rounds`]),Ae={running:`bg-primary/15 text-primary border-primary/40`,completed:`bg-secondary/15 text-secondary border-secondary/40`,halted:`bg-error/15 text-error border-error/40`,cancelled:`bg-surface-highest text-outline border-outline-variant`},je={pending:`text-primary`,running:`text-primary`,awaiting_human:`text-tertiary`,succeeded:`text-secondary`,failed:`text-error`,cancelled:`text-outline`,skipped:`text-outline`};function Z({children:e,className:t}){return(0,X.jsx)(`span`,{className:`inline-flex px-2 py-0.5 font-label text-xs rounded-md border ${t??`bg-surface-highest border-surface-highest text-on-surface-variant`}`,children:e})}function Me({taskId:e}){let{data:t,isLoading:n}=x(e),[r,i]=(0,Y.useState)(null);return n?(0,X.jsx)(`div`,{className:`font-body text-sm text-outline`,children:`Loading flow…`}):t?(0,X.jsx)(Ne,{run:t,taskId:e,selectedNodeId:r,onSelectNode:e=>i(t=>t===e?null:e)}):(0,X.jsx)(`div`,{className:`font-body text-sm text-outline`,"data-testid":`flow-run-empty`,children:`No flow has run on this task yet.`})}function Ne({run:e,taskId:t,selectedNodeId:n,onSelectNode:r}){let i=(0,Y.useMemo)(()=>N(e.definition),[e.definition]),o=(0,Y.useMemo)(()=>D(e),[e]),s=(0,Y.useMemo)(()=>oe(e),[e]),c=F(),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=Object.entries(e.vars).filter(([e])=>!ke.has(e));return(0,X.jsxs)(`div`,{className:`space-y-4`,"data-testid":`flow-run-panel`,"data-flow-status":e.status,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[e.flow_source===`task`?(0,X.jsx)(`span`,{className:`font-body text-sm text-on-surface truncate`,"data-testid":`flow-run-name`,children:e.flow_name}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(!0),className:`font-body text-sm text-primary hover:underline truncate`,"data-testid":`flow-run-name`,children:e.flow_name}),(0,X.jsx)(Z,{children:e.flow_source}),(0,X.jsx)(Z,{className:Ae[e.status],children:e.status})]}),e.status===`running`&&(0,X.jsxs)(a,{variant:`ghost`,"data-testid":`flow-halt-button`,size:`sm`,onClick:()=>u(!0),className:`font-label text-xs bg-error/10 text-error border border-error/30 hover:bg-error/20 min-h-11 sm:min-h-9 px-3`,children:[(0,X.jsx)(Ee,{size:11,className:`mr-1`}),`Halt`]})]}),e.halt_reason&&(0,X.jsxs)(`div`,{className:`p-2 rounded-lg border border-border bg-transparent space-y-0.5`,"data-testid":`flow-halt-reason`,"data-halt-reason":e.halt_reason,children:[(0,X.jsxs)(`div`,{className:`font-label text-xs font-medium text-error`,children:[`Halted: `,e.halt_reason.replace(/_/g,` `)]}),e.halt_description&&(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface-variant`,children:e.halt_description})]}),i?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(H,{definition:i,states:o,selectedNodeId:n,onSelectNode:r}),(0,X.jsx)(v,{})]}):(0,X.jsx)(`div`,{className:`font-body text-sm text-outline`,children:`This run did not record a readable definition, so its graph cannot be drawn.`}),s&&(0,X.jsx)(Pe,{taskId:t,nodeRun:s,definition:i,isHalting:c.isPending}),i&&n&&(0,X.jsx)(Fe,{definition:i,nodeId:n}),(0,X.jsx)(Ie,{run:e,selectedNodeId:n,onSelectNode:r}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1`,children:[(0,X.jsxs)(Q,{label:`Executions`,children:[e.node_executions,i?.limits.max_node_executions?` / ${i.limits.max_node_executions}`:``]}),(0,X.jsx)(Q,{label:`Elapsed`,children:A(e.started_at,e.ended_at)}),(0,X.jsx)(Q,{label:`Started`,children:M(e.started_at)}),(0,X.jsx)(Q,{label:`Ended`,children:M(e.ended_at)})]}),p.length>0&&(0,X.jsxs)(`div`,{className:`space-y-1`,"data-testid":`flow-run-vars`,children:[(0,X.jsx)(`div`,{className:`font-label text-xs font-medium text-outline`,children:`Run vars`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(([e,t])=>(0,X.jsxs)(Z,{children:[e,`=`,JSON.stringify(t)]},e))})]}),(0,X.jsx)(de,{flowName:d?e.flow_name:null,open:d,onClose:()=>f(!1)}),(0,X.jsx)(ge,{open:l,title:`Halt Flow`,description:`Stop flow "${e.flow_name}" and kill any live agent sessions for this task? The task keeps its current status.`,confirmLabel:`Halt`,variant:`destructive`,isPending:c.isPending,onConfirm:()=>c.mutate({taskId:t,reason:`halted from the web dashboard`},{onSuccess:()=>u(!1)}),onCancel:()=>u(!1)})]})}function Q({label:e,children:t}){return(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsx)(`div`,{className:`font-label text-[10px] font-medium text-outline`,children:e}),(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface-variant`,children:t})]})}function Pe({taskId:e,nodeRun:t,definition:n,isHalting:r}){let i=(0,Y.useMemo)(()=>n?O(n,t.node_id):[],[n,t.node_id]),o=C(),[m,h]=(0,Y.useState)(i[0]??``),[g,_]=(0,Y.useState)(``),v=m.trim();return(0,X.jsxs)(`div`,{className:`p-3 rounded-lg border border-border bg-transparent space-y-3`,"data-testid":`flow-gate-form`,"data-gate-node":t.node_id,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-label text-xs font-medium text-tertiary`,children:[(0,X.jsx)(Oe,{size:12}),`Waiting for you at “`,t.node_id,`”`]}),n?.nodeById[t.node_id]?.prompt&&(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface whitespace-pre-wrap`,children:n.nodeById[t.node_id]?.prompt}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Outcome`}),i.length>0?(0,X.jsxs)(d,{value:m,onValueChange:h,children:[(0,X.jsx)(c,{"aria-label":`Outcome`,"data-testid":`flow-gate-outcome`,className:`bg-background border-control-border text-on-surface font-label text-sm min-h-11 sm:min-h-9`,children:(0,X.jsx)(s,{placeholder:`Pick an outcome`})}),(0,X.jsx)(l,{className:`bg-surface-highest border-surface-highest`,children:i.map(e=>(0,X.jsx)(u,{value:e,className:`font-label text-xs`,children:e},e))})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{"aria-label":`Outcome`,"data-testid":`flow-gate-outcome-input`,value:m,onChange:e=>h(e.target.value),placeholder:`e.g. approved`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11 sm:min-h-9`}),(0,X.jsx)(`p`,{className:`font-body text-sm text-outline`,children:`This node routes everything through a catch-all edge, so any outcome continues the flow.`})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Comment (posted on the task)`}),(0,X.jsx)(f,{"aria-label":`Comment posted on the task`,"data-testid":`flow-gate-comment`,value:g,onChange:e=>_(e.target.value),placeholder:`Why this outcome…`,className:`bg-background border-control-border text-on-surface font-body text-sm resize-none`,rows:2})]}),o.error&&(0,X.jsx)(`div`,{className:`font-body text-sm text-error`,"data-testid":`flow-gate-error`,children:o.error.message}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(a,{"data-testid":`flow-gate-submit`,size:`sm`,disabled:o.isPending||r||v.length===0,onClick:()=>o.mutate({taskId:e,outcome:v,...g.trim()?{summary:g.trim()}:{},author:`human`},{onSuccess:()=>_(``)}),className:`font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90 min-h-11 sm:min-h-9 px-3`,children:o.isPending?`Resuming…`:`Resume flow`})})]})}function Fe({definition:e,nodeId:t}){let n=e.nodeById[t];if(!n)return null;let r=e.edges.map((e,t)=>({edge:e,index:t})).filter(({edge:e})=>e.from===t);return(0,X.jsxs)(`div`,{className:`p-2 rounded-lg border border-surface-highest bg-surface-highest/30 space-y-2`,"data-testid":`flow-node-detail`,"data-node-id":t,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`font-body text-sm font-medium text-on-surface`,children:n.id}),(0,X.jsx)(Z,{children:n.kind}),n.skill&&(0,X.jsxs)(Z,{children:[`skill `,n.skill]}),n.role&&(0,X.jsx)(Z,{children:n.role}),n.task_status&&(0,X.jsxs)(Z,{children:[`sets `,n.task_status]}),n.max_visits!==void 0&&(0,X.jsxs)(Z,{children:[`max `,n.max_visits,` visits`]}),n.routing===`all`&&(0,X.jsx)(Z,{children:`fan out`}),n.join&&(0,X.jsxs)(Z,{children:[`join `,n.join.mode,` of `,n.join.from.join(`, `)]}),n.on_error&&(0,X.jsxs)(Z,{children:[`on error → `,n.on_error]})]}),n.description&&(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface-variant`,children:n.description}),r.length>0&&(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsx)(`div`,{className:`font-label text-[10px] font-medium text-outline`,children:`Outgoing edges (first match wins)`}),r.map(({edge:e,index:t},n)=>(0,X.jsxs)(`div`,{className:`font-mono text-xs text-on-surface-variant`,"data-testid":`flow-node-detail-edge`,children:[n+1,`. → `,e.to,` `,(0,X.jsxs)(`span`,{className:`text-outline`,children:[`when `,k(e.when)]}),e.label&&(0,X.jsxs)(`span`,{className:`text-outline`,children:[` (`,e.label,`)`]})]},t))]})]})}function Ie({run:e,selectedNodeId:t,onSelectNode:n}){return(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline`,children:[`Ledger (`,e.nodes.length,` `,e.nodes.length===1?`visit`:`visits`,`)`]}),e.nodes.length===0?(0,X.jsx)(`div`,{className:`font-body text-sm text-outline`,children:`Nothing has run yet.`}):(0,X.jsx)(`div`,{className:`space-y-1`,children:e.nodes.map((e,r)=>(0,X.jsxs)(`div`,{onClick:()=>n(e.node_id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&n(e.node_id)},"data-testid":`flow-ledger-row`,"data-node-id":e.node_id,"data-node-status":e.status,"data-node-outcome":e.outcome??``,className:`w-full text-left p-2 rounded-lg border transition-colors cursor-pointer ${t===e.node_id?`border-primary/40 bg-primary/5`:`border-surface-highest bg-surface-highest/40 hover:bg-surface-highest/70`}`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`font-label text-[10px] text-outline`,children:r+1}),(0,X.jsx)(`span`,{className:`font-body text-sm text-on-surface`,children:e.node_id}),(0,X.jsxs)(`span`,{className:`font-label text-[10px] text-outline`,children:[`visit `,e.attempt,e.retry>0?` · retry ${e.retry}`:``]}),(0,X.jsx)(`span`,{className:`font-label text-[10px] ${je[e.status]??`text-outline`}`,children:e.status.replace(/_/g,` `)}),e.outcome&&(0,X.jsxs)(`span`,{className:`font-label text-[10px] text-primary`,children:[`→ `,e.outcome]}),(0,X.jsxs)(`span`,{className:`font-label text-[10px] text-outline ml-auto`,children:[A(e.started_at??e.created_at,e.ended_at),e.started_at===null&&T(e.status)?` waiting`:``]})]}),e.summary&&(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface-variant mt-1 whitespace-pre-wrap`,children:e.summary}),e.error&&(0,X.jsx)(`div`,{className:`font-body text-sm text-error mt-1 whitespace-pre-wrap`,children:e.error}),e.gateway_session_id&&(0,X.jsxs)(i,{to:`/sessions/${e.gateway_session_id}`,onClick:e=>e.stopPropagation(),className:`font-mono text-xs text-primary hover:underline mt-1 inline-block`,"data-testid":`flow-ledger-session-link`,children:[`session `,e.gateway_session_id.slice(-8)]})]},`${e.node_id}-${e.attempt}-${e.retry}`))})]})}function Le({children:e}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-label text-xs font-medium text-outline`,children:[(0,X.jsx)(q,{size:12}),`Flow`,e]})}var $=[`git_repo`,`git_branch`,`git_worktree`,`github_issue`,`github_pr`],Re={git_repo:`Repository folder`,git_branch:`Branch`,git_worktree:`Worktree folder`,github_issue:`GitHub issue URL`,github_pr:`GitHub PR URL`};function ze({task:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(()=>Object.fromEntries($.map(t=>[t,e[t]??``]))),a=U();return(0,X.jsxs)(`section`,{"data-testid":`task-git-links`,className:`space-y-2 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between`,children:[(0,X.jsx)(`strong`,{children:`Git / GitHub`}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`task-git-edit`,onClick:()=>{i(Object.fromEntries($.map(t=>[t,e[t]??``]))),n(!t)},children:`Edit links`})]}),t?(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),a.mutate({id:e.id,...Object.fromEntries($.map(e=>[e,r[e].trim()||null]))},{onSuccess:()=>n(!1)})},className:`space-y-2`,children:[$.map(e=>(0,X.jsxs)(`label`,{className:`block`,children:[Re[e],(0,X.jsx)(`input`,{"data-testid":`task-link-${e}`,className:`w-full bg-surface-highest p-2`,value:r[e],onChange:t=>i({...r,[e]:t.target.value})})]},e)),(0,X.jsx)(`button`,{type:`submit`,"data-testid":`task-git-save`,disabled:a.isPending,className:`text-primary`,children:`Save links`}),a.error&&(0,X.jsx)(`p`,{role:`alert`,children:a.error.message})]}):(0,X.jsxs)(`div`,{className:`space-y-1`,children:[$.map(t=>e[t]?(0,X.jsxs)(`p`,{className:`break-all`,children:[Re[t],`:`,` `,t.startsWith(`github_`)?(0,X.jsx)(`a`,{href:e[t]??``,target:`_blank`,rel:`noreferrer`,className:`text-primary`,children:e[t]}):e[t]]},t):null),!$.some(t=>e[t])&&(0,X.jsx)(`p`,{className:`text-outline`,children:`No links yet. Link a checkout from its terminal Git panel, or edit here.`})]})]})}function Be({taskId:e}){let[t]=r(),{data:n,isLoading:a,error:o,refetch:s}=Ce(e),c=(n??[]).filter(e=>e.tokens_used!=null),l=c.reduce((e,t)=>e+(t.tokens_used??0),0),u=(n??[]).map(e=>e.last_activity_at??``).sort().pop(),d=V((n??[]).map(W));return(0,X.jsxs)(`div`,{className:`border-t border-surface-highest pt-4 space-y-3`,"data-testid":`task-sessions`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-label text-xs text-outline`,children:[(0,X.jsx)(z,{size:12}),`Agent sessions`,d&&(0,X.jsx)(G,{state:d,compact:!0,testId:`task-sessions-state`}),n&&n.length>0&&(0,X.jsxs)(`span`,{className:`font-body text-xs normal-case tracking-normal text-on-surface-variant`,children:[` `,`· `,n.length,` ·`,` `,ye(l,c.some(e=>e.tokens_estimated)),` `,`tokens · last active `,J(u??null)]})]}),o?(0,X.jsx)(Se,{message:o.message,onRetry:()=>s()}):a?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`Loading agent sessions…`}):!n||n.length===0?(0,X.jsx)(`div`,{className:`font-body text-xs text-outline`,children:`No session yet. Add a session: line with the session id to the task body, or pick the task on the Sessions page.`}):(0,X.jsx)(`div`,{className:`space-y-1`,children:n.map(e=>(0,X.jsxs)(`div`,{"data-testid":`task-session-row`,className:`flex flex-wrap items-center gap-3 px-2 py-2 rounded-lg`,children:[(0,X.jsx)(G,{state:W(e),compact:!0,context:e.agent}),(0,X.jsx)(`span`,{className:`font-label text-xs text-primary w-14 shrink-0`,children:e.agent}),(0,X.jsx)(i,{to:xe(`/sessions?session=${encodeURIComponent(e.id)}`,t.get(`project`)??e.project_id),"data-testid":`task-session-link`,className:`flex-1 min-w-0 truncate font-body text-xs text-on-surface hover:text-primary`,title:e.name??void 0,children:e.name??e.session_id}),(0,X.jsx)(`span`,{className:`font-label text-xs text-outline shrink-0`,children:be(e)}),(0,X.jsx)(`span`,{className:`font-label text-xs text-outline shrink-0`,children:J(e.last_activity_at)}),(0,X.jsx)(we,{session:e})]},e.id))})]})}var Ve=[`todo`,`doing`,`review`,`blocked`,`done`],He=[`low`,`normal`,`high`,`critical`],Ue=[`blocks`,`blocked_by`,`relates_to`,`duplicates`,`clones`,`subtask_of`,`parent_of`];function We({taskId:e,open:t,onOpenChange:n,projectScope:r=`all`}){let{data:i,isLoading:o,error:h,refetch:g}=I(e),_=i&&(r===`all`||(r===`unassigned`?i.project_id===null:i.project_id===r)),v=_?i:void 0;(0,Y.useEffect)(()=>{t&&i&&!_&&n(!1)},[t,i,_,n]);let{data:y}=w(v?.id??null),{data:x}=S(v?.id??null),{data:C}=le(),T=me(),D=P(),O=fe(),[k,A]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(`human`),[F,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(``),[V,oe]=(0,Y.useState)(`relates_to`),[H,U]=(0,Y.useState)(!1),W=()=>{e&&k.trim()&&T.mutate({id:e,content:k.trim(),author:M||`human`},{onSuccess:()=>{A(``)}})},G=()=>{e&&R.trim()&&D.mutate({id:e,to_task_id:R.trim(),link_type:V},{onSuccess:()=>{z(``),L(!1)}})},de=(0,Y.useMemo)(()=>x?x.reduce((e,t)=>{let n=t.link_type;return e[n]||(e[n]=[]),e[n].push(t),e},{}):{},[x]),pe=b(v??{}),q=ee(v??{}),ge=(0,Y.useMemo)(()=>!v?.project_id||!C?null:C.find(e=>e.id===v.project_id)?.name??v.project_id.slice(-6),[v?.project_id,C]),J=e=>e?new Date(e).toLocaleString():`-`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ue,{open:t,onOpenChange:n,children:(0,X.jsxs)(re,{"data-testid":`task-detail-sheet`,defaultWidth:620,resizeKey:`tasks`,children:[(0,X.jsx)(ae,{children:o?(0,X.jsx)(j,{className:`h-5 w-48 bg-surface-highest`}):v?(0,X.jsxs)(`div`,{className:`space-y-2 pr-6`,children:[(0,X.jsx)(ie,{children:v.title}),v.github_sync&&(0,X.jsxs)(`div`,{className:`space-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`a`,{"data-testid":`task-github-issue-link`,href:v.github_issue??void 0,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`GitHub #`,v.github_sync.number]}),(0,X.jsx)(`p`,{children:`Title, description and labels come from GitHub. Status changes sync both ways.`}),v.github_sync.error?(0,X.jsx)(`p`,{role:`alert`,className:`text-error`,children:v.github_sync.error}):v.status===v.github_sync.status?null:(0,X.jsx)(`p`,{children:`Status awaiting GitHub sync.`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(ve,{status:v.status}),(0,X.jsx)(_e,{priority:v.priority})]})]}):(0,X.jsx)(ie,{children:`Task not found`})}),(0,X.jsxs)(ne,{children:[(T.error||D.error||O.error)&&(0,X.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(T.error??D.error??O.error)?.message}),h?(0,X.jsx)(Se,{message:h.message,onRetry:()=>g()}):o?(0,X.jsx)(`div`,{className:`space-y-4`,children:Array.from({length:6}).map((e,t)=>(0,X.jsx)(j,{className:`h-8 w-full bg-surface-highest`},t))}):v?(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(ze,{task:v},v.id),v.body&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`div`,{className:`font-label text-xs font-medium text-outline`,children:`Body`}),(0,X.jsx)(`div`,{"data-testid":`task-detail-body`,className:`font-body text-sm text-on-surface wrap-break-word`,children:(0,X.jsx)(m,{readable:!0,children:v.body})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,X.jsx)(K,{label:`ID`,children:(0,X.jsx)(`span`,{className:`font-mono text-xs break-all`,children:v.id})}),(0,X.jsx)(K,{label:`Author`,children:v.author}),(0,X.jsx)(K,{label:`Claimed By`,children:v.claimed_by??`-`}),(0,X.jsx)(K,{label:`Project`,children:ge??`-`}),(0,X.jsx)(K,{label:`Skill`,children:v.skill_name??`-`}),(0,X.jsxs)(K,{label:`Agent Backend`,children:[(0,X.jsx)(`span`,{"data-testid":`task-backend-name`,children:q.label}),q.available===!1&&(0,X.jsxs)(`span`,{className:`text-error`,title:`This backend is not usable right now`,children:[` `,`○`]})]}),(0,X.jsx)(K,{label:`Flow`,children:(0,X.jsx)(`span`,{"data-testid":`task-flow-name`,children:pe.label})}),(0,X.jsx)(K,{label:`Required Review`,children:v.required_review?`Yes`:`No`}),(0,X.jsx)(K,{label:`Max Review Rounds`,children:v.max_review_rounds}),(0,X.jsx)(K,{label:`Due`,children:(0,X.jsx)(`span`,{className:(e=>e?new Date(e)<new Date:!1)(v.due_at)&&v.status!==`done`?`text-error`:``,children:J(v.due_at)})}),(0,X.jsx)(K,{label:`Created`,children:J(v.created_at)}),(0,X.jsx)(K,{label:`Updated`,children:J(v.updated_at)})]}),v.progress>0&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`div`,{className:`font-label text-xs font-medium text-outline`,children:`Progress`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`flex-1 h-2 bg-surface-highest rounded-lg overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full bg-primary rounded-lg transition-all`,style:{width:`${Math.min(100,v.progress)}%`}})}),(0,X.jsxs)(`span`,{className:`font-label text-xs text-outline`,children:[v.progress,`%`]})]})]}),v.tags&&v.tags.length>0&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`div`,{className:`font-label text-xs font-medium text-outline`,children:`Tags`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:v.tags.map(e=>(0,X.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-label bg-primary/10 text-primary border border-primary/20 rounded-lg`,children:e},e))})]}),(0,X.jsx)(Be,{taskId:v.id}),(0,X.jsxs)(`div`,{className:`border-t border-surface-highest pt-4 space-y-3`,children:[(0,X.jsx)(Le,{}),(0,X.jsx)(Me,{taskId:v.id})]}),(0,X.jsxs)(`div`,{className:`border-t border-surface-highest pt-4 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-label text-xs font-medium text-outline`,children:[(0,X.jsx)(E,{size:12}),`Links`]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>L(!0),className:`text-primary hover:text-primary/80 transition-colors`,children:(0,X.jsx)(te,{size:14})})]}),x&&x.length>0?(0,X.jsx)(`div`,{className:`space-y-2`,children:Object.entries(de).map(([t,n])=>(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`div`,{className:`font-label text-[10px] font-medium text-outline`,children:t.replace(/_/g,` `)}),n.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 bg-surface-highest/50 rounded-lg`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs text-on-surface-variant`,children:t.from_task_id===e?t.to_task_id.slice(-6):t.from_task_id.slice(-6)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>O.mutate({taskId:e,linkId:t.id}),className:`text-outline hover:text-error transition-colors p-0.5`,children:(0,X.jsx)(he,{size:10})})]},t.id))]},t))}):(0,X.jsx)(`div`,{className:`font-body text-sm text-outline`,children:`No links`}),F&&(0,X.jsxs)(`div`,{className:`space-y-2 p-2 bg-surface-highest/30 rounded-lg border border-surface-highest`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Link Type`}),(0,X.jsxs)(d,{value:V,onValueChange:e=>oe(e),children:[(0,X.jsx)(c,{className:`bg-background border-control-border text-on-surface font-label text-xs h-7`,children:(0,X.jsx)(s,{})}),(0,X.jsx)(l,{className:`bg-surface-highest border-surface-highest`,children:Ue.map(e=>(0,X.jsx)(u,{value:e,className:`font-label text-xs`,children:e.replace(/_/g,` `)},e))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Target Task ID`}),(0,X.jsx)(B,{value:R,onChange:e=>z(e.target.value),placeholder:`Task ID...`,className:`bg-background border-control-border text-on-surface font-body text-sm h-7`})]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,X.jsx)(a,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{L(!1),z(``)},className:`font-label text-xs text-outline h-6 px-2`,children:`Cancel`}),(0,X.jsx)(a,{size:`sm`,onClick:G,disabled:D.isPending||!R.trim(),className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90 h-6 px-2`,children:`Add`})]})]})]}),(0,X.jsxs)(`div`,{className:`border-t border-surface-highest pt-4 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-label text-xs font-medium text-outline`,children:[(0,X.jsx)(se,{size:12}),`Comments (`,y?.length??0,`)`]}),y&&y.length>0&&(0,X.jsx)(`div`,{className:`space-y-2`,children:y.map(e=>(0,X.jsxs)(`div`,{className:`py-2 border-b border-border space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`font-label text-xs text-primary`,children:e.author}),(0,X.jsx)(`span`,{className:`font-label text-[10px] text-outline`,children:new Date(e.created_at).toLocaleString()})]}),(0,X.jsx)(`div`,{className:`font-body text-sm text-on-surface whitespace-pre-wrap wrap-break-word`,children:e.content})]},e.id))}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(B,{"aria-label":`Comment author`,value:M,onChange:e=>N(e.target.value),placeholder:`Author`,className:`bg-background border-control-border text-on-surface font-body text-sm h-7 w-24`}),(0,X.jsx)(f,{value:k,onChange:e=>A(e.target.value),placeholder:`Add a comment...`,className:`bg-background border-control-border text-on-surface font-body text-sm resize-none flex-1`,rows:2})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(a,{"data-testid":`task-comment-submit`,size:`sm`,onClick:W,disabled:T.isPending||!k.trim(),className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90 h-6 px-2`,children:T.isPending?`...`:`Comment`})})]})]})]}):(0,X.jsx)(`div`,{className:`text-outline font-label text-xs font-medium text-center py-8`,children:`Task not found`})]}),v&&(0,X.jsx)(ce,{children:(0,X.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),className:`font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface`,children:`Edit task`})})]})}),v&&H&&(0,X.jsx)(Ge,{task:v,open:H,onClose:()=>U(!1)})]})}function Ge({task:e,open:t,onClose:n}){let{data:r}=le(),i=U(),[o,f]=(0,Y.useState)(e.title),[m,v]=(0,Y.useState)(e.body??``),[b,x]=(0,Y.useState)(e.status),[S,C]=(0,Y.useState)(e.priority),[w,T]=(0,Y.useState)(e.due_at??``),[E,ee]=(0,Y.useState)((e.tags??[]).join(`, `)),[D,O]=(0,Y.useState)(e.project_id??``),[k,A]=(0,Y.useState)(e.skill_name??``),[j,te]=(0,Y.useState)(e.agent_backend??`__default__`),[M,N]=(0,Y.useState)(e.required_review),[P,F]=(0,Y.useState)(String(e.max_review_rounds)),[I,ne]=(0,Y.useState)(e.flow_name??`__default__`),z=(t,r=n)=>{if(t.preventDefault(),!o.trim())return;let a=E.split(`,`).map(e=>e.trim()).filter(Boolean);i.mutate({id:e.id,...e.github_sync?{}:{title:o.trim(),body:m.trim()||null},status:b,priority:S,due_at:w||null,tags:a.length>0?a:null,project_id:D||null,skill_name:k||null,agent_backend:j===`__default__`?null:j,required_review:M,max_review_rounds:Number(P)||3,...e.flow_override?{}:{flow_name:I===`__default__`?null:I}},{onSuccess:r})};return(0,X.jsx)(L,{testId:`edit-task-dialog`,open:t,onClose:n,busy:i.isPending,dirty:JSON.stringify([o,m,b,S,w,E,D,k,j,M,P,I])!==JSON.stringify([e.title,e.body??``,e.status,e.priority,e.due_at??``,(e.tags??[]).join(`, `),e.project_id??``,e.skill_name??``,e.agent_backend??`__default__`,e.required_review,String(e.max_review_rounds),e.flow_name??`__default__`]),children:(t,n)=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(h,{children:(0,X.jsx)(_,{className:`font-headline text-sm font-medium text-on-surface`,children:`Edit task`})}),(0,X.jsxs)(`form`,{onSubmit:e=>z(e,n),className:`min-h-0`,children:[(0,X.jsxs)(`div`,{className:`work-form-body grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Title *`}),(0,X.jsx)(B,{"aria-label":`Title`,"data-testid":`edit-task-title`,value:o,readOnly:!!e.github_sync,onChange:e=>f(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,X.jsx)(R,{label:`Body`,"aria-label":`Body`,"data-testid":`edit-task-body`,value:m,readOnly:!!e.github_sync,onChange:v,rows:4}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Status`}),(0,X.jsxs)(d,{value:b,onValueChange:e=>x(e),children:[(0,X.jsx)(c,{"aria-label":`Status`,className:`bg-background border-control-border text-on-surface font-label text-xs`,children:(0,X.jsx)(s,{})}),(0,X.jsx)(l,{className:`bg-surface-highest border-surface-highest`,children:Ve.map(e=>(0,X.jsx)(u,{value:e,className:`font-label text-xs`,children:e.replace(/_/g,` `)},e))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Priority`}),(0,X.jsxs)(d,{value:S,onValueChange:e=>C(e),children:[(0,X.jsx)(c,{"aria-label":`Priority`,className:`bg-background border-control-border text-on-surface font-label text-xs`,children:(0,X.jsx)(s,{})}),(0,X.jsx)(l,{className:`bg-surface-highest border-surface-highest`,children:He.map(e=>(0,X.jsx)(u,{value:e,className:`font-label text-xs`,children:e},e))})]})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Due date`}),(0,X.jsx)(B,{type:`datetime-local`,value:w?w.slice(0,16):``,onChange:e=>T(e.target.value?new Date(e.target.value).toISOString():``),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Project`}),(0,X.jsxs)(d,{value:D||`__none__`,disabled:!!e.github_sync,onValueChange:e=>O(e===`__none__`?``:e),children:[(0,X.jsx)(c,{"aria-label":`Project`,className:`bg-background border-control-border text-on-surface font-label text-xs`,children:(0,X.jsx)(s,{})}),(0,X.jsxs)(l,{className:`bg-surface-highest border-surface-highest`,children:[(0,X.jsx)(u,{value:`__none__`,className:`font-label text-xs`,children:`None`}),r?.map(e=>(0,X.jsx)(u,{value:e.id,className:`font-label text-xs`,children:e.name},e.id))]})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Tags (comma-separated)`}),(0,X.jsx)(B,{"aria-label":`Tags`,value:E,onChange:e=>ee(e.target.value),placeholder:`tag1, tag2`,className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Skill Name`}),(0,X.jsx)(B,{"aria-label":`Skill override`,value:k,onChange:e=>A(e.target.value),placeholder:`e.g. code-review`,className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,X.jsx)(y,{value:j,onChange:te,testId:`edit-task-backend`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1.5 flex items-center gap-2 pt-4`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`edit-required-review`,checked:M,onChange:e=>N(e.target.checked),className:`accent-primary`}),(0,X.jsx)(p,{htmlFor:`edit-required-review`,className:`font-label text-xs font-medium text-outline cursor-pointer`,children:`Required Review`})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`font-label text-xs font-medium text-outline`,children:`Max Review Rounds`}),(0,X.jsx)(B,{type:`number`,value:P,onChange:e=>F(e.target.value),min:1,className:`bg-background border-control-border text-on-surface font-body text-sm`})]})]}),e.flow_override?(0,X.jsxs)(`p`,{className:`font-body text-sm text-outline`,"data-testid":`task-flow-override-note`,children:[`This task carries an inline flow definition (flow_override), which beats any named flow. Detach it with `,(0,X.jsx)(`code`,{children:`orc flow attach`}),` to use a named flow instead.`]}):(0,X.jsx)(pe,{value:I,onChange:ne,testId:`edit-task-flow`}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error md:col-span-2`,children:i.error.message})]}),(0,X.jsxs)(g,{className:`work-form-footer`,children:[(0,X.jsx)(a,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`form-cancel`,onClick:t,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,X.jsx)(a,{"data-testid":`edit-task-submit`,type:`submit`,size:`sm`,disabled:i.isPending||!o.trim(),className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:i.isPending?`Saving...`:`Save`})]})]})]})})}export{We as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileEditor-wRs221QU.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/QueryClientProvider-DlPztvhd.js","assets/chunk-OB3PAWPO-1IihCzFx.js","assets/client-954dj6K2.js","assets/MarkdownEditor-5U4_BhYm.js","assets/button-By-NN7c7.js","assets/react-dom-DTbwZiiP.js","assets/floating-ui.react-dom-BDMgcqWu.js","assets/bundle-mjs-CdK3cBzO.js","assets/maximize-2-BUxUwGbf.js","assets/preload-helper-BLdHbfdN.js","assets/Markdown-D-AaJ4bU.js","assets/document-display-BQ5dM8QT.js","assets/file-kind-BYU1kv95.js","assets/index-XIDqokJX.js","assets/useMutation-CRAWY7v2.js","assets/dist-bytwC6rk.js","assets/es2015-w69PgVrA.js","assets/x-tY-z3woy.js","assets/check-Cg2_C_4I.js","assets/chevron-down-KBvm_HoX.js","assets/select-cyLFVkkB.js","assets/dist-DScw4RwC.js","assets/dist-Ct6061MC.js","assets/dist-D8Wfxh48.js","assets/circle-check-DWP3C_MJ.js","assets/textarea-CovStda2.js","assets/tabs-bEwJLtA0.js","assets/label-Bm_d0NKL.js","assets/schemas-BQZhekae.js","assets/dialog-DNIYhwi4.js","assets/bulk-actions-C8S1Gt4W.js","assets/index-hvCYuRJb.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-CRAWY7v2.js";import{f as o,m as s,p as c,r as l,t as u}from"./chunk-OB3PAWPO-1IihCzFx.js";import{c as d,r as f,t as p}from"./button-By-NN7c7.js";import{c as m,i as h,n as g,o as _,r as v,t as y}from"./x-tY-z3woy.js";import{h as b,n as x,t as S}from"./client-954dj6K2.js";import{t as C}from"./chevron-down-KBvm_HoX.js";import{t as w}from"./circle-check-DWP3C_MJ.js";import{t as T}from"./preload-helper-BLdHbfdN.js";import{a as E,n as ee,o as D,r as O,t as k}from"./dialog-DNIYhwi4.js";import{An as A,At as j,Br as M,Dr as N,Ft as P,Gr as F,Hr as I,Ht as L,In as R,Jr as z,Kr as B,Mn as V,Nn as H,Nr as U,Nt as te,O as ne,Or as re,Ot as W,Qr as ie,Qt as ae,Rr as oe,Sn as se,Ur as G,Vr as ce,Xr as K,Yr as le,Zr as q,_t as ue,bn as J,br as de,cr as fe,dr as pe,dt as me,f as he,fn as ge,fr as _e,ft as ve,g as ye,gr as be,gt as xe,h as Se,ht as Ce,jn as we,jr as Te,jt as Ee,kr as De,lr as Oe,lt as ke,m as Ae,mr as je,nn as Me,p as Ne,pr as Pe,sn as Fe,ur as Ie,ut as Le,vt as Re,yr as ze,yt as Y,zr as Be}from"./index-XIDqokJX.js";import{t as Ve}from"./ConfirmDialog-B5es4nUp.js";import{t as He}from"./ErrorState-DB0nWfcc.js";import{n as Ue}from"./useSessions-DiUU2FN8.js";import{t as We}from"./ResumeActions-e6YpUhEq.js";import{t as Ge}from"./SessionHomeLink-BAWO86fJ.js";var Ke={name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]};Ke.node;var qe=b(Ke),Je={name:`copy-plus`,size:24,node:[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Je.node;var Ye=b(Je),Xe={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};Xe.node;var Ze=b(Xe),Qe={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};Qe.node;var $e=b(Qe),et={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};et.node;var tt=b(et),nt={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};nt.node;var rt=b(nt),it={name:`panel-top`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};it.node;var at=b(it),ot={name:`panels-top-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]],aliases:[`layout`]};ot.node;var st=b(ot),ct={name:`rows-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]],aliases:[`rows`]};ct.node;var lt=b(ct),X=e(t(),1),Z=n();function ut({terminal:e,showLabel:t=!1,onContinued:n}){let r=J(),i=o(),[a]=s(),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(``);if(!R(e.kind))return null;async function f(){if(e.live_session_id){l(!0),d(``);try{r.openThread(await x.chat.resume(e.live_session_id));let t=new URLSearchParams(a);t.delete(`session`),t.set(`chat`,`open`),i({search:t.toString()}),n?.()}catch(e){d(e instanceof Error?e.message:`Could not continue in chat.`)}finally{l(!1)}}}return(0,Z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-continue-chat`,"aria-label":`Resume`,title:e.live_session_id?`Resume in chat`:`Waiting for the agent session to be registered`,disabled:c||!e.live_session_id,onClick:()=>void f(),className:`inline-flex min-h-11 min-w-11 items-center justify-center gap-2 rounded-md px-2 text-sm text-on-surface-variant hover:bg-surface disabled:opacity-40`,children:[(0,Z.jsx)(Te,{size:17}),t&&`Resume`]}),u&&(0,Z.jsx)(`p`,{role:`alert`,className:`absolute right-0 top-full z-50 w-64 rounded-md border border-border bg-background p-3 text-sm text-error`,children:u})]})}function dt({host:e,onPick:t,disabled:n=!1}){let{recent:r}=V(e);return(0,Z.jsxs)(`label`,{className:`block text-xs text-on-surface-variant`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Recent folders`}),(0,Z.jsxs)(`select`,{"data-testid":`recent-folders`,"aria-label":`Recent folders`,value:``,disabled:n||!r.length,className:`w-full min-h-11 sm:min-h-8 [@media(pointer:coarse)]:min-h-11 rounded-md border border-control-border bg-background px-2 text-sm`,onChange:e=>{e.target.value&&t(e.target.value)},children:[(0,Z.jsx)(`option`,{value:``,children:r.length?`Recent folders (${r.length})`:`No recent folders`}),r.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})}function ft(e,t){return i({queryKey:[`worktrees`,e,t],queryFn:()=>x.git.worktrees(e,t),enabled:e.trim()!==``,retry:!1,staleTime:5e3})}function pt(){let e=r();return a({mutationFn:e=>x.git.removeWorktree(e),onSettled:()=>e.invalidateQueries({queryKey:[`worktrees`]})})}var mt=`orc_terminal_cwd`,ht=`orc_terminal_worktree`;function gt(e){try{return{cwd:e?.getItem(`orc_terminal_cwd`)??``,worktree:e?.getItem(ht)===`1`}}catch{return{cwd:``,worktree:!1}}}function _t(e,t,n){try{e?.setItem(t,n)}catch{}}function vt(e,t){return e!==`shell`&&t.trim()===``}function yt(e,t,n){let r=t.trim();return{kind:e,...r?{cwd:r}:{},...n&&e!==`shell`&&r?{worktree:!0}:{}}}var bt=(()=>{try{return typeof window>`u`?void 0:window.localStorage}catch{return}})();function xt(e,t){let[n,r]=(0,X.useState)(e);return(0,X.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function St(e,t){let[n]=(0,X.useState)(()=>gt(bt)),[r,i]=(0,X.useState)(e),[a,o]=(0,X.useState)(()=>A(e).last||(e?``:n.cwd)),[s,c]=(0,X.useState)(n.worktree),[l,u]=(0,X.useState)(!1),d=(0,X.useRef)(new Map([[null,A(null).last||n.cwd],[e,A(e).last||(e?``:n.cwd)]])),f=(0,X.useRef)(!1);(0,X.useEffect)(()=>{let e=t&&!f.current;if(f.current=t,t||u(!1),e){let e=A(r).last;e&&o(e)}},[t,r]);let p=H(),m=(0,X.useRef)(e);return(0,X.useEffect)(()=>{m.current!==e&&(m.current=e,i(e),o(d.current.get(e)??A(e).last),u(!1))},[e]),{host:r,setHost:i,cwd:a,setCwd:o,worktree:s,setWorktree:c,remoteBrowsing:l,setRemoteBrowsing:u,folders:d,folderPickerSession:p}}function Ct({open:e,onOpenChange:t,launchers:n,host:r,pending:a,error:o,onCreate:s,className:c,compact:l=!1,iconOnly:u=!1,draft:f}){let p=(0,X.useId)(),b=St(r,e),{host:C,setHost:w,cwd:T,setCwd:E,worktree:ee,setWorktree:D,remoteBrowsing:O,setRemoteBrowsing:k,folders:M,folderPickerSession:N}=f??b,[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),R=(0,X.useRef)(null),z=(0,X.useRef)(null),{data:B,error:V}=Me(),H=!C||B?.supported===!0,{data:U,error:te,isFetching:ne}=i({queryKey:[`terminal-launchers`,C],queryFn:()=>x.terminals.list(C),enabled:e&&H,retry:!1,staleTime:3e4}),W=[],ie=Fe();U?.ready?W=U.launchers:!U&&C===r&&!te&&H&&(W=n);let ae=xt(T.trim(),300),oe=xt(C??``,300),{data:se}=ft(e&&H&&oe===(C??``)?ae:``,C),G=pt(),K=se?.root?se.worktrees:[],le=a||ne||!H,q=e=>{E(e),M.current.set(C,e),C===null&&_t(bt,mt,e)},ue=e=>{M.current.set(C,T),w(e),E(M.current.get(e)??A(e).last),k(!1),F(null),L(null)},J=()=>{N.reset(T.trim()),F(null),k(!0)},de=async(e,t,n)=>{F(null);let r=T.trim();vt(e,r)?J():await s({...yt(e,r,ee),host:C,providerId:t,name:n})&&(we(C,r),C===null&&_t(bt,mt,r))},fe=(e,t)=>{F(null),we(C,t.path),s({...yt(e,t.path,!1),host:C})},me=async e=>{F(null);let t=K.find(e=>e.main)?.path??ae;try{await G.mutateAsync({cwd:t,path:e.worktree.path,force:e.step===`dirty`,host:C}),L(null),e.worktree.path===ae&&q(t)}catch(t){if(t instanceof S&&t.code===`WORKTREE_DIRTY`){L({worktree:e.worktree,step:`dirty`});return}L(null),F(t instanceof Error?t.message:String(t))}},he=()=>{I&&(I.step===`confirm`&&I.worktree.dirty?L({worktree:I.worktree,step:`dirty`}):me(I))},ge=P??o??(C&&!H?B?.unsupported_reason:null)??te?.message??V?.message??U?.reason,ve=(0,X.useRef)(null),be=l?g:Oe,xe=l?X.Fragment:_e,Ce=l?h:pe;return(0,Z.jsx)(be,{open:e,onOpenChange:e=>{!O&&!I&&t(e)},children:(0,Z.jsxs)(`div`,{ref:R,className:d(`relative`,c),children:[(0,Z.jsx)(xe,{...l?{}:{asChild:!0},children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-new`,"aria-haspopup":`dialog`,"aria-expanded":e,onClick:l?()=>t(!e):void 0,title:`New terminal`,className:d(`min-w-11 inline-flex items-center justify-center gap-2 min-h-11 rounded-md font-label text-xs transition-colors`,u?`w-11 shrink-0 sm:w-8 sm:min-w-8 sm:min-h-8 text-on-surface-variant hover:bg-surface`:`w-full px-3 py-2 bg-primary border border-primary text-primary-foreground hover:bg-primary/90`),children:[(0,Z.jsx)(re,{size:14}),(0,Z.jsx)(`span`,{className:l||u?`sr-only`:void 0,children:`New terminal`})]})}),l&&e&&(0,Z.jsx)(_,{className:`fixed inset-0 z-50 bg-black/70`}),e&&(0,Z.jsxs)(Ce,{ref:ve,...l?{}:{align:`start`},onOpenAutoFocus:e=>{e.preventDefault(),ve.current?.querySelector(`[data-testid="terminal-cwd"]`)?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),R.current?.querySelector(`[data-testid="terminal-new"]`)?.focus()},onInteractOutside:e=>{(O||I)&&e.preventDefault()},onEscapeKeyDown:e=>{(O||I)&&e.preventDefault()},role:`dialog`,"aria-label":`New terminal`,"aria-describedby":void 0,"data-testid":`terminal-launch-menu`,className:d(`terminal-launch-controls bg-surface-high border border-outline-variant rounded-lg shadow-xl p-3 space-y-3 overflow-y-auto overscroll-contain`,l?`fixed inset-x-3 top-[calc(var(--app-top,0px)+env(safe-area-inset-top)+1rem)] z-50 max-h-[calc(var(--app-height,100dvh)-2rem)]`:`w-88 max-h-[min(70dvh,var(--radix-popover-content-available-height))]`),children:[l&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(m,{className:`text-sm font-medium`,children:`New terminal`}),(0,Z.jsx)(v,{className:`flex size-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface`,"aria-label":`Close terminal launcher`,children:(0,Z.jsx)(y,{size:18})})]}),(0,Z.jsxs)(`label`,{htmlFor:p,className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[`Host`,(0,Z.jsxs)(j,{id:p,"data-testid":`terminal-host-select`,value:C??``,onChange:e=>ue(e.target.value||null),disabled:a,children:[(0,Z.jsx)(`option`,{value:``,children:`Local`}),[...new Set([...B?.hosts??[],...B?.host?[B.host]:[]])].map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsxs)(`span`,{className:`font-label text-xs text-on-surface-variant`,children:[`Working directory`,C&&(0,Z.jsxs)(`span`,{"data-testid":`terminal-host`,className:`ml-1 px-1 rounded-md bg-surface-highest text-on-surface normal-case tracking-normal`,children:[`on `,C]})]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-1`,children:[(0,Z.jsx)(`input`,{type:`text`,"data-testid":`terminal-cwd`,value:T,onChange:e=>q(e.target.value),onBlur:()=>we(C,T),placeholder:`~ (home folder)`,spellCheck:!1,className:`min-w-0 flex-1 bg-background border border-control-border rounded-md min-h-11 px-2 py-1 font-body text-base sm:text-sm text-on-surface placeholder:text-on-surface-variant focus:outline-hidden focus:ring-2 focus:ring-focus`}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-browse`,ref:z,disabled:le,onClick:J,title:`Choose a folder`,className:`shrink-0 inline-flex items-center gap-1 min-h-11 px-2 py-1 rounded-md border border-control-border font-label text-xs text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50`,children:[(0,Z.jsx)(ce,{size:12}),`Browse`]})]})]}),(0,Z.jsx)(dt,{host:C,disabled:a,onPick:e=>{q(e),we(C,e)}}),(0,Z.jsx)(Ee,{session:N,open:O,onOpenChange:k,host:C,initial:T.trim(),returnFocusRef:z,onPick:e=>{q(e),we(C,e)}}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 px-1 cursor-pointer select-none`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`terminal-worktree`,checked:ee,onChange:e=>{D(e.target.checked),_t(bt,`orc_terminal_worktree`,e.target.checked?`1`:`0`)},className:`accent-primary`}),(0,Z.jsx)(`span`,{className:`font-body text-xs text-on-surface-variant`,children:`New git worktree`})]}),(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(ie.data?[...W.filter(e=>e===`shell`).map(e=>({kind:e,id:e,name:ye(e).label,providerId:void 0})),...ie.data.providers.filter(e=>e.enabled&&(W.includes(e.agent)||!C&&!!e.executable)).map(e=>({kind:e.agent,id:e.id,name:e.name,providerId:e.id}))]:W.map(e=>({kind:e,id:e,name:ye(e).label,providerId:void 0}))).map(e=>{let t=e.kind,{label:n,icon:r}=ye(t);return(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-launch-${e.id}`,disabled:le,onClick:()=>void de(t,e.providerId,e.providerId?e.name:void 0),className:`w-full flex items-center gap-2 min-h-11 px-2 py-1.5 rounded-md font-label text-xs text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50`,children:[(0,Z.jsx)(r,{size:14}),e.name||n]},e.id)}),W.length===0&&(0,Z.jsx)(`p`,{className:`min-h-11 px-2 py-1 font-body text-base sm:text-sm text-on-surface-variant`,children:`No launchers available`})]}),K.length>0&&(0,Z.jsxs)(`div`,{"data-testid":`terminal-worktrees`,className:`border-t border-surface-highest pt-2`,children:[(0,Z.jsx)(`p`,{className:`px-1 pb-1 font-label text-xs text-on-surface-variant`,children:`Checkouts`}),(0,Z.jsx)(`ul`,{className:`max-h-56 overflow-y-auto space-y-0.5`,children:K.map(e=>(0,Z.jsxs)(`li`,{"data-testid":`terminal-worktree-row`,className:`group flex flex-wrap sm:flex-nowrap items-center gap-x-2 px-1 py-1 rounded-md hover:bg-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 basis-full sm:basis-auto sm:flex-1`,title:e.path,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 font-body text-xs text-on-surface`,children:[(0,Z.jsx)(Be,{size:11,className:`shrink-0 text-on-surface-variant`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.branch??(e.head?e.head.slice(0,8):`detached`)}),e.main&&(0,Z.jsx)(`span`,{className:`shrink-0 px-1 rounded-md bg-surface-highest text-on-surface font-label text-xs`,children:`main`}),e.dirty&&(0,Z.jsx)(`span`,{className:`shrink-0 px-1 rounded-md text-tertiary font-label text-xs`,children:`dirty`}),e.prunable&&(0,Z.jsx)(`span`,{className:`shrink-0 px-1 rounded-md text-error font-label text-xs`,children:`missing`})]}),(0,Z.jsx)(`div`,{className:`truncate font-body text-xs text-on-surface-variant`,children:Se(e.path)})]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center`,children:[!e.prunable&&W.map(t=>{let{label:n,icon:r}=ye(t);return(0,Z.jsx)(`button`,{type:`button`,"data-testid":`terminal-worktree-open-${t}`,disabled:le,onClick:()=>fe(t,e),title:`Open ${n} here`,"aria-label":`Open ${n} in ${e.path}`,className:`shrink-0 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center p-1 rounded-md text-on-surface-variant hover:bg-surface hover:text-on-surface disabled:opacity-50`,children:(0,Z.jsx)(r,{size:12})},t)}),!e.main&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":`terminal-worktree-remove`,disabled:le||G.isPending,onClick:()=>L({worktree:e,step:`confirm`}),title:`Remove worktree`,"aria-label":`Remove worktree ${e.path}`,className:`shrink-0 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center p-1 rounded-md text-on-surface-variant hover:bg-error/15 hover:text-error disabled:opacity-50`,children:(0,Z.jsx)(ze,{size:12})})]})]},e.path))})]}),ge&&(0,Z.jsx)(`p`,{role:`alert`,className:`px-1 font-body text-xs text-error wrap-break-word`,children:ge})]}),(0,Z.jsx)(Ve,{open:I!==null,onCancel:()=>L(null),onConfirm:he,isPending:G.isPending,title:I?.step===`dirty`?`Discard uncommitted changes?`:`Remove worktree?`,description:I?.step===`dirty`?`${I.worktree.path} has uncommitted changes. Removing it deletes them for good.`:`Deletes the folder ${I?.worktree.path??``}. The branch ${I?.worktree.branch??``} is kept.`,confirmLabel:I?.step===`dirty`?`Discard and remove`:`Remove`})]})})}function wt({terminal:e,onClose:t}){let{rename:n}=ae(),[r,i]=(0,X.useState)(e.name),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null);return(0,Z.jsx)(k,{open:!0,onOpenChange:e=>{a||e||t()},children:(0,Z.jsxs)(ee,{onCloseAutoFocus:t=>{t.preventDefault(),document.querySelector(`[data-terminal-actions="${CSS.escape(e.id)}"]`)?.focus()},children:[(0,Z.jsx)(D,{children:`Rename terminal`}),(0,Z.jsx)(O,{children:`Choose a friendly name for this terminal session.`}),(0,Z.jsxs)(`form`,{className:`space-y-4`,onSubmit:async i=>{if(i.preventDefault(),!a&&r.trim()){o(!0),c(null);try{await n(e.id,r.trim()),t()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}},children:[(0,Z.jsxs)(`label`,{htmlFor:`terminal-name-${e.id}`,className:`block space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm`,children:`Terminal name`}),(0,Z.jsx)(be,{id:`terminal-name-${e.id}`,"data-testid":`terminal-rename-input`,value:r,onChange:e=>i(e.target.value),maxLength:120,required:!0,disabled:a})]}),s&&(0,Z.jsx)(`p`,{role:`alert`,"data-testid":`terminal-rename-error`,className:`text-sm text-error`,children:s}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(p,{type:`button`,variant:`ghost`,"data-testid":`terminal-rename-cancel`,disabled:a,onClick:t,children:`Cancel`}),(0,Z.jsx)(p,{type:`submit`,"data-testid":`terminal-rename-save`,disabled:a||!r.trim(),children:a?`Saving…`:`Save`})]})]})]})})}function Tt({terminal:e,paneId:t}){let[,n]=s(),r=i({queryKey:[`git`,e.id,`status`],queryFn:()=>x.git.status(e.id)});return r.error?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void r.refetch(),className:`min-h-8 text-xs text-warning`,title:r.error.message,children:`Git unavailable · Retry`}):r.data?.root?(0,Z.jsxs)(`button`,{type:`button`,"data-testid":t?`pane-checkout`:`terminal-checkout`,title:`Review checkout changes`,onClick:()=>n(n=>{let r=new URLSearchParams(n);return r.set(`view`,`git`),t&&r.set(`pane`,t),r.set(`paneTerminal`,e.id),r.delete(`file`),r}),className:`flex items-center gap-2 min-h-6 sm:min-h-8 min-w-0 max-w-full text-xs text-on-surface-variant hover:text-on-surface`,children:[(0,Z.jsx)(Be,{size:13,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:r.data.branch??`Detached HEAD`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:r.data.files.length?`${r.data.files.length} changed`:`Clean`})]}):null}function Et({terminal:e,onRename:t,onDuplicate:n,onClose:r,canDuplicate:i,pending:a,open:o,onOpenChange:s}){let[c,l]=(0,X.useState)(!1),u=s??l,d=`flex w-full items-center gap-2 rounded px-3 min-h-8 text-[13px] text-left hover:bg-surface-highest focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-40`;return(0,Z.jsxs)(Oe,{open:o??c,onOpenChange:u,children:[(0,Z.jsx)(_e,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`terminal-actions`,"data-terminal-actions":e.id,"aria-label":`Actions for ${e.name}`,title:`Terminal actions (also right-click the tab)`,className:`shrink-0 inline-flex min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 items-center justify-center rounded text-on-surface-variant hover:bg-surface hover:text-on-surface`,children:(0,Z.jsx)(B,{size:16})})}),(0,Z.jsxs)(pe,{"data-testid":`terminal-actions-menu`,"aria-label":`Actions for ${e.name}`,align:`end`,sideOffset:4,collisionPadding:8,className:`z-50 w-64 max-w-[calc(100vw-16px)] rounded-md border border-outline-variant bg-surface-high p-1 shadow-lg`,children:[(0,Z.jsx)(`p`,{className:`truncate px-3 py-2 text-xs text-on-surface-variant`,title:e.name,children:e.name}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-rename`,onClick:()=>{u(!1),t(e)},className:d,children:[(0,Z.jsx)(De,{size:14}),`Rename`]}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-duplicate`,disabled:a||!i,onClick:()=>{u(!1),n(e)},className:d,title:i?`Start a fresh session of the same type in this folder`:`The session's host or launcher is unavailable`,children:[(0,Z.jsx)(Ye,{size:14}),`Duplicate tab`]}),(0,Z.jsx)(`p`,{className:`px-3 pb-2 text-xs text-on-surface-variant`,children:`Duplicate starts a fresh session in the same folder.`}),(0,Z.jsx)(`div`,{className:`border-t border-outline-variant pt-1`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-close-selected`,onClick:()=>{u(!1),r(e)},className:`${d} text-error`,children:[(0,Z.jsx)(y,{size:14}),`Close terminal`]})})]})]})}function Dt({terminals:e,activeId:t,onClose:n,connectionOf:r,onRename:i,onDuplicate:a,canDuplicate:o,pending:c}){let[l]=s(),[f,p]=(0,X.useState)(`all`),[m,h]=(0,X.useState)(null),g=he(e,``,f),_=fe(),v=new Map((_.data??[]).map(e=>[e.id,je(e)]));return(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`space-y-2 px-3 pb-3 border-b border-outline-variant`,children:(0,Z.jsx)(`fieldset`,{className:`flex items-center gap-1`,"aria-label":`Filter terminals`,children:[`all`,`running`,`exited`].map(t=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`terminal-filter-${t}`,"aria-pressed":f===t,onClick:()=>p(t),className:d(`flex-1 min-h-11 sm:min-h-8 rounded px-1 text-xs`,f===t?`bg-surface-highest text-on-surface`:`text-on-surface-variant hover:bg-surface`),children:[t===`all`?`All`:t===`running`?`Running`:`Exited`,` `,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:t===`all`?e.length:e.filter(e=>e.status===t).length})]},t))})}),(0,Z.jsxs)(`div`,{"data-testid":`terminals-list`,className:`flex-1 min-h-0 overflow-y-auto py-1`,children:[g.length===0&&(0,Z.jsx)(`p`,{"data-testid":`terminal-search-empty`,className:`p-4 text-sm text-on-surface-variant`,children:`No sessions in this filter.`}),g.map(e=>{let s=e.id===t,{label:f,icon:p}=ye(e.kind),g=Se(e.cwd),_=Ne(e,r(e.id)),y=_===`Disconnected`||_===`Reconnecting`,b=e.status===`running`&&e.live_session_id?v.get(e.live_session_id):void 0,x=new URLSearchParams(l);return x.delete(`file`),x.delete(`session`),x.has(`view`)&&x.set(`paneTerminal`,e.id),(0,Z.jsxs)(`div`,{"data-testid":`terminal-item`,"data-status":e.status,"data-active":s,className:d(`flex min-h-11 items-center gap-2 px-3 py-1.5 transition-colors`,s?`bg-surface-highest`:`hover:bg-surface`),children:[b?(0,Z.jsx)(Pe,{state:b,compact:!0,context:e.name,testId:`terminal-agent-state`,className:`-mx-1.5`}):(0,Z.jsx)(`span`,{className:d(`h-2 w-2 shrink-0 rounded-full`,y?`bg-warning`:e.status===`running`?`bg-secondary`:`bg-outline`),title:_}),(0,Z.jsxs)(u,{onContextMenu:t=>{t.preventDefault(),h(e.id)},to:{pathname:`/terminals/${e.id}`,search:x.toString()},title:`${e.name}\n${f}\n${e.cwd??``}\n${_}`,"aria-current":s?`page`:void 0,className:`flex-1 min-w-0`,onKeyDown:t=>{(t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`)&&(t.preventDefault(),h(e.id))},children:[(0,Z.jsxs)(`div`,{className:d(`flex min-w-0 items-center gap-1.5 font-body text-xs`,s?`text-on-surface font-medium`:`text-on-surface`),children:[(0,Z.jsx)(p,{size:11,className:`shrink-0`,"aria-label":f}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 font-label text-xs text-on-surface-variant min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.host&&(0,Z.jsxs)(`span`,{"data-testid":`terminal-item-host`,className:`text-primary`,children:[e.host,g?` · `:``]}),g||!e.host&&f]}),(0,Z.jsx)(`span`,{"data-testid":`terminal-item-state`,className:d(`ml-auto truncate`,y?`text-warning`:`text-on-surface-variant`),children:_})]})]}),(0,Z.jsx)(Et,{terminal:e,open:m===e.id,onOpenChange:t=>h(t?e.id:null),onRename:i,onDuplicate:a,onClose:n,canDuplicate:o(e),pending:c})]},e.id)})]})]})}function Q(e){return`kind`in e?[e]:[...Q(e.first),...Q(e.second)]}function Ot(e,t,n){return e.id===t?n(e):`kind`in e?e:{...e,first:Ot(e.first,t,n),second:Ot(e.second,t,n)}}function kt(e,t){return`kind`in e?e:e.first.id===t?e.second:e.second.id===t?e.first:{...e,first:kt(e.first,t),second:kt(e.second,t)}}function At(e,t=0){if(!e||typeof e!=`object`||t>7)return null;let n=e;if(typeof n.id!=`string`||n.id.length>100)return null;if([`terminal`,`git`,`files`].includes(String(n.kind))&&(n.terminalId===null||typeof n.terminalId==`string`))return{id:n.id,kind:n.kind,terminalId:n.terminalId};if(n.direction!==`row`&&n.direction!==`column`||typeof n.ratio!=`number`||!Number.isFinite(n.ratio))return null;let r=At(n.first,t+1),i=At(n.second,t+1);if(!r||!i)return null;let a={id:n.id,direction:n.direction,ratio:Math.max(20,Math.min(80,n.ratio)),first:r,second:i},o=Q(a);if(o.length>8||new Set(o.map(e=>e.id)).size!==o.length)return null;let s=o.filter(e=>e.kind===`terminal`&&e.terminalId).map(e=>e.terminalId);return new Set(s).size===s.length?a:null}var jt=(0,X.lazy)(()=>T(()=>import(`./FileEditor-wRs221QU.js`).then(e=>({default:e.FileEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]))),Mt=new Map;function Nt(e){let t=e.split(`.`).pop()?.toLowerCase();return[`ts`,`tsx`,`js`,`jsx`,`py`,`sh`,`css`,`html`,`rs`,`go`].includes(t??``)?Ze:[`json`,`yml`,`yaml`,`toml`,`xml`].includes(t??``)?qe:[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`].includes(t??``)?$e:[`md`,`txt`,`log`,`csv`].includes(t??``)?G:tt}function Pt({terminalId:e,path:t,selected:n,expanded:r,toggle:a,select:o,changes:s}){let c=i({queryKey:[`checkout-files`,e,t],queryFn:()=>x.git.files(e,t)});return(0,Z.jsxs)(`ul`,{className:t?`ml-3 border-l border-outline/20 pl-1`:``,children:[c.isPending&&(0,Z.jsx)(`li`,{className:`px-3 py-2 text-xs text-on-surface-variant`,children:`Loading files…`}),c.error&&(0,Z.jsx)(`li`,{role:`alert`,className:`px-3 py-2 text-xs text-error`,children:c.error.message}),c.data?.entries?.length===0&&(0,Z.jsx)(`li`,{className:`px-3 py-2 text-xs text-on-surface-variant`,children:`Empty folder`}),c.data?.entries?.map(t=>{let i=r.has(t.path),c=s.find(e=>e.path===t.path),l=c?ge(c):null,u=Nt(t.name);return t.directory&&(u=i?ce:M),(0,Z.jsxs)(`li`,{children:[(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`file-entry`,"data-path":t.path,"aria-expanded":t.directory?i:void 0,"aria-current":!t.directory&&n===t.path?`true`:void 0,title:t.path,onClick:()=>t.directory?a(t.path):o(t.path),className:`flex min-h-11 sm:min-h-8 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-[13px] focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-focus ${n===t.path?`bg-surface-highest text-on-surface`:`hover:bg-surface`}`,children:[(0,Z.jsx)(`span`,{className:`flex w-3 shrink-0 items-center`,children:t.directory&&(0,Z.jsx)(ie,{size:12,className:`transition-transform ${i?`rotate-90`:``}`})}),(0,Z.jsx)(u,{size:15,className:`shrink-0 ${t.directory,`text-on-surface-variant`}`}),(0,Z.jsx)(`span`,{className:`truncate flex-1`,children:t.name}),l&&(0,Z.jsx)(`span`,{"data-testid":`file-change-badge`,title:l.label,className:`shrink-0 text-xs ${l.conflict?`text-error`:`text-warning`}`,children:l.conflict?`U`:c?.index===`?`?`?`:l.label.slice(0,1)})]}),t.directory&&i&&(0,Z.jsx)(Pt,{terminalId:e,path:t.path,selected:n,expanded:r,toggle:a,select:o,changes:s})]},t.path)}),c.data?.truncated&&(0,Z.jsx)(`li`,{className:`px-3 py-2 text-xs text-on-surface-variant`,children:`Showing the first 500 entries.`})]})}function Ft({terminal:e,active:t=!0,paneId:n}){let a=`${e.id}:${n}`,o=Mt.get(a),[c,l]=s(),u=t&&c.get(`view`)===`files`&&(c.get(`paneTerminal`)??e.id)===e.id?c.get(`file`):null,[d,f]=(0,X.useState)(u??o?.selected??null),[p,m]=(0,X.useState)(()=>[...new Set([...o?.openFiles??[],...u?[u]:[]])]),[h,g]=(0,X.useState)(o?.dirtyFiles??new Set),[_,v]=(0,X.useState)(!1),[b,S]=(0,X.useState)(!0),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(o?.expanded??new Set);(0,X.useEffect)(()=>{for(Mt.delete(a),Mt.set(a,{selected:d,openFiles:p,dirtyFiles:h,expanded:T});Mt.size>64;){let e=Mt.keys().next().value;if(e===void 0)break;Mt.delete(e)}},[a,d,p,h,T]),(0,X.useEffect)(()=>{if(t&&(u!==d&&(f(u),v(!1)),u)){m(e=>e.includes(u)?e:[...e,u]);let e=u.split(`/`);E(t=>new Set([...t,...e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`))]))}},[u,t,d]);let ee=r(),D=i({queryKey:[`checkout-files`,e.id,``],queryFn:()=>x.git.files(e.id,``)}),O=i({queryKey:[`checkout-files`,e.id,d],queryFn:()=>x.git.files(e.id,d??``),enabled:d!==null,staleTime:1/0,refetchOnWindowFocus:!1}),k=D.data?.root??e.cwd??``,A=i({queryKey:[`git`,e.id,`status`],queryFn:()=>x.git.status(e.id)}),j=se(k)||`Files`;function M(t){t!==d&&(!_||window.confirm(`Leave this file with unsaved changes? Your draft will be kept in this page.`))&&(v(!1),t&&m(e=>e.includes(t)?e:[...e,t]),f(t),w(!1),l(n=>{let r=new URLSearchParams(n);return r.set(`view`,`files`),r.set(`paneTerminal`,e.id),t===null?r.delete(`file`):r.set(`file`,t),r}))}function P(e){let t=p.filter(t=>t!==e);if(d===e){if(_&&!window.confirm(`Close this file with unsaved changes? Your draft will be kept in this page.`))return;v(!1);let n=t[Math.max(0,p.indexOf(e)-1)]??null;f(n),l(e=>{let t=new URLSearchParams(e);return n?t.set(`file`,n):t.delete(`file`),t})}else if(h.has(e)&&!window.confirm(`Close this file with unsaved changes? Your draft will be kept in this page.`))return;m(t)}function F(e){if(!(e.target instanceof HTMLButtonElement))return;let t=[...e.currentTarget.querySelectorAll(`button[data-path]`)],n=t.indexOf(e.target),r=e.target.dataset.path??``,i=e.target.getAttribute(`aria-expanded`),a;if(e.key===`ArrowDown`)a=t[n+1];else if(e.key===`ArrowUp`)a=t[n-1];else if(e.key===`Home`)a=t[0];else if(e.key===`End`)a=t[t.length-1];else if(e.key===`ArrowRight`)i===`false`?e.target.click():i===`true`&&(a=t[n+1]);else if(e.key===`ArrowLeft`)i===`true`?e.target.click():a=t.find(e=>e.dataset.path===r.split(`/`).slice(0,-1).join(`/`));else return;e.preventDefault(),a?.focus()}return(0,Z.jsxs)(`div`,{"data-testid":`file-panel`,className:`file-panel flex flex-1 min-h-0 min-w-0 flex-col overflow-hidden text-sm`,children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-surface-highest px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-xs font-medium text-on-surface-variant`,children:`Explorer`}),d!==null&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":`files-browser-toggle`,"aria-expanded":C,onClick:()=>w(!C),className:`md:hidden min-h-11 rounded-md px-2 text-sm text-primary hover:bg-surface`,children:C?`Show document`:`Browse files`}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`files-collapse`,"aria-label":`Collapse all folders`,title:`Collapse all folders`,disabled:T.size===0,onClick:()=>E(new Set),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface hover:text-primary disabled:opacity-30 disabled:hover:bg-transparent`,children:(0,Z.jsx)(q,{size:14})}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`files-refresh`,"aria-label":`Refresh files`,title:`Refresh files`,onClick:()=>void ee.invalidateQueries({queryKey:[`checkout-files`,e.id]}),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface hover:text-primary`,children:(0,Z.jsx)(N,{size:14,className:D.isFetching?`animate-spin`:``})})]}),p.length>0&&(0,Z.jsx)(`nav`,{"data-testid":`file-tabs`,"aria-label":`Open files`,className:`flex shrink-0 min-w-0 overflow-x-auto border-b border-outline-variant bg-background`,children:p.map(e=>(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center border-r border-outline-variant ${e===d?`bg-surface`:``}`,children:[(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`file-tab`,"data-path":e,"aria-current":e===d?`page`:void 0,title:e,onClick:()=>M(e),className:`flex items-center gap-2 max-w-56 min-h-11 sm:min-h-9 pl-3 pr-1 text-xs ${e===d?`text-on-surface`:`text-on-surface-variant`}`,children:[(0,Z.jsx)(tt,{size:13,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()}),h.has(e)&&(0,Z.jsx)(`span`,{title:`Unsaved changes`,children:`●`})]}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`file-tab-close`,"aria-label":`Close ${e}`,title:`Close ${e}`,onClick:()=>P(e),className:`flex min-h-11 min-w-11 sm:min-h-9 sm:min-w-8 items-center justify-center text-on-surface-variant hover:text-on-surface`,children:(0,Z.jsx)(y,{size:12})})]},e))}),(0,Z.jsxs)(`div`,{className:`file-panel-body`,"data-preview":d!==null,"data-browser-open":C,children:[(0,Z.jsxs)(`nav`,{"aria-label":`Project files`,"data-testid":`files-tree`,onKeyDown:F,className:`file-panel-tree overflow-auto p-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`files-root`,"data-path":``,title:k,"aria-expanded":b,onClick:()=>S(e=>!e),className:`mb-1 flex min-h-11 sm:min-h-8 w-full min-w-0 items-center gap-2 rounded px-2 text-left text-[13px] font-medium hover:bg-surface focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,Z.jsx)(ie,{size:12,className:`shrink-0 transition-transform ${b?`rotate-90`:``}`}),(0,Z.jsx)(ce,{size:16,className:`shrink-0 text-primary`}),(0,Z.jsx)(`span`,{className:`truncate`,children:j})]}),b&&(0,Z.jsx)(`div`,{className:`ml-3 border-l border-outline/20 pl-1`,children:(0,Z.jsx)(Pt,{terminalId:e.id,path:``,selected:d,expanded:T,select:M,toggle:e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),changes:A.data?.files??[]})})]}),d!==null&&(0,Z.jsxs)(`section`,{"aria-label":`File preview`,className:`file-panel-preview flex flex-col`,children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 bg-background px-3 py-1.5`,children:[(0,Z.jsx)(tt,{size:14,className:`shrink-0 text-primary`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:`truncate text-xs font-medium`,children:[d.split(`/`).pop(),_&&(0,Z.jsx)(`span`,{className:`ml-2 text-primary`,title:`Unsaved changes`,children:`●`})]}),(0,Z.jsx)(`p`,{title:d,className:`truncate pt-0.5 text-xs text-on-surface-variant`,children:d})]}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`file-preview-close`,"aria-label":`Close file preview`,onClick:()=>M(null),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md p-1 text-on-surface-variant hover:bg-surface`,children:(0,Z.jsx)(y,{size:14})})]}),O.isPending&&(0,Z.jsx)(`p`,{className:`p-3 text-xs text-on-surface-variant`,children:`Loading preview…`}),O.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`p-3 text-xs text-error`,children:O.error.message}),O.data?.binary&&(0,Z.jsx)(`p`,{className:`p-3 text-xs text-on-surface-variant`,children:`Binary file; text preview unavailable.`}),O.data?.content!=null&&(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`p`,{className:`p-3 text-xs text-on-surface-variant`,children:`Loading editor…`}),children:(0,Z.jsx)(jt,{terminalId:e.id,path:d,content:O.data.content,readOnly:O.data.truncated,onDirty:e=>{v(e),g(t=>{if(t.has(d)===e)return t;let n=new Set(t);return e?n.add(d):n.delete(d),n})}},`${e.id}:${d}`)}),O.data?.truncated&&(0,Z.jsx)(`p`,{className:`px-3 py-1 text-xs text-on-surface-variant`,children:`Preview limited to 200 KB.`})]})]})]})}function It(e,t){if(!e)return!1;let n=e=>e.replace(/\\/g,`/`).replace(/\/$/,``);return/^[A-Za-z]:[\\/]/.test(t)?n(e).toLowerCase()===n(t).toLowerCase():n(e)===n(t)}function Lt({terminal:e,paneId:t}){let[n,r]=s(),a=W(),o=i({queryKey:[`git`,e.id,`status`],queryFn:()=>x.git.status(e.id)}),c=i({queryKey:[`sessions`,`live`,!1],queryFn:()=>x.sessions.live({active:!1,limit:5e3}),enabled:!!e.live_session_id,select:e=>e.sessions}),l=i({queryKey:[`git`,e.id,`github`,o.data?.branch],queryFn:()=>x.git.checkoutGithub(e.id),enabled:!!o.data?.root,staleTime:6e4,refetchInterval:6e4}),d=o.data,f=c.data?.find(t=>t.id===e.live_session_id)?.task??a.data?.find(e=>d?.root&&d.branch&&e.git_branch===d.branch&&It(e.git_worktree??e.git_repo,d.root)),p=l.data?.items.find(e=>e.kind===`pr`&&e.branch===d?.branch&&/^https:\/\/github\.com\//.test(e.url)),m=`items-center gap-1.5 min-h-8 min-w-0 text-xs text-on-surface-variant hover:text-on-surface`;return(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsxs)(u,{"data-testid":`pane-linked-task`,to:Y(`/tasks/${f.id}`,n.get(`project`)??`all`,n.toString()),title:`ORC task: ${f.title}`,"aria-label":`Open ORC task: ${f.title}`,className:`pane-task-context max-w-40 ${m}`,children:[(0,Z.jsx)(rt,{size:13,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:f.title})]}),p&&(0,Z.jsxs)(`div`,{className:`pane-pr-context items-center gap-2 shrink-0`,children:[(0,Z.jsxs)(`a`,{"data-testid":`pane-linked-pr`,href:p.url,onClick:n=>{n.ctrlKey||n.metaKey||n.shiftKey||n.altKey||l.data?.auth===`none`||(n.preventDefault(),r(n=>{let r=new URLSearchParams(n);return r.set(`view`,`git`),r.set(`pane`,t),r.set(`paneTerminal`,e.id),r.set(`pr`,String(p.number)),r.delete(`file`),r}))},target:`_blank`,rel:`noopener noreferrer`,title:`PR #${p.number}: ${p.title} (${p.state})`,"aria-label":`Review PR #${p.number}: ${p.title}`,className:`inline-flex shrink-0 ${m}`,children:[(0,Z.jsx)(oe,{size:13}),`#`,p.number]}),(0,Z.jsx)(`a`,{href:p.url,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`pane-pr-browser`,"aria-label":`Open PR in browser`,title:`Open PR in browser`,className:`inline-flex ${m}`,children:(0,Z.jsx)(F,{size:12})}),l.data?.auth!==`none`&&p.ci&&/^https:\/\/github\.com\//.test(p.ci.url)&&(0,Z.jsxs)(`a`,{"data-testid":`pane-ci-status`,href:p.ci.url,target:`_blank`,rel:`noopener noreferrer`,title:`${p.ci.total} checks/statuses on the PR's current commit`,"aria-label":`CI ${p.ci.state===`none`?`has no checks`:p.ci.state}`,className:`inline-flex items-center gap-1 text-xs ${p.ci.state===`failure`?`text-error`:p.ci.state===`pending`?`text-warning`:`text-on-surface-variant`}`,children:[p.ci.state===`success`?(0,Z.jsx)(w,{size:13}):p.ci.state===`failure`?(0,Z.jsx)(le,{size:13}):p.ci.state===`pending`?(0,Z.jsx)(U,{size:13}):(0,Z.jsx)(K,{size:13}),p.ci.state===`none`?`No checks`:`CI ${p.ci.state===`success`?`passed`:p.ci.state===`failure`?`failed`:`pending`}`]})]})]})}function Rt(e){let{node:t,root:n,terminals:r,active:i,focus:a,change:o,close:s,renderTerminal:c,mobile:l,zoomed:u,zoom:d}=e;if(!(`kind`in t)){let n=t.direction===`row`,r=e=>o(t.id,t=>`kind`in t?t:{...t,ratio:Math.max(20,Math.min(80,e))});return(0,Z.jsxs)(`div`,{"data-testid":`workspace-split`,className:`flex flex-1 min-w-0 min-h-0 overflow-hidden`,style:{flexDirection:l?`column`:t.direction},children:[(0,Z.jsx)(`div`,{className:`${l&&!Q(t.first).some(e=>e.id===i)||u&&!Q(t.first).some(e=>e.id===u)?`hidden`:`flex`} min-w-0 min-h-0`,style:{flex:l||u?`1 1 0%`:`${t.ratio} 1 0%`},children:(0,Z.jsx)(Rt,{...e,node:t.first})}),(0,Z.jsx)(`div`,{role:`separator`,"aria-label":n?`Resize panes horizontally`:`Resize panes vertically`,"aria-orientation":n?`vertical`:`horizontal`,"aria-valuenow":Math.round(t.ratio),"aria-valuemin":20,"aria-valuemax":80,tabIndex:0,"data-testid":`workspace-resize`,className:`${l||u?`hidden`:``} shrink-0 bg-border hover:bg-surface focus-visible:bg-focus touch-none ${n?`w-2 cursor-col-resize`:`h-2 cursor-row-resize`}`,onDoubleClick:()=>r(50),onKeyDown:e=>{let i=n?`ArrowLeft`:`ArrowUp`,a=n?`ArrowRight`:`ArrowDown`;(e.key===i||e.key===a)&&(e.preventDefault(),r(t.ratio+(e.key===i?-5:5)))},onPointerDown:e=>{e.preventDefault();let t=e.currentTarget,i=t.parentElement?.getBoundingClientRect();if(!i)return;t.setPointerCapture(e.pointerId);let a=e=>r(100*(n?(e.clientX-i.left)/i.width:(e.clientY-i.top)/i.height)),o=()=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}}),(0,Z.jsx)(`div`,{className:`${l&&!Q(t.second).some(e=>e.id===i)||u&&!Q(t.second).some(e=>e.id===u)?`hidden`:`flex`} min-w-0 min-h-0`,style:{flex:l||u?`1 1 0%`:`${100-t.ratio} 1 0%`},children:(0,Z.jsx)(Rt,{...e,node:t.second})})]})}let p=new Set(Q(n).filter(e=>e.id!==t.id&&e.kind===`terminal`).map(e=>e.terminalId)),m=r.find(e=>e.id===t.terminalId),h=e=>o(t.id,t=>`kind`in t?{...t,...e}:t),g=e=>{if(Q(n).length>=8)return;d(null);let r=crypto.randomUUID();o(t.id,n=>({id:crypto.randomUUID(),direction:e,ratio:50,first:n,second:{id:r,kind:t.kind===`git`?`files`:`git`,terminalId:t.terminalId}})),a(r)};return(0,Z.jsxs)(`section`,{"data-testid":`workspace-pane`,"data-kind":t.kind,"data-active":i===t.id?`true`:`false`,onPointerDownCapture:()=>a(t.id),onFocusCapture:()=>a(t.id),className:`terminal-workspace-pane flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden border ${i===t.id?`border-outline-variant`:`border-transparent`}`,children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 gap-1 items-center p-1.5 bg-background border-b border-outline-variant`,children:[(0,Z.jsx)(`fieldset`,{"data-testid":`pane-view`,"data-view":t.kind,"aria-label":`Pane view`,className:`flex items-center rounded-md bg-surface p-0.5`,children:[{kind:`terminal`,label:`Terminal`,icon:de},{kind:`files`,label:`Files`,icon:I},{kind:`git`,label:`Git`,icon:Be}].map(({kind:e,label:n,icon:i})=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`pane-view-${e}`,"aria-label":n,"aria-pressed":t.kind===e,onClick:()=>{h({kind:e,terminalId:e===`terminal`&&p.has(t.terminalId)?r.find(e=>!p.has(e.id))?.id??null:t.terminalId})},className:`inline-flex items-center justify-center gap-1.5 min-h-11 sm:min-h-8 rounded px-2 text-xs ${t.kind===e?`bg-surface-highest text-on-surface`:`text-on-surface-variant hover:text-on-surface`}`,children:[(0,Z.jsx)(i,{size:14}),(0,Z.jsx)(`span`,{className:`pane-view-label`,children:n})]},e))}),(0,Z.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center gap-3 overflow-hidden px-1`,children:m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-on-surface`,title:`${m.name} · ${m.host??`Local`} · ${m.cwd??``}`,children:[(0,Z.jsx)(`span`,{"data-testid":`terminal-name`,children:m.name}),m.host&&(0,Z.jsx)(`span`,{"data-testid":`terminal-selected-host`,className:`ml-2 text-on-surface-variant`,children:m.host})]}),t.kind!==`git`&&(0,Z.jsx)(`div`,{className:`pane-checkout-context min-w-0 max-w-72`,children:(0,Z.jsx)(Tt,{terminal:m,paneId:t.id})}),(0,Z.jsx)(Lt,{terminal:m,paneId:t.id})]})}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`pane-terminal`,"data-terminal-id":m?.id??``,"aria-label":`Find and switch terminal`,"aria-haspopup":`dialog`,title:`Find terminal: ${m?.name??`None selected`}`,className:`shrink-0 inline-flex items-center justify-center min-h-11 w-11 sm:min-h-8 sm:w-10 rounded-md text-on-surface-variant hover:bg-surface`,onClick:()=>Ae({currentId:m?.id??null,select:e=>{let r=Q(n).find(t=>t.kind===`terminal`&&t.terminalId===e);t.kind===`terminal`&&r&&r.id!==t.id?(d(null),a(r.id)):h({terminalId:e})}}),children:[(0,Z.jsx)(de,{size:16,"aria-hidden":`true`}),(0,Z.jsx)(C,{size:11,"aria-hidden":`true`})]}),m&&e.renderActions(m,i===t.id),(0,Z.jsxs)(`div`,{className:`pane-extra-actions items-center gap-1`,children:[(0,Z.jsx)(f,{label:`Split side by side`,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-split-horizontal`,"aria-label":`Split side by side`,disabled:Q(n).length>=8,onClick:()=>g(`row`),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-primary hover:bg-surface disabled:opacity-40`,children:(0,Z.jsx)(z,{size:16})})}),(0,Z.jsx)(f,{label:`Split top and bottom`,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-split-vertical`,"aria-label":`Split top and bottom`,disabled:Q(n).length>=8,onClick:()=>g(`column`),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-primary hover:bg-surface disabled:opacity-40`,children:(0,Z.jsx)(lt,{size:16})})}),Q(n).length>1&&(0,Z.jsx)(f,{label:u?`Restore split layout`:`Expand pane`,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-focus`,"aria-label":u?`Restore split layout`:`Expand pane`,"aria-pressed":!!u,onClick:()=>d(u?null:t.id),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-on-surface-variant hover:bg-surface`,children:u?(0,Z.jsx)(st,{size:15}):(0,Z.jsx)(at,{size:15})})}),Q(n).length>1&&(0,Z.jsx)(f,{label:`Close pane (keep terminal running)`,description:`Close pane; terminal keeps running`,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-close`,"aria-label":`Close pane (keep terminal running)`,onClick:()=>s(t.id),className:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 inline-flex items-center justify-center rounded-md text-on-surface-variant hover:bg-surface`,children:(0,Z.jsx)(y,{size:16})})})]}),(0,Z.jsx)(`div`,{"data-pane-menu":!0,className:`relative`,children:(0,Z.jsxs)(Oe,{children:[(0,Z.jsx)(_e,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-actions`,"aria-label":`Pane actions`,title:`Pane actions`,className:`list-none flex min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 [@media(pointer:coarse)]:min-h-11 [@media(pointer:coarse)]:min-w-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface cursor-pointer`,children:(0,Z.jsx)(B,{size:18})})}),(0,Z.jsxs)(pe,{portalled:!1,"data-testid":`pane-actions-menu`,align:`end`,className:`w-60 p-2`,children:[m&&(0,Z.jsx)(Ie,{asChild:!0,children:e.renderOptions(m)}),(0,Z.jsxs)(`div`,{className:`pane-menu-layout-actions`,children:[(0,Z.jsx)(Ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-action-split-horizontal`,disabled:Q(n).length>=8,onClick:()=>g(`row`),className:`w-full text-left min-h-11 px-2 rounded hover:bg-surface`,children:`Split side by side`})}),(0,Z.jsx)(Ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-action-split-vertical`,disabled:Q(n).length>=8,onClick:()=>g(`column`),className:`w-full text-left min-h-11 px-2 rounded hover:bg-surface`,children:`Split top and bottom`})}),Q(n).length>1&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-action-focus`,onClick:()=>d(u?null:t.id),className:`w-full text-left min-h-11 px-2 rounded hover:bg-surface`,children:u?`Restore split layout`:`Expand pane`})}),(0,Z.jsx)(Ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-testid":`pane-action-close`,onClick:()=>s(t.id),className:`w-full text-left min-h-11 px-2 rounded hover:bg-surface`,children:`Close pane`})})]})]})]})]})})]}),m?t.kind===`terminal`?c(m.id):t.kind===`git`?(0,Z.jsx)(Re,{terminal:m,paneId:t.id},m.id):(0,Z.jsx)(Ft,{terminal:m,active:i===t.id,paneId:t.id},m.id):(0,Z.jsx)(`p`,{className:`p-4 text-sm text-on-surface-variant`,children:t.terminalId?`This terminal is unavailable or has been closed. Choose another terminal from the selector.`:`Choose a terminal or launch one from New terminal.`})]})}function zt(e){let t=ue(`lg`),[n,r]=s(),i=n.get(`view`),a=n.get(`pane`),o=n.get(`paneTerminal`),c=n.get(`file`),[l,u]=(0,X.useState)(()=>{try{let e=At(JSON.parse(localStorage.getItem(`orc_workspace_layout`)??`null`));if(e)return e}catch{}return{id:crypto.randomUUID(),kind:`terminal`,terminalId:e.selected.id}}),d=(0,X.useMemo)(()=>{let t=i===`files`||i===`git`?i:`terminal`,n=Q(l),r=n.find(e=>e.id===a)??n[0];if(!r)return l;let s=o??e.selected.id;return t===`terminal`&&n.some(e=>e.id!==r.id&&e.kind===`terminal`&&e.terminalId===s)||r.kind===t&&r.terminalId===s?l:Ot(l,r.id,e=>`kind`in e?{...e,kind:t,terminalId:s}:e)},[l,i,a,o,e.selected.id]),[f,p]=(0,X.useState)(()=>Q(d)[0]?.id??d.id),[m,h]=(0,X.useState)(null),g=(0,X.useRef)(d);g.current=d;let _=(0,X.useRef)(new Map);(0,X.useEffect)(()=>{if(i!==`files`)return;let t=Q(g.current).find(e=>e.id===a)??Q(g.current)[0];if(!t)return;let n=`${t.id}:${o??e.selected.id}`;c?_.current.set(n,c):_.current.delete(n)},[i,a,o,c,e.selected.id]),(0,X.useEffect)(()=>{let t=i===`files`||i===`git`?i:`terminal`,n=g.current,r=Q(n),s=r.find(e=>e.id===a)??r[0];if(!s)return;h(e=>e&&e!==s.id?null:e);let c=o??e.selected.id,l=t===`terminal`?r.find(e=>e.id!==s.id&&e.kind===`terminal`&&e.terminalId===c):void 0;p(l?l.id:s.id)},[i,a,o,e.selected.id]);function v(e,t){let i=Q(e).find(e=>e.id===t);if(!i)return;let a=new URLSearchParams(n);a.set(`view`,i.kind),a.set(`pane`,i.id),i.terminalId?a.set(`paneTerminal`,i.terminalId):a.delete(`paneTerminal`);let o=_.current.get(`${i.id}:${i.terminalId}`);i.kind===`files`&&o?a.set(`file`,o):a.delete(`file`),a.toString()!==n.toString()&&r(a)}function y(e){e!==f&&(p(e),m&&h(e),v(g.current,e))}(0,X.useEffect)(()=>{d!==l&&u(e=>e===l?d:e);try{localStorage.setItem(`orc_workspace_layout`,JSON.stringify(d))}catch{}},[d,l]);let b=Q(d),x=b.find(e=>e.id===f)??b[0];return(0,Z.jsxs)(`div`,{"data-testid":`terminal-workspace`,className:`flex flex-col flex-1 min-h-0 min-w-0`,children:[!t&&b.length>1&&(0,Z.jsx)(`nav`,{"aria-label":`Workspace panes`,"data-testid":`mobile-workspace-panes`,className:`flex shrink-0 gap-1 overflow-x-auto border-b border-outline-variant bg-background px-2 py-1`,children:b.map((e,t)=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`mobile-workspace-pane`,"aria-current":e.id===x.id?`page`:void 0,onClick:()=>y(e.id),className:`min-h-11 shrink-0 rounded-md px-3 text-sm ${e.id===x.id?`bg-surface-highest text-on-surface`:`text-on-surface-variant hover:bg-surface`}`,children:[e.kind===`terminal`?`Terminal`:e.kind===`files`?`Files`:`Git`,` `,t+1]},e.id))}),(0,Z.jsx)(Rt,{...e,node:d,root:d,active:x.id,zoomed:b.some(e=>e.id===m)?m:null,zoom:h,mobile:!t,focus:y,change:(e,t)=>{let n=Ot(g.current,e,t);g.current=n,u(n),v(n,Q(n).find(t=>t.id===e)?.id??x.id)},close:e=>{h(null);let t=kt(g.current,e);g.current=t,u(t);let n=f===e?Q(t)[0]?.id??t.id:f;p(n),v(t,n)}})]})}function Bt(e,t){return t?.state===`merged`&&!!e.head&&t.head_sha===e.head}function Vt(e,t){return!e.main&&!e.dirty&&!e.locked&&!e.active_terminal&&!!(e.merged||e.prunable||Bt(e,t))}var Ht={open:`text-success`,merged:`text-primary`,closed:`text-on-surface-variant`};function $({className:e,children:t}){return(0,Z.jsx)(`span`,{className:d(`shrink-0 rounded-md bg-surface-highest px-1.5 font-label text-xs leading-5`,e),children:t})}function Ut({launchers:e,host:t,onCreate:n,className:o}){let[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(`all`),[f,m]=(0,X.useState)({}),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),T=r(),A=i({queryKey:[`worktrees`,`registry`],queryFn:()=>x.git.registry(),enabled:s}),j=i({queryKey:[`worktrees`,`registry`,`pulls`],queryFn:()=>x.git.registryPulls(),enabled:s,staleTime:6e4,retry:!1}),M=pt(),P=(e,t)=>t?j.data?.repos.find(t=>t.root===e)?.pulls[t]:void 0,I=(A.data?.repos??[]).flatMap(e=>e.worktrees.map(t=>({root:e.root??``,tree:t}))),L=a({mutationFn:()=>x.git.cleanup(Object.values(f).map(e=>{let t=I.find(({tree:t})=>t.path===e.path),n=t&&(t.tree.merged||Bt(t.tree,P(t.root,t.tree.branch)));return{...e,delete_branch:_&&!!(n&&t?.tree.branch?.startsWith(`orc/`))}})),onSuccess:()=>{m({}),g(!1),T.invalidateQueries({queryKey:[`worktrees`]})}}),R=I.filter(({root:e,tree:t})=>Vt(t,P(e,t.branch))),z=Object.keys(f).length,B=async e=>{w(null);try{await M.mutateAsync({cwd:e.cwd,path:e.worktree.path,force:e.step===`dirty`}),b(null),m(({[e.worktree.path]:t,...n})=>n)}catch(t){if(t instanceof S&&t.code===`WORKTREE_DIRTY`){b({...e,step:`dirty`});return}b(null),w(t instanceof Error?t.message:String(t))}},V=async(e,r)=>{w(null),await n({...yt(e,r.path,!1),host:t})&&c(!1)},H=(e,t,n)=>m(r=>{let i={...r};return n?i[t]={cwd:e,path:t}:delete i[t],i});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(p,{variant:`outline`,size:`sm`,"data-testid":`worktree-manager-open`,onClick:()=>c(!0),className:d(`min-h-11 sm:min-h-8 gap-1.5`,o),children:[(0,Z.jsx)(Be,{size:14}),`Worktrees`]}),(0,Z.jsx)(k,{open:s,onOpenChange:c,children:(0,Z.jsxs)(ee,{"data-testid":`worktree-manager`,className:`max-w-3xl gap-3 bg-surface p-4 sm:p-6 border-surface-highest`,children:[(0,Z.jsxs)(E,{className:`pr-8 text-left`,children:[(0,Z.jsx)(D,{className:`font-headline text-base text-on-surface`,children:`Worktrees`}),(0,Z.jsx)(O,{className:`font-body text-xs text-on-surface-variant`,children:`Checkouts of every repository ORC knows about: project folders, sessions and recent terminals. Merged, squash-merged and missing worktrees can be cleaned up.`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex gap-1`,children:[[`all`,`All`],[`cleanable`,`Cleanable (${R.length})`],[`pr`,`With PR`]].map(([e,t])=>(0,Z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":l===e,"data-testid":`worktree-filter-${e}`,onClick:()=>u(e),className:d(`min-h-11 sm:min-h-8 rounded-md px-2 font-label text-xs`,l===e?`bg-surface-highest text-on-surface`:`text-on-surface-variant hover:bg-surface-high`),children:t},e))}),(0,Z.jsxs)(p,{variant:`ghost`,size:`sm`,"data-testid":`worktree-registry-refresh`,onClick:()=>{A.refetch(),j.refetch()},disabled:A.isFetching,className:`ml-auto min-h-11 sm:min-h-8 gap-1.5`,children:[(0,Z.jsx)(N,{size:14,className:d(A.isFetching&&`animate-spin`)}),`Refresh`]})]}),j.data?.auth===`none`&&(0,Z.jsx)(`p`,{className:`font-body text-xs text-on-surface-variant`,children:`Sign in with gh or set a GitHub token to match pull requests to branches.`}),[...j.data?.errors??[],...j.error?[{repo:`GitHub`,error:j.error.message}]:[]].map(e=>(0,Z.jsxs)(`p`,{className:`font-body text-xs text-tertiary`,children:[e.repo,`: `,e.error]},e.repo)),(0,Z.jsxs)(`div`,{className:`min-h-0 space-y-4`,children:[A.isLoading&&(0,Z.jsx)(`p`,{className:`font-body text-sm text-on-surface-variant`,children:`Loading repositories…`}),A.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`font-body text-sm text-error`,children:A.error.message}),A.data?.repos.length===0&&(0,Z.jsx)(`p`,{className:`font-body text-sm text-on-surface-variant`,children:`No known repositories. Set a project folder or launch a terminal in a repository.`}),A.data?.repos.map(t=>{let n=t.root??``,r=j.data?.repos.find(e=>e.root===t.root)?.repo,i=t.worktrees.filter(e=>{let n=P(t.root,e.branch);return l===`cleanable`?Vt(e,n):l!==`pr`||!!n});return i.length?(0,Z.jsxs)(`section`,{"data-testid":`worktree-repo`,className:`space-y-1`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Z.jsx)(`h3`,{className:`font-label text-sm text-on-surface`,children:Se(n)}),r&&(0,Z.jsx)(`span`,{className:`font-body text-xs text-on-surface-variant`,children:r}),(0,Z.jsx)(`span`,{className:`basis-full break-all font-body text-xs text-outline`,children:n})]}),(0,Z.jsx)(`ul`,{className:`divide-y divide-surface-highest rounded-md border border-surface-highest`,children:i.map(r=>{let i=P(t.root,r.branch),a=Vt(r,i);return(0,Z.jsxs)(`li`,{"data-testid":`registry-worktree`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-2 py-1.5 sm:flex-nowrap`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`registry-worktree-select`,"aria-label":`Select ${r.branch??r.path} for cleanup`,title:a?`Select for cleanup`:`Only clean, inactive merged or missing worktrees can be cleaned`,disabled:!a||L.isPending,checked:!!f[r.path],onChange:e=>H(n,r.path,e.target.checked),className:`size-4 shrink-0 accent-primary`}),(0,Z.jsxs)(`div`,{"data-testid":`registry-worktree-label`,className:`min-w-0 flex-1 basis-[calc(100%-1.5rem)] sm:basis-0`,title:r.path,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 font-body text-sm text-on-surface`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 break-all`,children:r.branch??(r.head?r.head.slice(0,8):`detached`)}),r.main&&(0,Z.jsx)($,{children:`main`}),i&&(0,Z.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,"data-testid":`worktree-pr`,title:i.title,className:d(`inline-flex shrink-0 items-center gap-0.5 rounded-md bg-surface-highest px-1.5 font-label text-xs leading-5 hover:underline`,Ht[i.state]),children:[`#`,i.number,` `,i.draft&&i.state===`open`?`draft`:i.state,(0,Z.jsx)(F,{size:10})]}),r.merged&&!r.main&&(0,Z.jsx)($,{className:`text-primary`,children:`merged`}),!r.merged&&Bt(r,i)&&(0,Z.jsx)($,{className:`text-primary`,children:`squash-merged`}),r.upstream_gone&&(0,Z.jsx)($,{children:`upstream gone`}),r.prunable&&(0,Z.jsx)($,{className:`text-error`,children:`missing`}),r.dirty&&(0,Z.jsx)($,{className:`text-tertiary`,children:`dirty`}),r.locked&&(0,Z.jsx)($,{children:`locked`}),r.active_terminal&&(0,Z.jsxs)($,{className:`text-success`,children:[`running: `,r.active_terminal]})]}),(0,Z.jsx)(`div`,{className:`truncate font-body text-xs text-on-surface-variant`,children:r.path})]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center`,children:[!r.prunable&&e.map(e=>{let{label:t,icon:n}=ye(e);return(0,Z.jsx)(`button`,{type:`button`,"data-testid":`worktree-open-${e}`,onClick:()=>void V(e,r),title:`Open ${t} here`,"aria-label":`Open ${t} in ${r.path}`,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-surface-high hover:text-on-surface sm:min-h-8 sm:min-w-8`,children:(0,Z.jsx)(n,{size:14})},e)}),!r.main&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":`worktree-remove`,disabled:M.isPending||!!r.active_terminal,onClick:()=>b({cwd:n,worktree:r,step:`confirm`}),title:r.active_terminal?`Close its terminal first`:`Remove worktree`,"aria-label":`Remove worktree ${r.path}`,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-on-surface-variant hover:bg-error/15 hover:text-error disabled:opacity-40 sm:min-h-8 sm:min-w-8`,children:(0,Z.jsx)(ze,{size:14})})]})]},r.path)})})]},n):null}),A.data?.errors.map(e=>(0,Z.jsxs)(`p`,{role:`alert`,className:`font-body text-xs text-error wrap-break-word`,children:[e.cwd,`: `,e.error]},e.cwd))]}),C&&(0,Z.jsx)(`p`,{role:`alert`,className:`font-body text-xs text-error wrap-break-word`,children:C}),L.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`font-body text-xs text-error wrap-break-word`,children:L.error.message}),L.data?.results.map(e=>(0,Z.jsxs)(`p`,{"data-testid":`cleanup-result`,role:e.error?`alert`:void 0,className:d(`font-body text-xs break-all`,e.error?`text-error`:`text-on-surface-variant`),children:[e.path,`: `,e.removed?`removed`:e.error]},e.path)),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-surface-highest pt-3`,children:[(0,Z.jsx)(p,{variant:`ghost`,size:`sm`,"data-testid":`worktree-select-cleanable`,disabled:!R.length||L.isPending,onClick:()=>m(Object.fromEntries(R.map(({root:e,tree:t})=>[t.path,{cwd:e,path:t.path}]))),className:`min-h-11 sm:min-h-8`,children:`Select cleanable`}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 font-body text-xs text-on-surface-variant sm:min-h-8`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`cleanup-delete-branch`,checked:_,onChange:e=>v(e.target.checked),className:`accent-primary`}),`Also delete merged orc/* branches`]}),(0,Z.jsxs)(p,{size:`sm`,"data-testid":`worktree-cleanup`,disabled:!z||L.isPending,onClick:()=>g(!0),className:`ml-auto min-h-11 sm:min-h-8`,children:[`Clean selected (`,z,`)`]})]})]})}),(0,Z.jsx)(Ve,{open:h,title:`Clean selected worktrees?`,description:`Remove ${z} selected worktree folders. Dirty, locked, active and unmerged worktrees are refused. ${_?`Merged orc/* branches will also be deleted.`:`Branches are kept.`}`,confirmLabel:`Clean selected`,isPending:L.isPending,onConfirm:()=>L.mutate(),onCancel:()=>g(!1)}),(0,Z.jsx)(Ve,{open:y!==null,isPending:M.isPending,title:y?.step===`dirty`?`Discard uncommitted changes?`:`Remove worktree?`,description:y?.step===`dirty`?`${y.worktree.path} has uncommitted changes. Removing it deletes them for good.`:`Deletes the folder ${y?.worktree.path??``}. The branch ${y?.worktree.branch??``} is kept.`,confirmLabel:y?.step===`dirty`?`Discard and remove`:`Remove`,onConfirm:()=>{y&&(y.step===`confirm`&&y.worktree.dirty?b({...y,step:`dirty`}):B(y))},onCancel:()=>b(null)})]})}var Wt=256,Gt=160,Kt=480,qt=`shrink-0 inline-flex min-h-11 items-center rounded-md font-label text-sm text-primary hover:text-on-surface`;function Jt({liveSessionId:e}){let[t]=s(),n=t.get(`project`)??`all`,{data:r}=Ue(!1),i=r?.find(t=>t.id===e)?.task;return(0,Z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-3`,children:[(0,Z.jsx)(u,{to:`${Y(`/sessions`,n,t.toString())}&session=${encodeURIComponent(e)}`,"data-testid":`terminal-open-session`,className:qt,children:`Session`}),i&&(0,Z.jsx)(u,{to:Y(`/tasks/${i.id}`,n,t.toString()),"data-testid":`terminal-open-task`,title:i.title,className:qt,children:`Task`})]})}function Yt({liveSessionId:e}){let[t]=s(),{data:n,isLoading:r,error:i,refetch:a}=Ue(!1),o=n?.find(t=>t.id===e);return r?(0,Z.jsx)(ne,{className:`h-24 w-full max-w-md`}):i?(0,Z.jsx)(He,{message:i.message,onRetry:()=>a()}):(0,Z.jsxs)(`div`,{"data-testid":`no-session-terminal`,className:`max-w-md space-y-3 text-center`,children:[(0,Z.jsx)(`h2`,{className:`font-headline text-sm text-on-surface`,children:o?`No terminal is open for this session`:`Session not found`}),o&&(0,Z.jsx)(`p`,{className:`truncate font-body text-sm text-on-surface-variant`,children:o.name??o.summary??o.id}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[o&&(0,Z.jsx)(We,{session:o}),(0,Z.jsx)(u,{to:Y(`/terminals`,t.get(`project`)??`all`,t.toString()),className:qt,children:`All terminals`})]})]})}function Xt({children:e}){return(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-6`,children:e})}function Zt(){let{terminalId:e}=c(),[t]=s(),n=t.get(`session`),r=o(),{terminals:i,info:a,isLoading:u,error:d,refetch:f,lastActiveId:m,connectionOf:h,create:g,remove:_}=ae(),v=ue(`lg`),{data:y}=Me(),b=L({storageKey:`orc_terminal_sidebar_width`,initial:Wt,min:Gt,max:Kt}),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),T=(0,X.useRef)(null),[E,ee]=(0,X.useState)(null),[D,O]=(0,X.useState)(),k=D===void 0?y?.host??null:D,A=St(k,x),M=(0,X.useCallback)(e=>{e&&O(void 0),S(e)},[]);(0,X.useEffect)(()=>{if(t.get(`new`)!==`1`)return;O(t.has(`terminalHost`)?t.get(`terminalHost`)||null:void 0),S(!0);let e=new URLSearchParams(t);e.delete(`new`),e.delete(`terminalHost`),r({search:e.toString()},{replace:!0})},[t,r]);let[N,F]=(0,X.useState)(!1),[I,R]=(0,X.useState)(null),[z,V]=(0,X.useState)(null),[H,U]=(0,X.useState)(null),[re,W]=(0,X.useState)(null),ie=(0,X.useCallback)(async e=>{F(!0),R(null);try{let n=await g(e);return S(!1),r(Y(`/terminals/${n.id}`,t.get(`project`)??`all`,t.toString())),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{F(!1)}},[g,r,t]),oe=(0,X.useCallback)(async n=>{W(null);try{if(await _(n.id),V(null),n.id===e){let e=i.find(e=>e.id!==n.id);r(Y(e?`/terminals/${e.id}`:`/terminals`,t.get(`project`)??`all`,t.toString()),{replace:!0})}}catch(e){V(null),W(e instanceof Error?e.message:String(e))}},[_,e,i,r,t]),se=(0,X.useCallback)(e=>{e.status===`running`?V(e):oe(e)},[oe]),G=e=>!!a&&(e.host?y?.supported===!0:a.launchers.includes(e.kind)),ce=async e=>{if(G(e)&&!N){F(!0),W(null);try{let n=await g({kind:e.kind,host:e.host,...e.cwd?{cwd:e.cwd}:{},name:`${e.name.slice(0,113)} (copy)`}),i=new URLSearchParams(t);i.delete(`session`),i.delete(`file`),i.set(`view`,`terminal`),i.set(`paneTerminal`,n.id),r({pathname:`/terminals/${n.id}`,search:i.toString()})}catch(e){W(e instanceof Error?e.message:String(e))}finally{F(!1)}}};if(d&&!a)return(0,Z.jsx)(Xt,{children:(0,Z.jsx)(`div`,{"data-testid":`terminal-load-error`,children:(0,Z.jsx)(He,{message:d.message,onRetry:f})})});if(u||!a)return(0,Z.jsx)(Xt,{children:(0,Z.jsxs)(`div`,{role:`status`,"data-testid":`terminal-loading`,"aria-label":`Loading terminals`,className:`w-full max-w-md`,children:[(0,Z.jsx)(ne,{className:`h-40 w-full`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading terminals…`})]})});if(!a.ready)return(0,Z.jsx)(Xt,{children:(0,Z.jsxs)(`div`,{className:`max-w-md space-y-3 text-center`,children:[(0,Z.jsx)(`h2`,{className:`font-headline text-sm text-on-surface`,children:`Terminals are not available`}),(0,Z.jsx)(`p`,{className:`font-body text-sm text-on-surface-variant`,children:a.reason??`The API has not enabled terminals.`}),(0,Z.jsxs)(`p`,{className:`font-body text-xs text-on-surface-variant`,children:[`Terminals require Bun 1.4.2 or newer and can be turned off with`,` `,(0,Z.jsx)(`code`,{className:`text-primary`,children:`terminals.enabled: false`}),`.`]})]})});if(!e&&n){let e=te(i,n);return e?(0,Z.jsx)(l,{to:{pathname:P(e.id),search:t.toString()},replace:!0}):(0,Z.jsx)(Xt,{children:(0,Z.jsx)(Yt,{liveSessionId:n})})}if(!e&&i.length>0){let e=i.find(e=>e.id===m)??i[0];return(0,Z.jsx)(l,{to:{pathname:`/terminals/${e.id}`,search:t.toString()},replace:!0})}let K=e?i.find(t=>t.id===e):void 0,le=t.get(`paneTerminal`)??e,q=i.find(e=>e.id===le),J=i.find(e=>e.id===E)??q??K,de=(e,t=!1)=>(0,Z.jsxs)(p,{variant:`ghost`,size:t?`sm`:`icon`,"data-testid":`terminal-options`,"aria-label":`Terminal options`,className:t?`w-full justify-start`:`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8`,onClick:t=>{T.current=t.currentTarget.closest(`[data-pane-menu]`)?.querySelector(`[data-testid="pane-actions"]`)??t.currentTarget,ee(e?.id??null),w(!0)},children:[(0,Z.jsx)(B,{size:16}),t&&`Terminal options`]}),fe=(0,Z.jsx)(Ut,{launchers:a.launchers,host:a.host,onCreate:ie}),pe=(0,Z.jsx)(Ct,{draft:A,open:x,onOpenChange:M,launchers:k===a.host?a.launchers:[],host:k,pending:N,error:I,onCreate:ie,compact:!v,iconOnly:!0},k??`local`);return(0,Z.jsxs)(`div`,{className:`terminal-workspace-page flex h-full w-full min-h-0 bg-background`,children:[v&&(0,Z.jsxs)(`aside`,{"data-testid":`terminal-sidebar`,style:{width:b.width},className:`relative shrink-0 flex flex-col min-h-0 border-r border-outline-variant bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-3 py-1.5`,children:[(0,Z.jsx)(`h2`,{className:`min-w-0 flex-1 text-sm font-medium text-on-surface`,children:`Sessions`}),(0,Z.jsx)(Ge,{terminalId:e,label:`Open sessions view`,testId:`terminals-open-home`}),fe,pe]}),(0,Z.jsx)(Dt,{terminals:i,activeId:e??null,onClose:se,connectionOf:h,onRename:U,onDuplicate:e=>void ce(e),canDuplicate:G,pending:N}),(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize terminal list`,"aria-valuenow":b.width,"aria-valuemin":Gt,"aria-valuemax":Kt,tabIndex:0,"data-testid":`terminal-sidebar-resize`,title:`Drag to resize, double-click to reset`,className:`absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none hover:bg-surface-highest focus-visible:bg-focus`,...b.handleProps})]}),(0,Z.jsxs)(`section`,{className:`flex-1 min-w-0 min-h-0 flex flex-col`,children:[!v&&!K&&(0,Z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-2 py-1 border-b border-surface-highest`,children:[(0,Z.jsxs)(j,{"aria-label":`Terminal`,value:q?.id??``,onChange:e=>{let n=new URLSearchParams(t);n.delete(`file`),n.delete(`session`),n.has(`view`)&&n.set(`paneTerminal`,e.target.value),r({pathname:`/terminals/${e.target.value}`,search:n.toString()})},disabled:i.length===0,className:`flex-1 min-w-0 bg-background border border-control-border text-on-surface font-label text-base sm:text-sm min-h-11 px-2 py-2 rounded-md`,children:[i.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No terminals`}),i.length>0&&!q&&(0,Z.jsx)(`option`,{value:``,children:`Choose terminal`}),i.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:pe}),q&&(0,Z.jsx)(ut,{terminal:q},q.id),de(q)]}),K?(0,Z.jsxs)(Z.Fragment,{children:[re&&(0,Z.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error wrap-break-word`,children:re}),(0,Z.jsx)(zt,{selected:K,terminals:i,renderTerminal:e=>(0,Z.jsx)(ke,{terminalId:e}),renderActions:(e,t)=>!v&&t?(0,Z.jsx)(`div`,{className:`shrink-0`,children:pe}):null,renderOptions:e=>de(e,!0)})]}):(0,Z.jsx)(Xt,{children:(0,Z.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Z.jsx)(`p`,{className:`font-label text-xs text-on-surface-variant`,children:e?`Terminal not found`:`No terminals yet`}),(0,Z.jsx)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e?r(Y(`/terminals`,t.get(`project`)??`all`,t.toString())):S(!0),className:`font-label text-sm`,children:e?`Back to terminals`:`Start a terminal`})]})})]}),(0,Z.jsx)(Le,{open:C,onOpenChange:w,children:(0,Z.jsxs)(ve,{"aria-describedby":void 0,onCloseAutoFocus:e=>{e.preventDefault(),T.current?.focus()},children:[(0,Z.jsx)(Ce,{children:(0,Z.jsx)(xe,{children:`Terminal options`})}),(0,Z.jsxs)(me,{className:`space-y-4`,children:[J&&(0,Z.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,Z.jsx)(`p`,{className:`wrap-break-word font-medium`,children:J.name}),(0,Z.jsx)(`p`,{className:`break-all text-on-surface-variant`,children:J.cwd}),(0,Z.jsx)(`p`,{children:Ne(J,h(J.id))}),(0,Z.jsx)(ut,{terminal:J,showLabel:!0,onContinued:()=>{T.current=null,w(!1)}},J.id),J.live_session_id&&(0,Z.jsx)(Jt,{liveSessionId:J.live_session_id}),(0,Z.jsx)(Tt,{terminal:J},J.id),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(p,{variant:`outline`,"data-testid":`terminal-rename`,onClick:()=>{w(!1),U(J)},children:`Rename`}),(0,Z.jsx)(p,{variant:`outline`,"data-testid":`terminal-duplicate`,disabled:N||!G(J),onClick:()=>{w(!1),ce(J)},children:`Duplicate tab`})]}),(0,Z.jsx)(p,{variant:`outline`,"data-testid":`terminal-close-selected`,onClick:()=>{w(!1),se(J)},"aria-label":`Close ${J.name}`,className:`text-error`,children:`Close terminal`})]}),(0,Z.jsx)(`div`,{className:`border-t border-surface-highest pt-3`,children:fe})]})]})}),H&&(0,Z.jsx)(wt,{terminal:H,onClose:()=>U(null)},H.id),(0,Z.jsx)(Ve,{open:z!==null,title:`Close terminal`,description:`"${z?.name??``}" is still running. Closing it kills the process.`,confirmLabel:`Close`,onConfirm:()=>z&&void oe(z),onCancel:()=>V(null)})]})}export{Zt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./client-954dj6K2.js";var t={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./client-954dj6K2.js";var t={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{c as r,r as i}from"./button-By-NN7c7.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./x-tY-z3woy.js";import{n as m,t as h}from"./document-display-BQ5dM8QT.js";var g=e(t(),1),_=n(),v=l,y=c,b=f,x=g.forwardRef(({className:e,...t},n)=>(0,_.jsx)(u,{ref:n,className:r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));x.displayName=u.displayName;var S=g.forwardRef(({className:e,children:t,closeDisabled:n=!1,...a},o)=>(0,_.jsxs)(b,{children:[(0,_.jsx)(x,{}),(0,_.jsxs)(s,{ref:o,className:r(`fixed left-[50%] top-[calc(var(--app-top,0px)+var(--app-height,100dvh)/2)] z-50 grid w-full max-w-lg max-h-[calc(var(--app-height,100dvh)-2rem)] overflow-y-auto overscroll-contain translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-surface-high p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg `,e),...a,"data-document-container":!0,onEscapeKeyDown:e=>{h(e)||a.onEscapeKeyDown?.(e)},onInteractOutside:e=>{m(e),e.defaultPrevented||a.onInteractOutside?.(e)},children:[t,(0,_.jsx)(i,{label:`Close`,description:`Close dialog`,children:(0,_.jsxs)(d,{disabled:n,className:`absolute right-2 top-2 flex size-8 items-center justify-center rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-focus focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-muted data-[state=open]:text-muted-foreground `,children:[(0,_.jsx)(p,{className:`h-4 w-4`}),(0,_.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]}));S.displayName=s.displayName;var C=({className:e,...t})=>(0,_.jsx)(`div`,{className:r(`flex flex-col space-y-1.5 text-left`,e),...t});C.displayName=`DialogHeader`;var w=({className:e,...t})=>(0,_.jsx)(`div`,{className:r(`flex flex-wrap items-center justify-end gap-2`,e),...t});w.displayName=`DialogFooter`;var T=g.forwardRef(({className:e,...t},n)=>(0,_.jsx)(o,{ref:n,className:r(`text-base font-medium leading-snug`,e),...t}));T.displayName=o.displayName;var E=g.forwardRef(({className:e,...t},n)=>(0,_.jsx)(a,{ref:n,className:r(`text-sm text-muted-foreground `,e),...t}));E.displayName=a.displayName;export{C as a,w as i,S as n,T as o,E as r,y as s,v as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return/\.(md|markdown|mdx)$/i.test(e)}export{e as t};
|