specrails-desktop 2.0.0 → 2.2.0
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/client/dist/assets/{ActivityFeedPage-Gy4x8dBt.js → ActivityFeedPage-BupGdGjj.js} +1 -1
- package/client/dist/assets/{AgentsPage-CPgu--Fb.js → AgentsPage-F3xksiLd.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-B5sJEee2.js → AnalyticsPage-D6LE6wG2.js} +1 -1
- package/client/dist/assets/{BarChart-7IMQ8HY1.js → BarChart-B366kDEj.js} +1 -1
- package/client/dist/assets/{CodePage-CBdFvbwe.js → CodePage-DLwCJgQ0.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-w0rdTq4w.js → DesktopAnalyticsPage-DG5LA_WO.js} +1 -1
- package/client/dist/assets/{DocsDialog-BZUYM7wm.js → DocsDialog-ChQ1oXLC.js} +1 -1
- package/client/dist/assets/{DocsPage-9QglWl46.js → DocsPage-BfGH8NUf.js} +1 -1
- package/client/dist/assets/{ExportDropdown-BLZFXtNi.js → ExportDropdown-9tRrlfM7.js} +1 -1
- package/client/dist/assets/{IntegrationsPage-BxBE4y99.js → IntegrationsPage-DANIzihd.js} +1 -1
- package/client/dist/assets/JobDetailPage-1RtejIOB.js +16 -0
- package/client/dist/assets/{JobsPage-20ibw0IO.js → JobsPage-NuDf5Zbx.js} +1 -1
- package/client/dist/assets/{dist-js-BY-Fv_fg.js → dist-js-BvQ52Q67.js} +1 -1
- package/client/dist/assets/{dist-js-Bakc4uxT.js → dist-js-XEilFTNz.js} +1 -1
- package/client/dist/assets/{index-XGZaKl_u.js → index-CNiaj7Sj.js} +45 -45
- package/client/dist/assets/index-DgFfrrTX.css +2 -0
- package/client/dist/assets/jobs-2N3RXDAM.js +1 -0
- package/client/dist/assets/jobs-2f6Hdc72.js +1 -0
- package/client/dist/assets/jobs-3j3_npyo.js +1 -0
- package/client/dist/assets/jobs-BqEbCCxD.js +1 -0
- package/client/dist/assets/jobs-DPPT6bV6.js +1 -0
- package/client/dist/assets/jobs-DRzjWI9u.js +1 -0
- package/client/dist/assets/jobs-cHYInoau.js +1 -0
- package/client/dist/assets/jobs-vGfzIDQa.js +1 -0
- package/client/dist/assets/{lib-CPxTMOAq.js → lib-DZJmnErt.js} +1 -1
- package/client/dist/assets/{settings-D3e_bDoW.js → settings-BSze3_9q.js} +1 -1
- package/client/dist/assets/{settings-nu68QukM.js → settings-Bg0A3zoS.js} +1 -1
- package/client/dist/assets/{settings-Dxpo6_w7.js → settings-BgPqg2nv.js} +1 -1
- package/client/dist/assets/{settings-Bd4Tq1RB.js → settings-CSJ0ahZ8.js} +1 -1
- package/client/dist/assets/{settings-DKbTkbn7.js → settings-CTcwN9RE.js} +1 -1
- package/client/dist/assets/{settings-bt84e3Aa.js → settings-DDcfx_ca.js} +1 -1
- package/client/dist/assets/{settings-CCSM-Fhn.js → settings-DYIV89nV.js} +1 -1
- package/client/dist/assets/{settings-55oDcbSh.js → settings-D_dujJZI.js} +1 -1
- package/client/dist/assets/setup--FMCsnQS.js +1 -0
- package/client/dist/assets/setup-B19ZpBNi.js +1 -0
- package/client/dist/assets/setup-BZPmkjSN.js +1 -0
- package/client/dist/assets/setup-BqYA02rS.js +1 -0
- package/client/dist/assets/setup-ChKQDHN9.js +1 -0
- package/client/dist/assets/setup-D2n9jMfM.js +1 -0
- package/client/dist/assets/setup-P3r6YP1D.js +1 -0
- package/client/dist/assets/setup-fnfEbwlv.js +1 -0
- package/client/dist/assets/{useProjectCache-DSaiGFjV.js → useProjectCache-H0T8Ot9j.js} +1 -1
- package/client/dist/index.html +5 -5
- package/package.json +1 -1
- package/client/dist/assets/JobDetailPage-DydWx_5S.js +0 -16
- package/client/dist/assets/index-CimDRRi7.css +0 -2
- package/client/dist/assets/jobs-BE1siB0M.js +0 -1
- package/client/dist/assets/jobs-BHcQ_Faf.js +0 -1
- package/client/dist/assets/jobs-CFfc2dNX.js +0 -1
- package/client/dist/assets/jobs-CSi5n8X_.js +0 -1
- package/client/dist/assets/jobs-Dc3X86PY.js +0 -1
- package/client/dist/assets/jobs-De5tASex.js +0 -1
- package/client/dist/assets/jobs-DsoXEdo7.js +0 -1
- package/client/dist/assets/jobs-Wl-ApPMb.js +0 -1
- package/client/dist/assets/setup-BMqwfbW9.js +0 -1
- package/client/dist/assets/setup-Bb5LcG28.js +0 -1
- package/client/dist/assets/setup-BeEx2_da.js +0 -1
- package/client/dist/assets/setup-CCCrB53Q.js +0 -1
- package/client/dist/assets/setup-CJA0ATmd.js +0 -1
- package/client/dist/assets/setup-CeiDbZcb.js +0 -1
- package/client/dist/assets/setup-Cus7TApA.js +0 -1
- package/client/dist/assets/setup-D9qOs2Xo.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{H as t,K as n,Mt as r,N as i,Nt as a,P as o,Yt as s,at as c,bt as l,jt as u,ot as d,qt as f,tn as p,tt as m}from"./index-XGZaKl_u.js";import{t as h}from"./useProjectCache-DSaiGFjV.js";var g=e(p(),1),_=r();function v(){let{t:e}=f(`integrations`),{activeProjectId:n}=l(),{registerHandler:r,unregisterHandler:o}=u(),s=(0,g.useRef)(n);(0,g.useEffect)(()=>{s.current=n},[n]);let[c,d]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),{data:v,isLoading:b,isFirstLoad:x,refresh:S}=h({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,g.useCallback)(async()=>{let e=await fetch(`${a()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,g.useEffect)(()=>(r(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==s.current||t.type.startsWith(`plugin.`)&&S())}),()=>o(`integrations-page`)),[r,o,S]),(0,g.useEffect)(()=>{d(!b&&!v?`Failed to load plugins`:null)},[b,v]);let C=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status!==`orphan`),[v]),T=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status===`orphan`),[v]);return n?(0,_.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,_.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-4 h-4 text-accent-primary`}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,_.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&b?(0,_.jsx)(O,{}):c?(0,_.jsx)(k,{onRetry:S}):(v?.length??0)===0?(0,_.jsx)(A,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,_.jsx)(y,{plugin:e,isInstalling:p===e.name,onInstall:()=>m(e.name),onCloseInstall:()=>{m(null),S()}},e.name))}),T.length>0&&(0,_.jsxs)(`div`,{className:`mt-10`,children:[(0,_.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:T.map(e=>(0,_.jsx)(w,{plugin:e,onRemoved:S},e.name))})]})]})})]}):(0,_.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function y({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:a}=f(`integrations`),[l,u]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3`,children:[(0,_.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,_.jsx)(d,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,_.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,_.jsx)(i,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,_.jsx)(m,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,_.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,_.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,_.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,_.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,_.jsx)(s,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,_.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,_.jsx)(C,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,_.jsx)(x,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,_.jsx)(S,{pluginName:e.name}),(0,_.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b,{pluginName:e.name,active:e.status===`installed`}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,_.jsx)(T,{pluginName:e.name,onClose:r}),l&&(0,_.jsx)(E,{pluginName:e.name,onClose:()=>u(!1),onUninstalled:()=>{u(!1)}})]})}function b({pluginName:e,active:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),s(null);try{let n=`${a()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){s(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,_.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),o&&(0,_.jsx)(`span`,{className:`text-[10px] text-destructive`,children:o})]})}function x({keys:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,_.jsx)(`strong`,{}),code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,_.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,_.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function S({pluginName:e}){let{t}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(m,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`update.body`,components:{code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),c(null);try{let t=await fetch(`${a()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){c(e.message)}finally{i(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[r&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t,i18nKey:`update.button`,components:{code:(0,_.jsx)(`code`,{})}})]}),o&&(0,_.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function C({pluginName:e,conflicts:t}){let{t:r}=f(`integrations`),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=async e=>{c(e),u(null);try{let t=await fetch(`${a()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){u(e.message)}finally{c(null)}};return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,_.jsx)(`strong`,{})}})})]}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:o===e,onClick:()=>d(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 hover:bg-yellow-500/10 disabled:opacity-50 flex items-center gap-1`,children:[o===e&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,_.jsx)(`code`,{})}})]},e))}),l&&(0,_.jsx)(`div`,{className:`text-destructive`,children:l})]})}function w({plugin:e,onRemoved:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 bg-yellow-500/5 p-4 flex flex-col gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-500`,children:n(`orphan.badge`)})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${a()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function T({pluginName:e,onClose:t}){let{t:r}=f(`integrations`),[o,s]=(0,g.useState)(null),[l,p]=(0,g.useState)(null),[h,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)([]),{registerHandler:O,unregisterHandler:k}=u(),A=(0,g.useCallback)(()=>{s(null),p(null),fetch(`${a()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>s(e)).catch(e=>p(e.message))},[e]);(0,g.useEffect)(()=>{A()},[A]),(0,g.useEffect)(()=>(O(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&E(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){w(null);let e=n.reason;e&&E(t=>[...t,`► ${e}`]),n.ok&&A()}}),()=>k(`install-${e}`)),[e,O,k,A]);let j=async e=>{w(e),E([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${a()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){E(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),w(null)}},M=(o?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,_.jsxs)(D,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),!o&&!l&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),o&&(0,_.jsxs)(_.Fragment,{children:[o.platformNote&&(0,_.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 bg-yellow-500/5 text-[11px] leading-relaxed`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:o.platformNote})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:o.files.map((e,t)=>(0,_.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),o.requirements.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-1`,children:o.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,_.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,_.jsx)(d,{className:`w-3 h-3 text-accent-success`}):(0,_.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,_.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&i&&(0,_.jsxs)(`button`,{type:`button`,disabled:C===e.name,onClick:()=>j(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[C===e.name&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),T.length>0&&(0,_.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:T.join(`
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{H as t,K as n,Mt as r,N as i,Nt as a,P as o,Yt as s,at as c,bt as l,jt as u,ot as d,qt as f,tn as p,tt as m}from"./index-CNiaj7Sj.js";import{t as h}from"./useProjectCache-H0T8Ot9j.js";var g=e(p(),1),_=r();function v(){let{t:e}=f(`integrations`),{activeProjectId:n}=l(),{registerHandler:r,unregisterHandler:o}=u(),s=(0,g.useRef)(n);(0,g.useEffect)(()=>{s.current=n},[n]);let[c,d]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),{data:v,isLoading:b,isFirstLoad:x,refresh:S}=h({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,g.useCallback)(async()=>{let e=await fetch(`${a()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,g.useEffect)(()=>(r(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==s.current||t.type.startsWith(`plugin.`)&&S())}),()=>o(`integrations-page`)),[r,o,S]),(0,g.useEffect)(()=>{d(!b&&!v?`Failed to load plugins`:null)},[b,v]);let C=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status!==`orphan`),[v]),T=(0,g.useMemo)(()=>(v??[]).filter(e=>e.status===`orphan`),[v]);return n?(0,_.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,_.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-4 h-4 text-accent-primary`}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,_.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&b?(0,_.jsx)(O,{}):c?(0,_.jsx)(k,{onRetry:S}):(v?.length??0)===0?(0,_.jsx)(A,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,_.jsx)(y,{plugin:e,isInstalling:p===e.name,onInstall:()=>m(e.name),onCloseInstall:()=>{m(null),S()}},e.name))}),T.length>0&&(0,_.jsxs)(`div`,{className:`mt-10`,children:[(0,_.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:T.map(e=>(0,_.jsx)(w,{plugin:e,onRemoved:S},e.name))})]})]})})]}):(0,_.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function y({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:a}=f(`integrations`),[l,u]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3`,children:[(0,_.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,_.jsxs)(`div`,{className:`flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,_.jsx)(d,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,_.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,_.jsx)(i,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,_.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,_.jsx)(m,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,_.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,_.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,_.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,_.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,_.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,_.jsx)(s,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,_.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,_.jsx)(C,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,_.jsx)(x,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,_.jsx)(S,{pluginName:e.name}),(0,_.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,_.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(b,{pluginName:e.name,active:e.status===`installed`}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,_.jsx)(T,{pluginName:e.name,onClose:r}),l&&(0,_.jsx)(E,{pluginName:e.name,onClose:()=>u(!1),onUninstalled:()=>{u(!1)}})]})}function b({pluginName:e,active:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),s(null);try{let n=`${a()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){s(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,_.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),o&&(0,_.jsx)(`span`,{className:`text-[10px] text-destructive`,children:o})]})}function x({keys:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,_.jsx)(`strong`,{}),code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,_.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,_.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function S({pluginName:e}){let{t}=f(`integrations`),[r,i]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null);return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(m,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t,i18nKey:`update.body`,components:{code:(0,_.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),c(null);try{let t=await fetch(`${a()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){c(e.message)}finally{i(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[r&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t,i18nKey:`update.button`,components:{code:(0,_.jsx)(`code`,{})}})]}),o&&(0,_.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function C({pluginName:e,conflicts:t}){let{t:r}=f(`integrations`),[o,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=async e=>{c(e),u(null);try{let t=await fetch(`${a()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){u(e.message)}finally{c(null)}};return(0,_.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 bg-yellow-500/5 p-2 leading-relaxed space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,_.jsx)(i,{className:`w-3 h-3 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:(0,_.jsx)(s,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,_.jsx)(`strong`,{})}})})]}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:o===e,onClick:()=>d(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 hover:bg-yellow-500/10 disabled:opacity-50 flex items-center gap-1`,children:[o===e&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),(0,_.jsx)(s,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,_.jsx)(`code`,{})}})]},e))}),l&&(0,_.jsx)(`div`,{className:`text-destructive`,children:l})]})}function w({plugin:e,onRemoved:t}){let{t:n}=f(`integrations`),[r,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 bg-yellow-500/5 p-4 flex flex-col gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-500`,children:n(`orphan.badge`)})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,_.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${a()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function T({pluginName:e,onClose:t}){let{t:r}=f(`integrations`),[o,s]=(0,g.useState)(null),[l,p]=(0,g.useState)(null),[h,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)([]),{registerHandler:O,unregisterHandler:k}=u(),A=(0,g.useCallback)(()=>{s(null),p(null),fetch(`${a()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>s(e)).catch(e=>p(e.message))},[e]);(0,g.useEffect)(()=>{A()},[A]),(0,g.useEffect)(()=>(O(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&E(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){w(null);let e=n.reason;e&&E(t=>[...t,`► ${e}`]),n.ok&&A()}}),()=>k(`install-${e}`)),[e,O,k,A]);let j=async e=>{w(e),E([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${a()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){E(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),w(null)}},M=(o?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,_.jsxs)(D,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),!o&&!l&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),o&&(0,_.jsxs)(_.Fragment,{children:[o.platformNote&&(0,_.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 bg-yellow-500/5 text-[11px] leading-relaxed`,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-500 mt-0.5 flex-shrink-0`}),(0,_.jsx)(`span`,{children:o.platformNote})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:o.files.map((e,t)=>(0,_.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),o.requirements.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,_.jsx)(`ul`,{className:`text-xs space-y-1`,children:o.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,_.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,_.jsx)(d,{className:`w-3 h-3 text-accent-success`}):(0,_.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,_.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&i&&(0,_.jsxs)(`button`,{type:`button`,disabled:C===e.name,onClick:()=>j(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[C===e.name&&(0,_.jsx)(n,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),T.length>0&&(0,_.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:T.join(`
|
|
2
2
|
`)})]}),x.length>0&&(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,_.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:x.join(`
|
|
3
3
|
`)})]}),y&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:y})]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,_.jsxs)(`button`,{type:`button`,disabled:!o||!M||h,onClick:async()=>{v(!0),b(null);try{let n=await fetch(`${a()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){b(e.message)}finally{v(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[h?(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}):(0,_.jsx)(m,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function E({pluginName:e,onClose:t,onUninstalled:r}){let{t:i}=f(`integrations`),[o,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(null);return(0,_.jsxs)(D,{onClose:t,title:i(`uninstallDialog.title`,{name:e}),children:[(0,_.jsx)(`p`,{className:`text-xs`,children:(0,_.jsx)(s,{t:i,i18nKey:`uninstallDialog.body`,components:{code:(0,_.jsx)(`code`,{})}})}),l&&(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:l}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:i(`common:actions.cancel`)}),(0,_.jsxs)(`button`,{type:`button`,disabled:o,onClick:async()=>{c(!0);try{let t=await fetch(`${a()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);r()}catch(e){u(e.message)}finally{c(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[o&&(0,_.jsx)(n,{className:`w-3 h-3 animate-spin`}),i(`card.uninstall`)]})]})]})}function D({title:e,onClose:t,children:n}){return(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:t,children:(0,_.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),n]})})}function O(){return(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,_.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function k({onRetry:e}){let{t}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,_.jsx)(i,{className:`w-5 h-5 text-destructive`}),(0,_.jsx)(`p`,{children:t(`page.loadError`)}),(0,_.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function A(){let{t:e}=f(`integrations`);return(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(t,{className:`w-6 h-6`}),(0,_.jsx)(`p`,{children:e(`page.empty`)})]})}export{v as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{A as t,B as n,K as r,Kt as i,L as a,Mt as o,Nt as s,O as c,Qt as l,St as u,Xt as d,Zt as f,_ as p,a as m,at as h,bt as g,c as _,ct as v,d as y,f as b,it as x,jt as S,k as C,l as w,lt as T,nt as E,ot as D,qt as O,tn as k,tt as ee,ut as A,v as j,vt as M,xt as N,y as P}from"./index-CNiaj7Sj.js";import{t as F}from"./lib-DZJmnErt.js";import{t as te}from"./format-command-CwGuwzGA.js";var I=M(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),L=M(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),R=e(k(),1),z=o();function ne({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,z.jsx)(`div`,{className:`flex items-center`,children:n.map((r,i)=>{let a=e[r.key]??`idle`,o=i<n.length-1?e[n[i+1].key]??`idle`:null;return(0,z.jsxs)(`div`,{className:`flex items-center`,children:[(0,z.jsxs)(p,{children:[(0,z.jsx)(P,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,z.jsx)(B,{state:a}),(0,z.jsx)(`span`,{className:t(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:r.label})]})}),(0,z.jsxs)(j,{side:`bottom`,className:`max-w-[200px]`,children:[(0,z.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),o!==null&&(0,z.jsx)(`div`,{className:t(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},r.key)})})}function B({state:e}){return(0,z.jsxs)(`div`,{className:t(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,z.jsx)(r,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,z.jsx)(D,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,z.jsx)(h,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,z.jsx)(x,{className:`w-6 h-6 text-muted-foreground/20`})]})}function V(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function H(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var U=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function W(e){return e.length>40?`${e.slice(0,39)}…`:e}function G(e){return typeof e!=`string`||e.length===0?``:W(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function K(e){return typeof e!=`string`||e.length===0?``:W(e.trim().split(/\s+/)[0]??``)}function q(e,t){let n=t??{},r=G(n.file_path??n.path);switch(e){case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:return{step:!0,actionKey:`editing`,actionArg:r};case`Write`:case`create`:return{step:!0,actionKey:`writing`,actionArg:r};case`Read`:return{step:!0,actionKey:`reading`,actionArg:r};case`Grep`:case`Glob`:case`search`:return{step:!0,actionKey:`searching`,actionArg:W(String(n.pattern??n.query??``))};case`Bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:K(n.command)};default:return{step:!0,actionKey:`working`}}}function J(e){let t=e.event_type,n={};try{n=JSON.parse(e.payload)}catch{n={}}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=[...e].reverse().find(e=>e?.type===`tool_use`);if(t)return q(t.name,t.input);if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}return{step:!0}}if(t===`tool_use`)return q(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:K(e?.command)||(typeof e?.name==`string`?W(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}var Y={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function re(e,t){if(t.type===`reset`)return Y;if(t.type===`consume`){let{events:n}=t;if(n.length<=e.lastSeenIdx)return e;let{steps:r,actionKey:i,actionArg:a}=e;for(let t=e.lastSeenIdx;t<n.length;t++){let e=J(n[t]);e.step&&(r+=1),e.actionKey&&(i=e.actionKey,a=e.actionArg??``)}return{steps:r,actionKey:i,actionArg:a,lastSeenIdx:n.length}}return e}function ie({job:e,events:n,defaultOpen:i=!0,pipelineTotals:a,phases:o,phaseDefinitions:s}){let{t:c}=O(`jobs`),[l,u]=(0,R.useState)(i),d=(0,R.useMemo)(()=>H(n),[n]),f=e.status===`running`,p=e.status===`completed`,[m,g]=(0,R.useState)(()=>Date.now());(0,R.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[_,v]=(0,R.useReducer)(re,Y),y=(0,R.useRef)(e.id);(0,R.useEffect)(()=>{y.current!==e.id&&(y.current=e.id,v({type:`reset`})),v({type:`consume`,events:n})},[e.id,n]);let[b,x]=(0,R.useState)(!0);(0,R.useEffect)(()=>{if(!f)return;x(!0);let e=window.setTimeout(()=>x(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let S=e.finished_at?V(e.started_at,e.finished_at):f?V(e.started_at,m):`—`,C=!!e.total_cost_usd_estimated,w=e.total_cost_usd==null?null:`${C?`~`:``}$${e.total_cost_usd.toFixed(4)}`,T=e.num_turns==null?null:String(e.num_turns),E=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),k=E==null?null:`${(E/1e3).toFixed(1)}k`,ee=(0,R.useMemo)(()=>!o||!s?null:s.find(e=>o[e.key]===`running`)?.label??null,[o,s]),j=f&&_.steps===0?`connecting`:_.actionKey||`thinking`,M=U.has(j)?c(`statusPanel.activity.${j}`,{arg:_.actionArg}):c(`statusPanel.activity.${j}`),N=ee??(f&&_.steps===0?c(`statusPanel.activity.starting`):null),P=_.steps>0?c(`statusPanel.steps`,{count:_.steps}):null,F=c(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),te=f?`border-accent-info/20 bg-accent-info/5`:p?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`,I=f?r:p?D:h,L=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`w-4 h-4 text-emerald-400 shrink-0`:`w-4 h-4 text-red-400 shrink-0`;return(0,z.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border transition-colors duration-500`,te),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(!l),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,z.jsx)(I,{className:L,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:F}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`tabular-nums`,children:S}),f?P&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:P}):(0,z.jsxs)(z.Fragment,{children:[w&&(0,z.jsx)(`span`,{className:`tabular-nums text-yellow-400`,children:w}),d.length>0&&(0,z.jsx)(`span`,{children:c(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,z.jsx)(A,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,l&&`rotate-180`)})]}),l&&(0,z.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:c(`statusPanel.zoneInProgress`)}),(0,z.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[c(`statusPanel.duration`),(0,z.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:c(`statusPanel.liveTooltip`),"aria-label":c(`statusPanel.liveTooltip`)})]}),(0,z.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:S})]}),(0,z.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,z.jsx)(r,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),N&&(0,z.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:N}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:M}),P&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,P]})]})]}),b&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:c(`statusPanel.explainer`)}),(0,z.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:c(`statusPanel.zoneFinalPending`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,z.jsx)(Q,{label:c(`statusPanel.cost`),caption:c(`statusPanel.pendingCaption`),tooltip:c(`statusPanel.costTooltip`)}),(0,z.jsx)(Q,{label:c(`statusPanel.turns`),caption:c(`statusPanel.pendingCaption`),tooltip:c(`statusPanel.pendingTooltip`)}),(0,z.jsx)(Q,{label:c(`statusPanel.tokens`),caption:c(`statusPanel.pendingCaption`),tooltip:c(`statusPanel.pendingTooltip`)})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:c(`statusPanel.zoneFinal`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,z.jsx)(X,{label:c(`statusPanel.duration`),value:S}),(0,z.jsx)(Z,{label:c(`statusPanel.cost`),value:w,valueClass:`text-yellow-400`,naCaption:c(`statusPanel.notAvailable`)}),(0,z.jsx)(Z,{label:c(`statusPanel.turns`),value:T,naCaption:c(`statusPanel.notAvailable`)}),(0,z.jsx)(Z,{label:c(`statusPanel.tokens`),value:k,naCaption:c(`statusPanel.notAvailable`)})]}),a&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:c(`statusPanel.pipelineTotal`,{count:a.jobCount})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsx)(X,{label:c(`statusPanel.totalCost`),value:`$${a.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,z.jsx)(X,{label:c(`statusPanel.totalTokens`),value:`${((a.totalTokensIn+a.totalTokensOut+a.totalTokensCacheRead+a.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),d.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:c(`statusPanel.filesModified`)}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,z.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})})]})}function X({label:e,value:n,valueClass:r}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,z.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}function Z({label:e,value:n,valueClass:r,naCaption:i}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,z.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,n==null?`text-muted-foreground`:r),children:n??`—`}),n==null&&(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:i})]})}function Q({label:e,caption:t,tooltip:n}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,z.jsx)(I,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,z.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var $=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=O(`jobs`),[r,i]=(0,R.useState)(!1);if(e.length===0)return null;let a=e.length>=$&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,z.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,z.jsx)(oe,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,z.jsx)(A,{className:`w-3 h-3`})]}),r&&e.length>=$&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,z.jsx)(v,{className:`w-3 h-3`})]})]})}function oe({ticket:e,onClick:n}){let{t:r}=O(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,z.jsx)(`span`,{className:t(a,`text-muted-foreground bg-muted/20 select-none`),title:r(`ticketHeader.deletedTooltip`),children:r(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,z.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,z.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,z.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function se(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function ce(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:se(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(u.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${u.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function le(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function ue(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function de({events:e,isLoading:t}){let{t:n,i18n:r}=O(`jobs`),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(!0),[u,d]=(0,R.useState)(new Set),f=(0,R.useRef)(null),p=(0,R.useRef)(null),{processedLines:h,groups:g,totalLines:_}=(0,R.useMemo)(()=>{let t=e.map((e,t)=>ce(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
|
|
2
|
+
`+e.content:n.push({...e})}let r=le(n);return{processedLines:r,groups:ue(r),totalLines:r.length}},[e,r.language]),v=(0,R.useMemo)(()=>{if(!o)return _;let e=o.toLowerCase();return h.filter(t=>t.content.toLowerCase().includes(e)).length},[o,h,_]),y=(0,R.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,R.useEffect)(()=>{c&&y()},[e.length,c,y]);function b(){let e=p.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function x(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.loading`)})}):_===0?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.empty`)})}):(0,z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,z.jsx)(a,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,z.jsx)(m,{placeholder:n(`logViewer.filterPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`pl-7 h-7`})]}),(0,z.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=h.map(e=>e.content).join(`
|
|
3
|
+
`);navigator.clipboard.writeText(e).then(()=>{i.success(n(`logViewer.copySuccess`))}).catch(()=>{i.error(n(`logViewer.copyFailed`))})},children:(0,z.jsx)(E,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`logViewer.lineCount`,{filtered:v,total:_})})]}),(0,z.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:b,children:[g.map(e=>(0,z.jsx)(fe,{group:e,filter:o,collapsed:u.has(e.key),onToggle:()=>x(e.key)},e.key)),(0,z.jsx)(`div`,{ref:f})]}),!c&&(0,z.jsxs)(C,{size:`sm`,variant:`secondary`,onClick:()=>{l(!0),y()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,z.jsx)(A,{className:`w-3 h-3`}),n(`logViewer.jumpToBottom`)]})]})}var fe=(0,R.memo)(function({group:e,filter:n,collapsed:r,onToggle:i}){let{t:a}=O(`jobs`),o=n?e.lines.filter(e=>e.content.toLowerCase().includes(n.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,z.jsx)(`div`,{children:o.map((e,t)=>(0,z.jsx)(me,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,z.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:i,className:t(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,z.jsx)(T,{className:t(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!r&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!r&&(0,z.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,z.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(n?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,z.jsx)(me,{line:e,even:t%2==0},e.id))})]})}),pe=[F],me=(0,R.memo)(function({line:e,even:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`;return(0,z.jsxs)(`div`,{className:t(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(i||a||o||s)&&(n?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 border-l-2 border-emerald-500/40 mt-2 py-2`,i&&`bg-emerald-500/8 border-l-2 border-emerald-500/50`,a&&`bg-red-500/8 border-l-2 border-red-500/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),r?(0,z.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
|
+
prose-p:my-1 prose-p:leading-relaxed
|
|
5
|
+
prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
|
|
6
|
+
prose-ul:my-1 prose-ol:my-1 prose-li:my-0
|
|
7
|
+
prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
|
|
8
|
+
prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
|
|
9
|
+
prose-strong:text-foreground prose-em:text-foreground/70
|
|
10
|
+
prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
|
|
11
|
+
prose-table:my-2 prose-table:text-[11px]
|
|
12
|
+
prose-thead:border-border prose-thead:bg-muted/30
|
|
13
|
+
prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
|
|
14
|
+
prose-td:px-3 prose-td:py-1.5 prose-td:border-border
|
|
15
|
+
prose-tr:border-border
|
|
16
|
+
text-foreground/80`,children:(0,z.jsx)(b,{remarkPlugins:[y],rehypePlugins:pe,children:e.content})}):(0,z.jsx)(`span`,{className:t(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 text-[11px]`,e.type===`stderr`&&`text-orange-400`,e.type===`result`&&`text-emerald-400 font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,i&&`text-emerald-400`,a&&`text-red-400`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:e.content})]})}),he={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function ge(){let{t:e}=O(`jobs`),{id:r}=l(),{activeProjectId:a,projects:o}=g(),u=o.find(e=>e.id===a)?.provider,m=f(),{openTicketDetail:h}=_(),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)([]),[E,D]=(0,R.useState)([]),[k,A]=(0,R.useState)({}),[M,F]=(0,R.useState)([]),[I,B]=(0,R.useState)(!0),[V,H]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!r)return;let e=new AbortController;y(null),x([]),D([]),A({}),B(!0),H(!1);async function t(){try{let t=await fetch(`${s()}/jobs/${r}`,{signal:e.signal});if(t.status===404){H(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();y(n.job),x(n.events)}catch(e){if(e.name===`AbortError`)return;H(!0)}finally{e.signal.aborted||B(!1)}}return t(),()=>e.abort()},[r,a]),(0,R.useEffect)(()=>{if(!v?.pipeline_id){F([]);return}let e=v.pipeline_id;fetch(`${s()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&F(e.jobs)}).catch(()=>{})},[v?.pipeline_id,v?.status]);let U=(0,R.useRef)(a);U.current=a;let W=(0,R.useRef)([]),G=(0,R.useRef)(null),K=(0,R.useCallback)(()=>{G.current=null;let e=W.current;e.length!==0&&(W.current=[],x(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,R.useEffect)(()=>()=>{G.current&&cancelAnimationFrame(G.current)},[]);let q=(0,R.useCallback)(e=>{let t=e;if(!(U.current&&t.projectId&&t.projectId!==U.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];D(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;A(n)}else if(t.type===`event`&&t.jobId===r){let e={id:Date.now(),job_id:r??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};W.current.push(e),G.current||=requestAnimationFrame(K)}else if(t.type===`log`&&t.processId===r){let e={id:Date.now(),job_id:r??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};W.current.push(e),G.current||=requestAnimationFrame(K)}else if(t.type===`phase`){let e=t.phase,n=t.state;A(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===r);if(e){let t=e.status;y(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${s()}/jobs/${r}`).then(e=>e.json()).then(e=>y(e.job)).catch(()=>{})}}}},[r,K]),{registerHandler:J,unregisterHandler:Y}=S();(0,R.useEffect)(()=>(J(`job-detail-${r}`,q),()=>Y(`job-detail-${r}`)),[r,q,J,Y]),(0,R.useEffect)(()=>{if(!r||!v||v.status!==`running`||v.hasTelemetry)return;let e=setInterval(()=>{fetch(`${s()}/jobs/${r}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&y(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[r,v?.status,v?.hasTelemetry]);async function re(){if(r)try{let t=await fetch(`${s()}/jobs/${r}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(i.success(e(`detail.toast.jobDeleted`)),m(`/jobs`)):i.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();i.error(e(`detail.toast.failed`),{description:n.error})}}catch{i.error(e(`detail.toast.networkError`))}}async function X(){if(v)try{let t=await fetch(`${s()}/jobs/${v.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${v.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){i.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Z(){if(v)try{let t=await fetch(`${s()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:v.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));i.success(e(`detail.toast.jobRequeued`)),m(`/jobs/${n.jobId}`)}catch(e){i.error(e.message)}}if(I)return(0,z.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,z.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,z.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(V||!v)return(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,z.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:r})}),(0,z.jsx)(C,{asChild:!0,variant:`outline`,size:`sm`,children:(0,z.jsxs)(d,{to:`/`,children:[(0,z.jsx)(L,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Q=he[v.status]??he.queued,$=v.status===`running`,oe=v.status===`completed`||v.status===`failed`,se=(v.tickets?.length??0)>0,ce=M.length>1?{totalCostUsd:M.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:M.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:M.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:M.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:M.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:M.length}:null;return(0,z.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,z.jsxs)(d,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,z.jsx)(L,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,z.jsx)(T,{className:`w-3 h-3`}),(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:r?.slice(0,8)})})]}),se&&(0,z.jsx)(ae,{tickets:v.tickets??[],onTicketClick:h}),(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,z.jsxs)(p,{children:[(0,z.jsx)(P,{asChild:!0,children:(0,z.jsx)(`div`,{children:(0,z.jsx)(c,{variant:Q.variant,children:e(Q.labelKey)})})}),(0,z.jsx)(j,{children:e(Q.tooltipKey)})]}),(0,z.jsx)(`code`,{className:t(`font-mono text-foreground/90 truncate`,se?`text-xs text-muted-foreground`:`text-sm`),children:te(v.command,u)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,z.jsx)(`span`,{children:v.started_at?e(`detail.startedAgo`,{timeAgo:w(new Date(v.started_at),{addSuffix:!0,locale:N()})}):e(`detail.queuedWaiting`)}),v.model&&(0,z.jsx)(`span`,{className:`text-muted-foreground/40`,children:v.model})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[v.hasTelemetry&&(0,z.jsxs)(p,{children:[(0,z.jsx)(P,{asChild:!0,children:(0,z.jsxs)(C,{variant:`outline`,size:`sm`,className:`h-7`,onClick:X,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,z.jsx)(ee,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,z.jsx)(j,{children:e(`detail.exportDiagnosticTooltip`)})]}),oe&&(0,z.jsxs)(p,{children:[(0,z.jsx)(P,{asChild:!0,children:(0,z.jsxs)(C,{variant:`outline`,size:`sm`,onClick:Z,className:`h-7`,children:[(0,z.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,z.jsx)(j,{children:e(`detail.reExecuteTooltip`)})]}),$&&(0,z.jsxs)(p,{children:[(0,z.jsx)(P,{asChild:!0,children:(0,z.jsx)(C,{variant:`outline`,size:`sm`,onClick:re,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(`detail.cancelJob`)})}),(0,z.jsx)(j,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,z.jsx)(ne,{phases:k,phaseDefinitions:E})]}),(v.status===`running`||v.status===`completed`||v.status===`failed`)&&(0,z.jsx)(ie,{job:v,events:b,defaultOpen:v.status===`completed`||v.status===`running`,pipelineTotals:ce??void 0,phases:k,phaseDefinitions:E}),(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,z.jsx)(de,{events:b})})]})}export{ge as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{C as t,Kt as n,M as r,Mt as i,Nt as a,O as o,P as s,S as c,T as l,Zt as u,_ as d,at as f,b as p,bt as m,d as ee,f as h,k as g,l as _,ot as v,q as y,qt as b,rt as x,t as S,tn as C,v as w,vt as T,w as E,x as D,xt as O,y as k}from"./index-XGZaKl_u.js";import{t as A}from"./ExportDropdown-BLZFXtNi.js";import{t as j}from"./useProjectCache-DSaiGFjV.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=T(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),M=e(C(),1),N=i();function P(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function F(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function I(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function L({label:e,a:t,b:n,highlight:r}){return(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function R(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function re({jobIds:e,onClose:t}){let{t:n}=b(`jobs`),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(!0),[l,u]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=new AbortController;return fetch(`${a()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),c(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),c(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,N.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,N.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,N.jsx)(v,{className:`w-3 h-3 text-emerald-400`}):(0,N.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,N.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,N.jsx)(r,{className:`w-4 h-4`})})]}),s&&(0,N.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,N.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,N.jsx)(`p`,{className:`text-xs text-red-400`,children:n(`comparison.loadFailed`,{error:l})}),i&&(()=>{let[e,t]=i.jobs,r=R(e.durationMs,t.durationMs,!0),a=R(e.totalCostUsd,t.totalCostUsd,!0),o=R(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,N.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,N.jsx)(L,{label:n(`comparison.duration`),a:P(e.durationMs),b:P(t.durationMs),highlight:r}),(0,N.jsx)(L,{label:n(`comparison.cost`),a:F(e.totalCostUsd),b:F(t.totalCostUsd),highlight:a}),(0,N.jsx)(L,{label:n(`comparison.tokensOut`),a:I(e.tokensOut),b:I(t.tokensOut),highlight:o}),(0,N.jsx)(L,{label:n(`comparison.tokensIn`),a:I(e.tokensIn),b:I(t.tokensIn),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.cacheRead`),a:I(e.tokensCacheRead),b:I(t.tokensCacheRead),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,N.jsx)(L,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),i&&(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]})})}var ie={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ae=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],oe={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,labelKey:`recent.priority.low`}};function se(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ce(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function le(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ue(e){try{return _(new Date(e),{addSuffix:!0,locale:O()})}catch{return e}}var z=10;function B({jobs:e,isLoading:r,onJobsCleared:i,onProposalClick:f,onProposalDelete:ee}){let{t:h}=b(`jobs`),_=u(),{activeProjectId:v,projects:S}=m(),C=S.find(e=>e.id===v)?.provider,[T,O]=(0,M.useState)(null),[A,j]=(0,M.useState)(``),[P,F]=(0,M.useState)(``),[I,L]=(0,M.useState)(!1),[R,B]=(0,M.useState)(``),[V,H]=(0,M.useState)(``),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(null),[q,J]=(0,M.useState)(z),[Y,de]=(0,M.useState)(!1),[X,Z]=(0,M.useState)([]),[fe,Q]=(0,M.useState)(null);(0,M.useEffect)(()=>{J(z)},[e.length]);function pe(){de(e=>!e),Z([])}function me(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(T&&e.status!==T||A&&e.started_at<A||P&&e.started_at>`${P}T23:59:59`)),he=e.filter(e=>!(R&&e.started_at<R||V&&e.started_at>`${V}T23:59:59`)).length;async function ge(e){W(!0);try{let t={};e===`range`&&(R&&(t.from=R),V&&(t.to=V));let r=await fetch(`${a()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();n.success(h(`recent.toast.cleared`,{count:e.deleted})),L(!1),B(``),H(``),i?.()}else n.error(h(`recent.toast.clearFailed`))}catch{n.error(h(`recent.toast.networkError`))}finally{W(!1)}}return r?(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,N.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,N.jsx)(x,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,N.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:h(`recent.emptyTitle`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:h(`recent.emptyDescription`)})]}):(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterAll`,{count:e.length})}),ae.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterStatus`,{status:h(`statusName.${t}`),count:n})},t)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.fromDate`)}),(0,N.jsx)(`input`,{type:`date`,value:P,onChange:e=>F(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.toDate`)}),(A||P)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{j(``),F(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:h(`recent.clear`)}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:pe,children:(0,N.jsx)(ne,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>L(!0),children:(0,N.jsx)(s,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(`recent.clearJobs`)})]})]})]}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,N.jsxs)(`span`,{children:[X.length===0&&h(`recent.selectTwoToCompare`),X.length===1&&h(`recent.selectOneMore`),X.length===2&&h(`recent.readyToCompare`)]}),X.length===2&&(0,N.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:h(`recent.compareAction`)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,N.jsx)(`span`,{className:`w-14`,children:h(`recent.colStatus`)}),(0,N.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`recent.colCommand`)}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:h(`recent.colDuration`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colTokens`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colCost`)}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:h(`recent.colStarted`)})]})]}),(0,N.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,q).map(e=>{let t=ie[e.status]??ie.queued,n=se(e.total_cost_usd),r=ce(e.started_at,e.finished_at),i=le((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),c=a?e.id.replace(`proposal:`,``):null,l=X.includes(e.id),u=Y&&!a&&X.length===2&&!l;return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(Y&&!a){me(e.id);return}a&&c?f?.(c):_(`/jobs/${e.id}`)},children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`div`,{children:(0,N.jsx)(o,{variant:t.variant,children:h(t.labelKey)})})}),(0,N.jsx)(w,{children:h(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${oe[e.priority].className}`,children:h(oe[e.priority].labelKey)}),e.profile_name&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,N.jsx)(w,{children:h(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(y,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,N.jsxs)(w,{children:[h(`recent.pipelinePart`),e.depends_on_job_id&&` ${h(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,N.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:te(e.command,C)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:ue(e.started_at)}),a&&c&&(0,N.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),K(c)},title:h(`recent.deleteProposal`),children:(0,N.jsx)(s,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>q&&(0,N.jsx)(`div`,{className:`pt-1 text-center`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>J(e=>e+z),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:h(`recent.loadMore`,{count:$.length-q})})}),I&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>L(!1),children:(0,N.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:h(`recent.clearModal.title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:h(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:U,onClick:()=>ge(`all`),children:h(`recent.clearModal.clearAll`,{count:e.length})}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`recent.clearModal.orByRange`)}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:R,onChange:e=>B(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.fromPlaceholder`)}),(0,N.jsx)(`input`,{type:`date`,value:V,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.toPlaceholder`)})]}),(0,N.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:U||!R&&!V,onClick:()=>ge(`range`),children:R||V?h(`recent.clearModal.clearInRange`,{count:he}):h(`recent.clearModal.clearRange`)})]}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>L(!1),children:h(`common:actions.cancel`)})]})}),(0,N.jsx)(p,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,N.jsxs)(D,{className:`max-w-sm`,children:[(0,N.jsxs)(E,{children:[(0,N.jsx)(l,{children:h(`recent.deleteProposalConfirm.title`)}),(0,N.jsx)(c,{children:h(`recent.deleteProposalConfirm.description`)})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:h(`common:actions.cancel`)}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&ee?.(G),K(null)},children:h(`common:actions.delete`)})]})]})}),fe&&(0,N.jsx)(re,{jobIds:fe,onClose:()=>{Q(null),Z([]),de(!1)}})]})}function V(){let{t:e}=b(`jobs`),{activeProjectId:r}=m(),{recentJobs:i}=S(r),{data:s,isFirstLoad:c,refresh:u}=j({namespace:`jobs`,projectId:r,initialValue:i,fetcher:async()=>{let e=await fetch(`${a()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:d}=j({namespace:`proposals`,projectId:r,initialValue:[],fetcher:async()=>{let e=await fetch(`${a()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),f={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},_=d.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:f[e.status]??`queued`})),v=[...s,..._].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,x]=(0,M.useState)(null),C=(0,M.useCallback)(async e=>{try{let t=await fetch(`${a()}/propose/${e}`);if(!t.ok)return;x((await t.json()).proposal)}catch{}},[]),w=(0,M.useCallback)(async t=>{try{(await fetch(`${a()}/propose/${t}`,{method:`DELETE`})).ok&&(n.success(e(`page.proposalDeleted`)),u())}catch{}},[u,e]);return(0,N.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,N.jsx)(A,{baseUrl:`${a()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,N.jsx)(B,{jobs:v,isLoading:c,onJobsCleared:u,onProposalClick:C,onProposalDelete:w}),(0,N.jsx)(p,{open:y!==null,onOpenChange:e=>!e&&x(null),children:(0,N.jsx)(D,{className:`max-w-3xl glass-card`,children:y&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(l,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,N.jsx)(o,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,N.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,N.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,N.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,N.jsx)(h,{remarkPlugins:[ee],children:y.result_markdown})})}):(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,N.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,N.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{w(y.id),x(null)},children:e(`common:actions.delete`)}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>x(null),children:e(`common:actions.close`)})]})]})})})]})}export{V as default};
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{C as t,Kt as n,M as r,Mt as i,Nt as a,O as o,P as s,S as c,T as l,Zt as u,_ as d,at as f,b as p,bt as m,d as ee,f as h,k as g,l as _,ot as v,q as y,qt as b,rt as x,t as S,tn as C,v as w,vt as T,w as E,x as D,xt as O,y as k}from"./index-CNiaj7Sj.js";import{t as A}from"./ExportDropdown-9tRrlfM7.js";import{t as j}from"./useProjectCache-H0T8Ot9j.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=T(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),M=e(C(),1),N=i();function P(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function F(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function I(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function L({label:e,a:t,b:n,highlight:r}){return(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,N.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function R(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function re({jobIds:e,onClose:t}){let{t:n}=b(`jobs`),[i,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(!0),[l,u]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=new AbortController;return fetch(`${a()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),c(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),c(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,N.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,N.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,N.jsx)(v,{className:`w-3 h-3 text-emerald-400`}):(0,N.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,N.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,N.jsx)(r,{className:`w-4 h-4`})})]}),s&&(0,N.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,N.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,N.jsx)(`p`,{className:`text-xs text-red-400`,children:n(`comparison.loadFailed`,{error:l})}),i&&(()=>{let[e,t]=i.jobs,r=R(e.durationMs,t.durationMs,!0),a=R(e.totalCostUsd,t.totalCostUsd,!0),o=R(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,N.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,N.jsx)(L,{label:n(`comparison.duration`),a:P(e.durationMs),b:P(t.durationMs),highlight:r}),(0,N.jsx)(L,{label:n(`comparison.cost`),a:F(e.totalCostUsd),b:F(t.totalCostUsd),highlight:a}),(0,N.jsx)(L,{label:n(`comparison.tokensOut`),a:I(e.tokensOut),b:I(t.tokensOut),highlight:o}),(0,N.jsx)(L,{label:n(`comparison.tokensIn`),a:I(e.tokensIn),b:I(t.tokensIn),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.cacheRead`),a:I(e.tokensCacheRead),b:I(t.tokensCacheRead),highlight:null}),(0,N.jsx)(L,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,N.jsx)(L,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),i&&(0,N.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]})})}var ie={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ae=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],oe={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,labelKey:`recent.priority.low`}};function se(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ce(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function le(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ue(e){try{return _(new Date(e),{addSuffix:!0,locale:O()})}catch{return e}}var z=10;function B({jobs:e,isLoading:r,onJobsCleared:i,onProposalClick:f,onProposalDelete:ee}){let{t:h}=b(`jobs`),_=u(),{activeProjectId:v,projects:S}=m(),C=S.find(e=>e.id===v)?.provider,[T,O]=(0,M.useState)(null),[A,j]=(0,M.useState)(``),[P,F]=(0,M.useState)(``),[I,L]=(0,M.useState)(!1),[R,B]=(0,M.useState)(``),[V,H]=(0,M.useState)(``),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(null),[q,J]=(0,M.useState)(z),[Y,de]=(0,M.useState)(!1),[X,Z]=(0,M.useState)([]),[fe,Q]=(0,M.useState)(null);(0,M.useEffect)(()=>{J(z)},[e.length]);function pe(){de(e=>!e),Z([])}function me(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(T&&e.status!==T||A&&e.started_at<A||P&&e.started_at>`${P}T23:59:59`)),he=e.filter(e=>!(R&&e.started_at<R||V&&e.started_at>`${V}T23:59:59`)).length;async function ge(e){W(!0);try{let t={};e===`range`&&(R&&(t.from=R),V&&(t.to=V));let r=await fetch(`${a()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();n.success(h(`recent.toast.cleared`,{count:e.deleted})),L(!1),B(``),H(``),i?.()}else n.error(h(`recent.toast.clearFailed`))}catch{n.error(h(`recent.toast.networkError`))}finally{W(!1)}}return r?(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,N.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,N.jsx)(x,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,N.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:h(`recent.emptyTitle`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:h(`recent.emptyDescription`)})]}):(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterAll`,{count:e.length})}),ae.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,N.jsx)(`button`,{type:`button`,onClick:()=>O(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:h(`recent.filterStatus`,{status:h(`statusName.${t}`),count:n})},t)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.fromDate`)}),(0,N.jsx)(`input`,{type:`date`,value:P,onChange:e=>F(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:h(`recent.toDate`)}),(A||P)&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{j(``),F(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:h(`recent.clear`)}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:pe,children:(0,N.jsx)(ne,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>L(!0),children:(0,N.jsx)(s,{className:`w-3.5 h-3.5`})})}),(0,N.jsx)(w,{children:h(`recent.clearJobs`)})]})]})]}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,N.jsxs)(`span`,{children:[X.length===0&&h(`recent.selectTwoToCompare`),X.length===1&&h(`recent.selectOneMore`),X.length===2&&h(`recent.readyToCompare`)]}),X.length===2&&(0,N.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:h(`recent.compareAction`)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,N.jsx)(`span`,{className:`w-14`,children:h(`recent.colStatus`)}),(0,N.jsx)(`span`,{className:`flex-1 min-w-0`,children:h(`recent.colCommand`)}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:h(`recent.colDuration`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colTokens`)}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:h(`recent.colCost`)}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:h(`recent.colStarted`)})]})]}),(0,N.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,q).map(e=>{let t=ie[e.status]??ie.queued,n=se(e.total_cost_usd),r=ce(e.started_at,e.finished_at),i=le((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),c=a?e.id.replace(`proposal:`,``):null,l=X.includes(e.id),u=Y&&!a&&X.length===2&&!l;return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(Y&&!a){me(e.id);return}a&&c?f?.(c):_(`/jobs/${e.id}`)},children:[(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`div`,{children:(0,N.jsx)(o,{variant:t.variant,children:h(t.labelKey)})})}),(0,N.jsx)(w,{children:h(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${oe[e.priority].className}`,children:h(oe[e.priority].labelKey)}),e.profile_name&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,N.jsx)(w,{children:h(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,N.jsxs)(d,{children:[(0,N.jsx)(k,{asChild:!0,children:(0,N.jsx)(y,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,N.jsxs)(w,{children:[h(`recent.pipelinePart`),e.depends_on_job_id&&` ${h(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,N.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:te(e.command,C)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,N.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,N.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,N.jsx)(`span`,{className:`w-20 text-right`,children:ue(e.started_at)}),a&&c&&(0,N.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),K(c)},title:h(`recent.deleteProposal`),children:(0,N.jsx)(s,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>q&&(0,N.jsx)(`div`,{className:`pt-1 text-center`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>J(e=>e+z),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:h(`recent.loadMore`,{count:$.length-q})})}),I&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>L(!1),children:(0,N.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:h(`recent.clearModal.title`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:h(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:U,onClick:()=>ge(`all`),children:h(`recent.clearModal.clearAll`,{count:e.length})}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`recent.clearModal.orByRange`)}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`input`,{type:`date`,value:R,onChange:e=>B(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.fromPlaceholder`)}),(0,N.jsx)(`input`,{type:`date`,value:V,onChange:e=>H(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:h(`recent.clearModal.toPlaceholder`)})]}),(0,N.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:U||!R&&!V,onClick:()=>ge(`range`),children:R||V?h(`recent.clearModal.clearInRange`,{count:he}):h(`recent.clearModal.clearRange`)})]}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>L(!1),children:h(`common:actions.cancel`)})]})}),(0,N.jsx)(p,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,N.jsxs)(D,{className:`max-w-sm`,children:[(0,N.jsxs)(E,{children:[(0,N.jsx)(l,{children:h(`recent.deleteProposalConfirm.title`)}),(0,N.jsx)(c,{children:h(`recent.deleteProposalConfirm.description`)})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:h(`common:actions.cancel`)}),(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&ee?.(G),K(null)},children:h(`common:actions.delete`)})]})]})}),fe&&(0,N.jsx)(re,{jobIds:fe,onClose:()=>{Q(null),Z([]),de(!1)}})]})}function V(){let{t:e}=b(`jobs`),{activeProjectId:r}=m(),{recentJobs:i}=S(r),{data:s,isFirstLoad:c,refresh:u}=j({namespace:`jobs`,projectId:r,initialValue:i,fetcher:async()=>{let e=await fetch(`${a()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:d}=j({namespace:`proposals`,projectId:r,initialValue:[],fetcher:async()=>{let e=await fetch(`${a()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),f={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},_=d.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:f[e.status]??`queued`})),v=[...s,..._].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,x]=(0,M.useState)(null),C=(0,M.useCallback)(async e=>{try{let t=await fetch(`${a()}/propose/${e}`);if(!t.ok)return;x((await t.json()).proposal)}catch{}},[]),w=(0,M.useCallback)(async t=>{try{(await fetch(`${a()}/propose/${t}`,{method:`DELETE`})).ok&&(n.success(e(`page.proposalDeleted`)),u())}catch{}},[u,e]);return(0,N.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,N.jsx)(A,{baseUrl:`${a()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,N.jsx)(B,{jobs:v,isLoading:c,onJobsCleared:u,onProposalClick:C,onProposalDelete:w}),(0,N.jsx)(p,{open:y!==null,onOpenChange:e=>!e&&x(null),children:(0,N.jsx)(D,{className:`max-w-3xl glass-card`,children:y&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(l,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,N.jsx)(o,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,N.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,N.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,N.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,N.jsx)(h,{remarkPlugins:[ee],children:y.result_markdown})})}):(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,N.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,N.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,N.jsxs)(t,{children:[(0,N.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{w(y.id),x(null)},children:e(`common:actions.delete`)}),(0,N.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>x(null),children:e(`common:actions.close`)})]})]})})})]})}export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./index-
|
|
1
|
+
import{r as e}from"./index-CNiaj7Sj.js";function t(e){if(e!==void 0){if(typeof e==`string`)return e;if(`ok`in e&&`cancel`in e)return{OkCancelCustom:[e.ok,e.cancel]};if(`yes`in e&&`no`in e&&`cancel`in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if(`ok`in e)return{OkCustom:e.ok}}}async function n(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|open`,{options:t})}async function r(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|save`,{options:t})}async function i(n,r){return await e(`plugin:dialog|message`,{message:n,title:r?.title,kind:r?.kind,buttons:t(r?.buttons)})}async function a(e,t){let n=typeof t==`string`?{title:t}:t;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),i(e,n)}async function o(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Yes`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`No`}:`YesNo`})===a}async function s(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Ok`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`Cancel`}:`OkCancel`})===a}export{o as ask,s as confirm,a as message,n as open,r as save};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./index-
|
|
1
|
+
import{n as e,r as t}from"./index-CNiaj7Sj.js";var n=class{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.addListener(e,n)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(e=>e!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){let n=this.eventListeners[e];for(let e of n)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.prependListener(e,n)}},r=class{constructor(e){this.pid=e}async write(e){await t(`plugin:shell|stdin_write`,{pid:this.pid,buffer:e})}async kill(){await t(`plugin:shell|kill`,{cmd:`killChild`,pid:this.pid})}},i=class i extends n{constructor(e,t=[],r){super(),this.stdout=new n,this.stderr=new n,this.program=e,this.args=typeof t==`string`?[t]:t,this.options=r??{}}static create(e,t=[],n){return new i(e,t,n)}static sidecar(e,t=[],n){let r=new i(e,t,n);return r.options.sidecar=!0,r}async spawn(){let n=this.program,i=this.args,a=this.options;typeof i==`object`&&Object.freeze(i);let o=new e;return o.onmessage=e=>{switch(e.event){case`Error`:this.emit(`error`,e.payload);break;case`Terminated`:this.emit(`close`,e.payload);break;case`Stdout`:this.stdout.emit(`data`,e.payload);break;case`Stderr`:this.stderr.emit(`data`,e.payload);break}},await t(`plugin:shell|spawn`,{program:n,args:i,options:a,onEvent:o}).then(e=>new r(e))}async execute(){let e=this.program,n=this.args,r=this.options;return typeof n==`object`&&Object.freeze(n),await t(`plugin:shell|execute`,{program:e,args:n,options:r})}};async function a(e,n){await t(`plugin:shell|open`,{path:e,with:n})}export{r as Child,i as Command,n as EventEmitter,a as open};
|