specrails-desktop 2.20.0 → 2.20.1
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-BgLjSsDn.js → ActivityFeedPage-3WSqRYVx.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-R87DoreG.js → AgentBrowserCapture-BlGDZahz.js} +1 -1
- package/client/dist/assets/{AgentModeCodePane-CO8F0ttc.js → AgentModeCodePane-Cnsea6eZ.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-BecN3lwS.js → AgentModeJobsPane-CyNR-9BO.js} +1 -1
- package/client/dist/assets/{AgentsPage-_-Q9plMs.js → AgentsPage-dNsEsY_x.js} +1 -1
- package/client/dist/assets/AnalyticsPage-BAxmR0HQ.js +1 -0
- package/client/dist/assets/{BarChart-DZlxRF5i.js → BarChart-C6If656N.js} +1 -1
- package/client/dist/assets/{CodePage-4eiDoOBX.js → CodePage-Crc4BBQN.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-DyiCeq0h.js → DesktopAnalyticsPage-IXSnbCce.js} +1 -1
- package/client/dist/assets/{DocsDialog-CDZv0FMK.js → DocsDialog-Bc4hx7oW.js} +1 -1
- package/client/dist/assets/{DocsPage-BmwaXyUf.js → DocsPage-bEU4t9c6.js} +1 -1
- package/client/dist/assets/{ExportDropdown-CWafyruY.js → ExportDropdown-CezTK0EX.js} +1 -1
- package/client/dist/assets/{IntegrationsPage-CY2jfpeW.js → IntegrationsPage-wq2CezEL.js} +1 -1
- package/client/dist/assets/{JobDetailPage-p0lsbXRg.js → JobDetailPage-BBcPk3j8.js} +1 -1
- package/client/dist/assets/{JobsPage-GeKC3ckC.js → JobsPage-DXrSPlwa.js} +1 -1
- package/client/dist/assets/{LogViewer-Cz7jzyU2.js → LogViewer-BoYbwvbU.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-C_vv7AW2.js → LoopBuilderPage-CiUMAuWz.js} +1 -1
- package/client/dist/assets/{LoopsPage-CettzySP.js → LoopsPage-Xrp6W5XW.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-Xw30FTul.js → ProjectSettingsDialog-BU98L5JD.js} +1 -1
- package/client/dist/assets/analytics-B7bPj6u_2.js +1 -0
- package/client/dist/assets/analytics-BakymH7Z2.js +1 -0
- package/client/dist/assets/analytics-CBvaxOId.js +1 -0
- package/client/dist/assets/analytics-Ce-sPORu.js +1 -0
- package/client/dist/assets/analytics-DZ74aQ54.js +1 -0
- package/client/dist/assets/analytics-WF1I49ln.js +1 -0
- package/client/dist/assets/analytics-slx4X1mu2.js +1 -0
- package/client/dist/assets/analytics-uRNP6yAJ.js +1 -0
- package/client/dist/assets/{dist-js-DoZ1SVEs.js → dist-js-BAWSqVtr.js} +1 -1
- package/client/dist/assets/{dist-js-zlcAXgob.js → dist-js-BQn4yxaw.js} +1 -1
- package/client/dist/assets/index-BHPbzyg6.css +2 -0
- package/client/dist/assets/{index-CG4z4_Mq.js → index-n2PmJGF6.js} +47 -47
- package/client/dist/assets/jobs-BqF79kHz2.js +1 -0
- package/client/dist/assets/jobs-C1XM5urS.js +1 -0
- package/client/dist/assets/jobs-C5UjG0262.js +1 -0
- package/client/dist/assets/jobs-DBfaHTxC.js +1 -0
- package/client/dist/assets/jobs-DM4BDPdg.js +1 -0
- package/client/dist/assets/jobs-Da5OkZmf2.js +1 -0
- package/client/dist/assets/jobs-JJdnuQ03.js +1 -0
- package/client/dist/assets/{jobs---dwa4Nf.js → jobs-SI34ML8I.js} +1 -1
- package/client/dist/assets/{lib-zJbG81CY.js → lib-C-g8QbZl.js} +1 -1
- package/client/dist/assets/{upload-Cm4KWhcE.js → upload-CRtTj4Co.js} +1 -1
- package/client/dist/assets/{value-m3Q84dDF.js → value-D9aLbxw-.js} +1 -1
- package/client/dist/index.html +4 -4
- package/package.json +1 -1
- package/server/dist/agent-chat-manager.js +57 -4
- package/server/dist/agent-generator.js +110 -14
- package/server/dist/agent-refine-manager.js +51 -28
- package/server/dist/ai-invocations.js +14 -0
- package/server/dist/chat-manager.js +179 -38
- package/server/dist/db.js +30 -22
- package/server/dist/desktop-analytics.js +83 -31
- package/server/dist/desktop-db.js +62 -0
- package/server/dist/file-summary-generator.js +7 -2
- package/server/dist/interactive-job-session.js +126 -4
- package/server/dist/loop-executors.js +5 -0
- package/server/dist/loop-run-manager.js +7 -0
- package/server/dist/pricing.js +77 -17
- package/server/dist/profiles-router.js +12 -4
- package/server/dist/project-registry.js +7 -3
- package/server/dist/project-router-spending.js +46 -1
- package/server/dist/project-router-tickets.js +51 -5
- package/server/dist/proposal-manager.js +70 -3
- package/server/dist/providers/claude-adapter.js +67 -6
- package/server/dist/queue-manager.js +487 -81
- package/server/dist/rail-isolated-launch.js +10 -0
- package/server/dist/rail-merge-orchestrator.js +53 -2
- package/server/dist/result-event.js +20 -7
- package/server/dist/setup-manager.js +63 -3
- package/server/dist/smash-runner.js +73 -25
- package/server/dist/spec-launcher-manager.js +85 -2
- package/server/dist/spending.js +61 -16
- package/client/dist/assets/AnalyticsPage-Cqh5IGaF.js +0 -1
- package/client/dist/assets/analytics-B4FJ_pry.js +0 -1
- package/client/dist/assets/analytics-BBAfeB1o.js +0 -1
- package/client/dist/assets/analytics-BM1R5CEp2.js +0 -1
- package/client/dist/assets/analytics-BjLruoYS.js +0 -1
- package/client/dist/assets/analytics-CKwh2zUr.js +0 -1
- package/client/dist/assets/analytics-CpcjUkV72.js +0 -1
- package/client/dist/assets/analytics-DbXHdSlk2.js +0 -1
- package/client/dist/assets/analytics-Djzr1xUQ.js +0 -1
- package/client/dist/assets/index-5mbwBNQ-.css +0 -2
- package/client/dist/assets/jobs-Bvh_HiRo2.js +0 -1
- package/client/dist/assets/jobs-BzYX5VLd.js +0 -1
- package/client/dist/assets/jobs-DTfaTfzQ2.js +0 -1
- package/client/dist/assets/jobs-DrPyq5J2.js +0 -1
- package/client/dist/assets/jobs-Dty7cCdI2.js +0 -1
- package/client/dist/assets/jobs-Dv8MP-eE.js +0 -1
- package/client/dist/assets/jobs-DvkAoA8D.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,Bn as n,Cn as r,Dt as i,G as a,H as o,J as s,Jt as c,K as l,Kn as u,Ln as d,Q as f,Rn as p,Sn as m,Ut as h,V as g,Yt as _,at as v,dn as y,i as b,it as x,ln as S,q as C,un as w,wn as T,xt as E,yt as D,z as O}from"./index-CG4z4_Mq.js";var k=e(u(),1),A=r(),j=[`todo`,`in_progress`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=p(`jira`),r=e.connection,[i,a]=(0,k.useState)(r.enabled),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(!1),[u,m]=(0,k.useState)([]),[h,g]=(0,k.useState)([]),[_,v]=(0,k.useState)(r.discardStatus??``),[y,b]=(0,k.useState)(r.statusMap??{}),x=e.outbox??{pending:0,inflight:0,done:0,dead:0},S=(0,k.useCallback)(async()=>{try{let{ops:e}=await O.listOutbox(`dead`);m(e)}catch{m([])}},[]);(0,k.useEffect)(()=>{S()},[S]),(0,k.useEffect)(()=>{let e=!1;return O.listStatuses().then(({statuses:t})=>{e||g(t)}).catch(()=>{e||g([])}),()=>{e=!0}},[]);async function C(e){let r=_;v(e);try{await O.patchConnection({discardStatus:e||null}),t()}catch(e){v(r),d.error(F(e,n))}}async function w(e,r){let i=y,a={...y,[e]:r||void 0};b(a);let o=Object.fromEntries(Object.entries(a).filter(([,e])=>e));try{await O.patchConnection({statusMap:Object.keys(o).length?o:null}),t()}catch(e){b(i),d.error(F(e,n))}}async function T(){let e=!i;a(e),l(!0);try{await O.setEnabled(e)}catch(t){a(!e),d.error(F(t,n))}finally{l(!1)}}async function E(){s(!0);try{let e=await O.syncNow();d.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){d.error(F(e,n))}finally{s(!1)}}async function D(){if(window.confirm(n(`status.disconnectConfirm`))){l(!0);try{await O.disconnect(),d.success(n(`status.disconnectedToast`)),t()}catch(e){d.error(F(e,n))}finally{l(!1)}}}async function N(e){try{await O.retryOutbox(e),await S()}catch(e){d.error(F(e,n))}}let I=x.pending+x.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:r.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.baseUrl,` · `,r.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${r.baseUrl}/browse/${r.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(i?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":n(`status.enabledLabel`),disabled:c,onClick:T,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${i?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${i?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:y[e]??``,onChange:t=>void w(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!h.some(t=>t.name===y[e])&&(0,A.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:_,onChange:e=>void C(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,A.jsx)(`option`,{value:_,children:_})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:E,disabled:o,children:n(o?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:D,disabled:c,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),x.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:x.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),u.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),u.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(null),[s,c]=(0,k.useState)(!0),[u,d]=(0,k.useState)(!1),[f,m]=(0,k.useState)(!1),h=(0,k.useCallback)(async()=>{try{i(await O.getConnection())}catch{i({connected:!1})}finally{c(!1)}},[]);if((0,k.useEffect)(()=>{!t||!e||(c(!0),h())},[e,h]),!t)return null;let v=!!(r?.connected&&r.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(E,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`jiraCard.title`)}),v&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(_,{className:`w-3 h-3`}),` `,n(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:v&&r?.connection?n(`jiraCard.connectedDescription`,{key:r.connection.jiraProjectKey}):n(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:n(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:n(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:s?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):v?(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:n(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(E,{className:`w-3.5 h-3.5`}),n(`jiraCard.connect`)]})}),(0,A.jsx)(g,{open:u,onOpenChange:d,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.modalTitle`)})}),(0,A.jsx)(b,{onConnected:()=>{d(!1),h()},onSkip:()=>d(!1)})]})}),(0,A.jsx)(g,{open:f,onOpenChange:m,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.manageTitle`)})}),r?.connected&&r.connection&&(0,A.jsx)(N,{state:r,onChanged:()=>{h().then(()=>m(!1))}})]})})]})}function L(){let{t:e}=p(`integrations`),{activeProjectId:n,projects:r}=w(),i=r.find(e=>e.id===n),a=i?S(i).includes(`claude`):!0,{registerHandler:o,unregisterHandler:s}=m(),c=(0,k.useRef)(n);(0,k.useEffect)(()=>{c.current=n},[n]);let[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(null),{data:h,isLoading:g,isFirstLoad:_,refresh:v}=y({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${T()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(o(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==c.current||t.type.startsWith(`plugin.`)&&v())}),()=>s(`integrations-page`)),[o,s,v]),(0,k.useEffect)(()=>{u(!g&&!h?`Failed to load plugins`:null)},[g,h]);let b=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status!==`orphan`),[h]),C=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status===`orphan`),[h]);return n?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(D,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:_&&g?(0,A.jsx)(q,{}):l&&a?(0,A.jsx)(J,{onRetry:v}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:n}),a&&b.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:d===e.name,onInstall:()=>f(e.name),onCloseInstall:()=>{f(null),v()}},e.name))]}),a&&C.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:v},e.name))})]}),!t&&(!a||b.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:t,onInstall:r,onCloseInstall:i}){let{t:a}=p(`integrations`),[o,s]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.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,A.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,A.jsx)(_,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.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,A.jsx)(x,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.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,A.jsx)(h,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.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,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(n,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>s(!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,A.jsx)(v,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,A.jsx)(W,{pluginName:e.name,onClose:i}),o&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>s(!1),onUninstalled:()=>{s(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${T()}/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){o(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,A.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,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function B({keys:e}){let{t}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.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,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t}=p(`integrations`),[r,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(null);return(0,A.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,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{a(!0),s(null);try{let t=await fetch(`${T()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(!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,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),o&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function H({pluginName:e,conflicts:t}){let{t:r}=p(`integrations`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),l=async e=>{o(e),c(null);try{let t=await fetch(`${T()}/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){c(e.message)}finally{o(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:a===e,onClick:()=>l(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[a===e&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),s&&(0,A.jsx)(`div`,{className:`text-destructive`,children:s})]})}function U({plugin:e,onRemoved:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${T()}/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,A.jsx)(v,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:t}){let{t:n}=p(`integrations`),[r,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(null),[l,u]=(0,k.useState)(!1),[d,f]=(0,k.useState)(null),[g,v]=(0,k.useState)([]),[y,b]=(0,k.useState)(null),[S,C]=(0,k.useState)([]),{registerHandler:w,unregisterHandler:E}=m(),D=(0,k.useCallback)(()=>{a(null),s(null),fetch(`${T()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>a(e)).catch(e=>s(e.message))},[e]);(0,k.useEffect)(()=>{D()},[D]),(0,k.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&v(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&C(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&C(t=>[...t,`► ${e}`]),n.ok&&D()}}),()=>E(`install-${e}`)),[e,w,E,D]);let O=async e=>{b(e),C([n(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${T()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){C(t=>[...t,n(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(r?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:t,title:n(`installDialog.title`,{name:e}),children:[o&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),!r&&!o&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),` `,n(`installDialog.computingChanges`)]}),r&&(0,A.jsxs)(A.Fragment,{children:[r.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:r.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:r.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),r.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:r.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,r=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(_,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&r&&(0,A.jsxs)(`button`,{type:`button`,disabled:y===e.name,onClick:()=>O(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:[y===e.name&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),n(`installDialog.autoInstall`)]})]},e.name)})}),S.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:S.join(`
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,Bn as n,Cn as r,Dt as i,G as a,H as o,J as s,Jt as c,K as l,Kn as u,Ln as d,Q as f,Rn as p,Sn as m,Ut as h,V as g,Yt as _,at as v,dn as y,i as b,it as x,ln as S,q as C,un as w,wn as T,xt as E,yt as D,z as O}from"./index-n2PmJGF6.js";var k=e(u(),1),A=r(),j=[`todo`,`in_progress`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=p(`jira`),r=e.connection,[i,a]=(0,k.useState)(r.enabled),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(!1),[u,m]=(0,k.useState)([]),[h,g]=(0,k.useState)([]),[_,v]=(0,k.useState)(r.discardStatus??``),[y,b]=(0,k.useState)(r.statusMap??{}),x=e.outbox??{pending:0,inflight:0,done:0,dead:0},S=(0,k.useCallback)(async()=>{try{let{ops:e}=await O.listOutbox(`dead`);m(e)}catch{m([])}},[]);(0,k.useEffect)(()=>{S()},[S]),(0,k.useEffect)(()=>{let e=!1;return O.listStatuses().then(({statuses:t})=>{e||g(t)}).catch(()=>{e||g([])}),()=>{e=!0}},[]);async function C(e){let r=_;v(e);try{await O.patchConnection({discardStatus:e||null}),t()}catch(e){v(r),d.error(F(e,n))}}async function w(e,r){let i=y,a={...y,[e]:r||void 0};b(a);let o=Object.fromEntries(Object.entries(a).filter(([,e])=>e));try{await O.patchConnection({statusMap:Object.keys(o).length?o:null}),t()}catch(e){b(i),d.error(F(e,n))}}async function T(){let e=!i;a(e),l(!0);try{await O.setEnabled(e)}catch(t){a(!e),d.error(F(t,n))}finally{l(!1)}}async function E(){s(!0);try{let e=await O.syncNow();d.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){d.error(F(e,n))}finally{s(!1)}}async function D(){if(window.confirm(n(`status.disconnectConfirm`))){l(!0);try{await O.disconnect(),d.success(n(`status.disconnectedToast`)),t()}catch(e){d.error(F(e,n))}finally{l(!1)}}}async function N(e){try{await O.retryOutbox(e),await S()}catch(e){d.error(F(e,n))}}let I=x.pending+x.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:r.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.baseUrl,` · `,r.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${r.baseUrl}/browse/${r.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(i?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":n(`status.enabledLabel`),disabled:c,onClick:T,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${i?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${i?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:y[e]??``,onChange:t=>void w(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!h.some(t=>t.name===y[e])&&(0,A.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:_,onChange:e=>void C(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,A.jsx)(`option`,{value:_,children:_})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:E,disabled:o,children:n(o?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:D,disabled:c,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),x.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:x.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),u.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),u.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(null),[s,c]=(0,k.useState)(!0),[u,d]=(0,k.useState)(!1),[f,m]=(0,k.useState)(!1),h=(0,k.useCallback)(async()=>{try{i(await O.getConnection())}catch{i({connected:!1})}finally{c(!1)}},[]);if((0,k.useEffect)(()=>{!t||!e||(c(!0),h())},[e,h]),!t)return null;let v=!!(r?.connected&&r.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(E,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`jiraCard.title`)}),v&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(_,{className:`w-3 h-3`}),` `,n(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:v&&r?.connection?n(`jiraCard.connectedDescription`,{key:r.connection.jiraProjectKey}):n(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:n(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:n(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:s?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):v?(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:n(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(E,{className:`w-3.5 h-3.5`}),n(`jiraCard.connect`)]})}),(0,A.jsx)(g,{open:u,onOpenChange:d,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.modalTitle`)})}),(0,A.jsx)(b,{onConnected:()=>{d(!1),h()},onSkip:()=>d(!1)})]})}),(0,A.jsx)(g,{open:f,onOpenChange:m,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.manageTitle`)})}),r?.connected&&r.connection&&(0,A.jsx)(N,{state:r,onChanged:()=>{h().then(()=>m(!1))}})]})})]})}function L(){let{t:e}=p(`integrations`),{activeProjectId:n,projects:r}=w(),i=r.find(e=>e.id===n),a=i?S(i).includes(`claude`):!0,{registerHandler:o,unregisterHandler:s}=m(),c=(0,k.useRef)(n);(0,k.useEffect)(()=>{c.current=n},[n]);let[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(null),{data:h,isLoading:g,isFirstLoad:_,refresh:v}=y({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${T()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(o(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==c.current||t.type.startsWith(`plugin.`)&&v())}),()=>s(`integrations-page`)),[o,s,v]),(0,k.useEffect)(()=>{u(!g&&!h?`Failed to load plugins`:null)},[g,h]);let b=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status!==`orphan`),[h]),C=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status===`orphan`),[h]);return n?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(D,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:_&&g?(0,A.jsx)(q,{}):l&&a?(0,A.jsx)(J,{onRetry:v}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:n}),a&&b.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:d===e.name,onInstall:()=>f(e.name),onCloseInstall:()=>{f(null),v()}},e.name))]}),a&&C.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:v},e.name))})]}),!t&&(!a||b.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:t,onInstall:r,onCloseInstall:i}){let{t:a}=p(`integrations`),[o,s]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.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,A.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,A.jsx)(_,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.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,A.jsx)(x,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.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,A.jsx)(h,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.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,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(n,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>s(!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,A.jsx)(v,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,A.jsx)(W,{pluginName:e.name,onClose:i}),o&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>s(!1),onUninstalled:()=>{s(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${T()}/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){o(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,A.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,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function B({keys:e}){let{t}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.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,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t}=p(`integrations`),[r,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(null);return(0,A.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,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{a(!0),s(null);try{let t=await fetch(`${T()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(!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,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),o&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function H({pluginName:e,conflicts:t}){let{t:r}=p(`integrations`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),l=async e=>{o(e),c(null);try{let t=await fetch(`${T()}/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){c(e.message)}finally{o(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:a===e,onClick:()=>l(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[a===e&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),s&&(0,A.jsx)(`div`,{className:`text-destructive`,children:s})]})}function U({plugin:e,onRemoved:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${T()}/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,A.jsx)(v,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:t}){let{t:n}=p(`integrations`),[r,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(null),[l,u]=(0,k.useState)(!1),[d,f]=(0,k.useState)(null),[g,v]=(0,k.useState)([]),[y,b]=(0,k.useState)(null),[S,C]=(0,k.useState)([]),{registerHandler:w,unregisterHandler:E}=m(),D=(0,k.useCallback)(()=>{a(null),s(null),fetch(`${T()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>a(e)).catch(e=>s(e.message))},[e]);(0,k.useEffect)(()=>{D()},[D]),(0,k.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&v(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&C(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&C(t=>[...t,`► ${e}`]),n.ok&&D()}}),()=>E(`install-${e}`)),[e,w,E,D]);let O=async e=>{b(e),C([n(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${T()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){C(t=>[...t,n(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(r?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:t,title:n(`installDialog.title`,{name:e}),children:[o&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),!r&&!o&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),` `,n(`installDialog.computingChanges`)]}),r&&(0,A.jsxs)(A.Fragment,{children:[r.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:r.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:r.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),r.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:r.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,r=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(_,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&r&&(0,A.jsxs)(`button`,{type:`button`,disabled:y===e.name,onClick:()=>O(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:[y===e.name&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),n(`installDialog.autoInstall`)]})]},e.name)})}),S.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:S.join(`
|
|
2
2
|
`)})]}),g.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.progress`)}),(0,A.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:g.join(`
|
|
3
3
|
`)})]}),d&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:d})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:n(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:!r||!j||l,onClick:async()=>{u(!0),f(null);try{let n=await fetch(`${T()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){f(e.message)}finally{u(!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:[l?(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}):(0,A.jsx)(h,{className:`w-3 h-3`}),n(`card.install`)]})]})]})}function G({pluginName:e,onClose:t,onUninstalled:r}){let{t:a}=p(`integrations`),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(null);return(0,A.jsxs)(K,{onClose:t,title:a(`uninstallDialog.title`,{name:e}),children:[(0,A.jsx)(`p`,{className:`text-xs`,children:(0,A.jsx)(n,{t:a,i18nKey:`uninstallDialog.body`,components:{code:(0,A.jsx)(`code`,{})}})}),c&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:c}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:a(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0);try{let t=await fetch(`${T()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);r()}catch(e){l(e.message)}finally{s(!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,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),a(`card.uninstall`)]})]})]})}function K({title:e,onClose:t,children:n}){let{panelRef:r,panelStyle:i,headerHandleProps:a,resizeHandles:o,isFloating:c,guardBackdrop:l}=s();return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:l(t),children:[(0,A.jsxs)(`div`,{ref:r,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(),style:i,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold ${c?`cursor-grab active:cursor-grabbing`:``}`,...a,children:e}),n]}),(0,A.jsx)(C,{handles:o})]})}function q(){return(0,A.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,A.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function J({onRetry:e}){let{t}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,A.jsx)(x,{className:`w-5 h-5 text-destructive`}),(0,A.jsx)(`p`,{children:t(`page.loadError`)}),(0,A.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 Y(){let{t:e}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,A.jsx)(D,{className:`w-6 h-6`}),(0,A.jsx)(`p`,{children:e(`page.empty`)})]})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$t as n,At as r,Cn as i,Dt as a,F as o,Gt as s,Hn as c,I as l,Jt as ee,Kn as u,Ln as d,Q as f,Qt as p,R as m,Rn as h,Sn as te,Un as ne,Ut as g,Vn as _,Yt as re,Z as v,Zt as y,_t as b,fn as x,g as ie,h as S,pt as ae,un as C,v as w,wn as T,y as E}from"./index-CG4z4_Mq.js";import{t as D}from"./format-command-BHymDa4r.js";import{n as O,t as k}from"./LogViewer-Cz7jzyU2.js";var A=e(u(),1),j=i();function M(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 N(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 P={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function F(e,t){if(t.type===`reset`)return P;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=E(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function oe({job:e,events:r,defaultOpen:i=!0,pipelineTotals:o,phases:s,phaseDefinitions:c}){let{t:l}=h(`jobs`),[u,d]=(0,A.useState)(i),f=(0,A.useMemo)(()=>N(r),[r]),p=e.status===`running`,m=e.status===`completed`,[te,ne]=(0,A.useState)(()=>Date.now());(0,A.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>ne(Date.now()),1e3);return()=>window.clearInterval(e)},[p]);let[g,_]=(0,A.useReducer)(F,P),v=(0,A.useRef)(e.id);(0,A.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:r})},[e.id,r]);let[y,b]=(0,A.useState)(!0);(0,A.useEffect)(()=>{if(!p)return;b(!0);let e=window.setTimeout(()=>b(!1),8e3);return()=>window.clearTimeout(e)},[p,e.id]);let x=e.finished_at?M(e.started_at,e.finished_at):p?M(e.started_at,te):`—`,ie=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${ie?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ae=e.num_turns==null?null:String(e.num_turns),C=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=C==null?null:`${(C/1e3).toFixed(1)}k`,E=(0,A.useMemo)(()=>!s||!c?null:c.find(e=>s[e.key]===`running`)?.label??null,[s,c]),D=p&&g.steps===0?`connecting`:g.actionKey||`thinking`,O=w.has(D)&&g.actionArg!==``,k=w.has(D)&&!O?`working`:D,oe=O?l(`statusPanel.activity.${k}`,{arg:g.actionArg}):l(`statusPanel.activity.${k}`),z=E??(p&&g.steps===0?l(`statusPanel.activity.starting`):null),B=g.steps>0?l(`statusPanel.steps`,{count:g.steps}):null,V=l(p?`statusPanel.inProgress`:m?`statusPanel.completed`:`statusPanel.failed`),H=p?`border-accent-info/20 bg-accent-info/5`:m?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,U=p?a:m?re:ee,se=p?`w-4 h-4 text-accent-info shrink-0 animate-spin`:m?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,j.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border transition-colors duration-500`,H),children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,j.jsx)(U,{className:se,"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:V}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`tabular-nums`,children:x}),p?B&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:B}):(0,j.jsxs)(j.Fragment,{children:[S&&(0,j.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),f.length>0&&(0,j.jsx)(`span`,{children:l(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,j.jsx)(n,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,u&&`rotate-180`)})]}),u&&(0,j.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:p?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneInProgress`)}),(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[l(`statusPanel.duration`),(0,j.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:l(`statusPanel.liveTooltip`),"aria-label":l(`statusPanel.liveTooltip`)})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:x})]}),(0,j.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,j.jsx)(a,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),z&&(0,j.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:z}),(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:oe}),B&&(0,j.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,B]})]})]}),y&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:l(`statusPanel.explainer`)}),(0,j.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:l(`statusPanel.zoneFinalPending`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,j.jsx)(R,{label:l(`statusPanel.cost`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.costTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.turns`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.tokens`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneFinal`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.duration`),value:x}),(0,j.jsx)(L,{label:l(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.turns`),value:ae,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.tokens`),value:T,naCaption:l(`statusPanel.notAvailable`)})]}),o&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.pipelineTotal`,{count:o.jobCount})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.totalCost`),value:`$${o.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,j.jsx)(I,{label:l(`statusPanel.totalTokens`),value:`${((o.totalTokensIn+o.totalTokensOut+o.totalTokensCacheRead+o.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),f.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.filesModified`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,j.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function I({label:e,value:n,valueClass:r}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}function L({label:e,value:n,valueClass:r,naCaption:i}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,n==null?`text-muted-foreground`:r),children:n??`—`}),n==null&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:i})]})}function R({label:e,caption:t,tooltip:n}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,j.jsx)(s,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var z=4;function B({tickets:e,onTicketClick:t}){let{t:r}=h(`jobs`),[i,a]=(0,A.useState)(!1);if(e.length===0)return null;let o=e.length>=z&&!i?e.slice(0,1):e,s=e.length-o.length;return(0,j.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[o.map(e=>(0,j.jsx)(V,{ticket:e,onClick:()=>t(e.id)},e.id)),s>0&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showMore`,{count:s}),(0,j.jsx)(n,{className:`w-3 h-3`})]}),i&&e.length>=z&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showLess`),(0,j.jsx)(y,{className:`w-3 h-3`})]})]})}function V({ticket:e,onClick:n}){let{t:r}=h(`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,j.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,j.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,j.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,j.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,j.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var H={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 U(){let{t:e}=h(`jobs`),{id:n}=ne(),{activeProjectId:i,projects:s}=C(),ee=s.find(e=>e.id===i)?.provider,u=c(),{openTicketDetail:y}=S(),[w,E]=(0,A.useState)(null),[M,N]=(0,A.useState)([]),[P,F]=(0,A.useState)([]),[I,L]=(0,A.useState)({}),[R,z]=(0,A.useState)([]),[V,U]=(0,A.useState)(!0),[se,W]=(0,A.useState)(!1),[G,ce]=(0,A.useState)(null),[le,K]=(0,A.useState)(!1),[q,ue]=(0,A.useState)(``),[J,Y]=(0,A.useState)(!1),[de,fe]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(!n)return;let e=new AbortController;E(null),N([]),F([]),L({}),U(!0),W(!1);async function t(){try{let t=await fetch(`${T()}/jobs/${n}`,{signal:e.signal});if(t.status===404){W(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();E(r.job),N(r.events)}catch(e){if(e.name===`AbortError`)return;W(!0)}finally{e.signal.aborted||U(!1)}}return t(),()=>e.abort()},[n,i]),(0,A.useEffect)(()=>{if(!w?.pipeline_id){z([]);return}let e=w.pipeline_id;fetch(`${T()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&z(e.jobs)}).catch(()=>{})},[w?.pipeline_id,w?.status]);let X=(0,A.useRef)(i);X.current=i;let Z=(0,A.useRef)([]),Q=(0,A.useRef)(null),pe=(0,A.useCallback)(()=>{Q.current=null;let e=Z.current;e.length!==0&&(Z.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),me=(0,A.useCallback)(e=>{let t=Z.current;t.push(e),t.length>1e4&&(Z.current=t.slice(-8e3)),Q.current||=requestAnimationFrame(pe)},[pe]);(0,A.useEffect)(()=>()=>{Q.current&&cancelAnimationFrame(Q.current)},[]);let he=(0,A.useCallback)(e=>{let t=e;if(!(X.current&&t.projectId&&t.projectId!==X.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];F(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;L(n)}else if(t.type===`event`&&t.jobId===n)me({id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===n)me({id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.turn_user`&&t.jobId===n)K(!0);else if(t.type===`job.turn_done`&&t.jobId===n)ce(t.totals),K(!1);else if(t.type===`job.finalized`&&t.jobId===n){K(!1),Y(!1);let e=t.totals;e&&ce(e),fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}else if(t.type===`phase`){let e=t.phase,n=t.state;L(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status;E(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}}}},[n,me]),{registerHandler:ge,unregisterHandler:_e}=te();(0,A.useEffect)(()=>(ge(`job-detail-${n}`,he),()=>_e(`job-detail-${n}`)),[n,he,ge,_e]),(0,A.useEffect)(()=>{if(!n||!w||w.status!==`running`||w.hasTelemetry)return;let e=setInterval(()=>{fetch(`${T()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&E(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,w?.status,w?.hasTelemetry]);async function ve(){if(n)try{let t=await fetch(`${T()}/jobs/${n}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(d.success(e(`detail.toast.jobDeleted`)),u(`/jobs`)):d.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();d.error(e(`detail.toast.failed`),{description:n.error})}}catch{d.error(e(`detail.toast.networkError`))}}async function ye(){if(!(!n||J)){Y(!0);try{let t=await fetch(`${T()}/jobs/${n}/finalize`,{method:`POST`});if(t.ok)d.success(e(`detail.toast.finalizeScheduled`));else{let n=await t.json().catch(()=>({}));d.error(e(`detail.toast.finalizeFailed`),{description:n.error}),Y(!1)}}catch{d.error(e(`detail.toast.networkError`)),Y(!1)}}}async function be(){let t=q.trim();if(!(!n||!t||de)){fe(!0);try{let r=await fetch(`${T()}/jobs/${n}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(r.ok)ue(``);else{let t=await r.json().catch(()=>({}));d.error(e(`detail.toast.sendFailed`),{description:t.error})}}catch{d.error(e(`detail.toast.networkError`))}finally{fe(!1)}}}async function xe(){if(w)try{let t=await fetch(`${T()}/jobs/${w.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-${w.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){d.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Se(){if(w)try{let t=await fetch(`${T()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:w.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));d.success(e(`detail.toast.jobRequeued`)),u(`/jobs/${n.jobId}`)}catch(e){d.error(e.message)}}if(V)return(0,j.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,j.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,j.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(se||!w)return(0,j.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,j.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,j.jsx)(f,{asChild:!0,variant:`outline`,size:`sm`,children:(0,j.jsxs)(_,{to:`/`,children:[(0,j.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=H[w.status]??H.queued,Ce=w.status===`running`,we=w.status===`completed`||w.status===`failed`,Te=!!w.interactive,Ee=Te&&Ce,De=(w.tickets?.length??0)>0,Oe=R.length>1?{totalCostUsd:R.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:R.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:R.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:R.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:R.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:R.length}:null;return(0,j.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,j.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,j.jsxs)(_,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,j.jsx)(r,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,j.jsx)(p,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),De&&(0,j.jsx)(B,{tickets:w.tickets??[],onTicketClick:y}),(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(v,{variant:$.variant,children:e($.labelKey)})})}),(0,j.jsx)(l,{children:e($.tooltipKey)})]}),(0,j.jsx)(`code`,{className:t(`font-mono text-foreground/90 truncate`,De?`text-xs text-muted-foreground`:`text-sm`),children:D(w.command,ee)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,j.jsx)(`span`,{children:w.started_at?e(`detail.startedAgo`,{timeAgo:ie(new Date(w.started_at),{addSuffix:!0,locale:x()})}):e(`detail.queuedWaiting`)}),w.model&&(0,j.jsx)(`span`,{className:`text-muted-foreground/40`,children:w.model})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[w.hasTelemetry&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-7`,onClick:xe,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,j.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,j.jsx)(l,{children:e(`detail.exportDiagnosticTooltip`)})]}),we&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:Se,className:`h-7`,children:[(0,j.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,j.jsx)(l,{children:e(`detail.reExecuteTooltip`)})]}),Ee&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:ye,disabled:J,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,j.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(J?`detail.finalizing`:`detail.finalizeJob`)]})}),(0,j.jsx)(l,{children:e(`detail.finalizeJobTooltip`)})]}),Ce&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(f,{variant:`outline`,size:`sm`,onClick:ve,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Te?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,j.jsx)(l,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,j.jsx)(O,{phases:I,phaseDefinitions:P})]}),(w.status===`running`||w.status===`completed`||w.status===`failed`)&&(0,j.jsx)(oe,{job:w,events:M,defaultOpen:w.status===`completed`||w.status===`running`,pipelineTotals:Oe??void 0,phases:I,phaseDefinitions:P}),(0,j.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,j.jsx)(k,{events:M})}),Ee&&(0,j.jsxs)(`div`,{className:`shrink-0 border-t border-border/40 bg-surface/40 px-3 py-2 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[le&&(0,j.jsx)(a,{className:`w-3 h-3 animate-spin`}),e(le?`detail.interactive.working`:`detail.interactive.ready`)]}),G&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:e(`detail.interactive.liveTotals`,{turns:G.num_turns,cost:G.total_cost_usd.toFixed(4)})})]}),(0,j.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,j.jsx)(`textarea`,{value:q,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),be())},rows:2,placeholder:e(`detail.interactive.placeholder`),"aria-label":e(`detail.interactive.placeholder`),className:`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,j.jsxs)(f,{size:`sm`,onClick:()=>void be(),disabled:de||!q.trim(),className:`h-9 shrink-0`,children:[(0,j.jsx)(ae,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.interactive.send`)]})]})]})]})}export{U as default};
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$t as n,At as r,Cn as i,Dt as a,F as o,Gt as s,Hn as c,I as l,Jt as ee,Kn as u,Ln as d,Q as f,Qt as p,R as m,Rn as h,Sn as te,Un as ne,Ut as g,Vn as _,Yt as re,Z as v,Zt as y,_t as b,fn as x,g as ie,h as S,pt as ae,un as C,v as w,wn as T,y as E}from"./index-n2PmJGF6.js";import{t as D}from"./format-command-BHymDa4r.js";import{n as O,t as k}from"./LogViewer-BoYbwvbU.js";var A=e(u(),1),j=i();function M(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 N(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 P={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function F(e,t){if(t.type===`reset`)return P;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=E(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function oe({job:e,events:r,defaultOpen:i=!0,pipelineTotals:o,phases:s,phaseDefinitions:c}){let{t:l}=h(`jobs`),[u,d]=(0,A.useState)(i),f=(0,A.useMemo)(()=>N(r),[r]),p=e.status===`running`,m=e.status===`completed`,[te,ne]=(0,A.useState)(()=>Date.now());(0,A.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>ne(Date.now()),1e3);return()=>window.clearInterval(e)},[p]);let[g,_]=(0,A.useReducer)(F,P),v=(0,A.useRef)(e.id);(0,A.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:r})},[e.id,r]);let[y,b]=(0,A.useState)(!0);(0,A.useEffect)(()=>{if(!p)return;b(!0);let e=window.setTimeout(()=>b(!1),8e3);return()=>window.clearTimeout(e)},[p,e.id]);let x=e.finished_at?M(e.started_at,e.finished_at):p?M(e.started_at,te):`—`,ie=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${ie?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ae=e.num_turns==null?null:String(e.num_turns),C=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=C==null?null:`${(C/1e3).toFixed(1)}k`,E=(0,A.useMemo)(()=>!s||!c?null:c.find(e=>s[e.key]===`running`)?.label??null,[s,c]),D=p&&g.steps===0?`connecting`:g.actionKey||`thinking`,O=w.has(D)&&g.actionArg!==``,k=w.has(D)&&!O?`working`:D,oe=O?l(`statusPanel.activity.${k}`,{arg:g.actionArg}):l(`statusPanel.activity.${k}`),z=E??(p&&g.steps===0?l(`statusPanel.activity.starting`):null),B=g.steps>0?l(`statusPanel.steps`,{count:g.steps}):null,V=l(p?`statusPanel.inProgress`:m?`statusPanel.completed`:`statusPanel.failed`),H=p?`border-accent-info/20 bg-accent-info/5`:m?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,U=p?a:m?re:ee,se=p?`w-4 h-4 text-accent-info shrink-0 animate-spin`:m?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,j.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border transition-colors duration-500`,H),children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,j.jsx)(U,{className:se,"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:V}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`tabular-nums`,children:x}),p?B&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:B}):(0,j.jsxs)(j.Fragment,{children:[S&&(0,j.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),f.length>0&&(0,j.jsx)(`span`,{children:l(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,j.jsx)(n,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,u&&`rotate-180`)})]}),u&&(0,j.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:p?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneInProgress`)}),(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[l(`statusPanel.duration`),(0,j.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:l(`statusPanel.liveTooltip`),"aria-label":l(`statusPanel.liveTooltip`)})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:x})]}),(0,j.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,j.jsx)(a,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),z&&(0,j.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:z}),(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:oe}),B&&(0,j.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,B]})]})]}),y&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:l(`statusPanel.explainer`)}),(0,j.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:l(`statusPanel.zoneFinalPending`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,j.jsx)(R,{label:l(`statusPanel.cost`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.costTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.turns`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.tokens`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneFinal`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.duration`),value:x}),(0,j.jsx)(L,{label:l(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.turns`),value:ae,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.tokens`),value:T,naCaption:l(`statusPanel.notAvailable`)})]}),o&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.pipelineTotal`,{count:o.jobCount})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.totalCost`),value:`${o.costEstimated?`~`:``}${o.hasNullCost?`≥`:``}$${o.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,j.jsx)(I,{label:l(`statusPanel.totalTokens`),value:`${((o.totalTokensIn+o.totalTokensOut+o.totalTokensCacheRead+o.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),o.hasNullCost&&(0,j.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:l(`statusPanel.pipelinePartialTooltip`),children:l(`statusPanel.pipelinePartial`,{count:o.nullCostCount??0})})]}),f.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.filesModified`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,j.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function I({label:e,value:n,valueClass:r}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}function L({label:e,value:n,valueClass:r,naCaption:i}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,n==null?`text-muted-foreground`:r),children:n??`—`}),n==null&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:i})]})}function R({label:e,caption:t,tooltip:n}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,j.jsx)(s,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var z=4;function B({tickets:e,onTicketClick:t}){let{t:r}=h(`jobs`),[i,a]=(0,A.useState)(!1);if(e.length===0)return null;let o=e.length>=z&&!i?e.slice(0,1):e,s=e.length-o.length;return(0,j.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[o.map(e=>(0,j.jsx)(V,{ticket:e,onClick:()=>t(e.id)},e.id)),s>0&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showMore`,{count:s}),(0,j.jsx)(n,{className:`w-3 h-3`})]}),i&&e.length>=z&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showLess`),(0,j.jsx)(y,{className:`w-3 h-3`})]})]})}function V({ticket:e,onClick:n}){let{t:r}=h(`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,j.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,j.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,j.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,j.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,j.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var H={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 U(){let{t:e}=h(`jobs`),{id:n}=ne(),{activeProjectId:i,projects:s}=C(),ee=s.find(e=>e.id===i)?.provider,u=c(),{openTicketDetail:y}=S(),[w,E]=(0,A.useState)(null),[M,N]=(0,A.useState)([]),[P,F]=(0,A.useState)([]),[I,L]=(0,A.useState)({}),[R,z]=(0,A.useState)([]),[V,U]=(0,A.useState)(!0),[se,W]=(0,A.useState)(!1),[G,ce]=(0,A.useState)(null),[le,K]=(0,A.useState)(!1),[q,ue]=(0,A.useState)(``),[J,Y]=(0,A.useState)(!1),[de,fe]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(!n)return;let e=new AbortController;E(null),N([]),F([]),L({}),U(!0),W(!1);async function t(){try{let t=await fetch(`${T()}/jobs/${n}`,{signal:e.signal});if(t.status===404){W(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();E(r.job),N(r.events)}catch(e){if(e.name===`AbortError`)return;W(!0)}finally{e.signal.aborted||U(!1)}}return t(),()=>e.abort()},[n,i]),(0,A.useEffect)(()=>{if(!w?.pipeline_id){z([]);return}let e=w.pipeline_id;fetch(`${T()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&z(e.jobs)}).catch(()=>{})},[w?.pipeline_id,w?.status]);let X=(0,A.useRef)(i);X.current=i;let Z=(0,A.useRef)([]),Q=(0,A.useRef)(null),pe=(0,A.useCallback)(()=>{Q.current=null;let e=Z.current;e.length!==0&&(Z.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),me=(0,A.useCallback)(e=>{let t=Z.current;t.push(e),t.length>1e4&&(Z.current=t.slice(-8e3)),Q.current||=requestAnimationFrame(pe)},[pe]);(0,A.useEffect)(()=>()=>{Q.current&&cancelAnimationFrame(Q.current)},[]);let he=(0,A.useCallback)(e=>{let t=e;if(!(X.current&&t.projectId&&t.projectId!==X.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];F(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;L(n)}else if(t.type===`event`&&t.jobId===n)me({id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===n)me({id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.turn_user`&&t.jobId===n)K(!0);else if(t.type===`job.turn_done`&&t.jobId===n)ce(t.totals),K(!1);else if(t.type===`job.finalized`&&t.jobId===n){K(!1),Y(!1);let e=t.totals;e&&ce(e),fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}else if(t.type===`phase`){let e=t.phase,n=t.state;L(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status;E(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}}}},[n,me]),{registerHandler:ge,unregisterHandler:_e}=te();(0,A.useEffect)(()=>(ge(`job-detail-${n}`,he),()=>_e(`job-detail-${n}`)),[n,he,ge,_e]),(0,A.useEffect)(()=>{if(!n||!w||w.status!==`running`||w.hasTelemetry)return;let e=setInterval(()=>{fetch(`${T()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&E(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,w?.status,w?.hasTelemetry]);async function ve(){if(n)try{let t=await fetch(`${T()}/jobs/${n}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(d.success(e(`detail.toast.jobDeleted`)),u(`/jobs`)):d.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();d.error(e(`detail.toast.failed`),{description:n.error})}}catch{d.error(e(`detail.toast.networkError`))}}async function ye(){if(!(!n||J)){Y(!0);try{let t=await fetch(`${T()}/jobs/${n}/finalize`,{method:`POST`});if(t.ok)d.success(e(`detail.toast.finalizeScheduled`));else{let n=await t.json().catch(()=>({}));d.error(e(`detail.toast.finalizeFailed`),{description:n.error}),Y(!1)}}catch{d.error(e(`detail.toast.networkError`)),Y(!1)}}}async function be(){let t=q.trim();if(!(!n||!t||de)){fe(!0);try{let r=await fetch(`${T()}/jobs/${n}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(r.ok)ue(``);else{let t=await r.json().catch(()=>({}));d.error(e(`detail.toast.sendFailed`),{description:t.error})}}catch{d.error(e(`detail.toast.networkError`))}finally{fe(!1)}}}async function xe(){if(w)try{let t=await fetch(`${T()}/jobs/${w.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-${w.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){d.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Se(){if(w)try{let t=await fetch(`${T()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:w.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));d.success(e(`detail.toast.jobRequeued`)),u(`/jobs/${n.jobId}`)}catch(e){d.error(e.message)}}if(V)return(0,j.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,j.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,j.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(se||!w)return(0,j.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,j.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,j.jsx)(f,{asChild:!0,variant:`outline`,size:`sm`,children:(0,j.jsxs)(_,{to:`/`,children:[(0,j.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=H[w.status]??H.queued,Ce=w.status===`running`,we=w.status===`completed`||w.status===`failed`,Te=!!w.interactive,Ee=Te&&Ce,De=(w.tickets?.length??0)>0,Oe=R.length>1?{totalCostUsd:R.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:R.some(e=>e.total_cost_usd==null),costEstimated:R.some(e=>!!e.total_cost_usd_estimated),nullCostCount:R.filter(e=>e.total_cost_usd==null).length,totalTokensIn:R.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:R.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:R.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:R.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:R.length}:null;return(0,j.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,j.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,j.jsxs)(_,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,j.jsx)(r,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,j.jsx)(p,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),De&&(0,j.jsx)(B,{tickets:w.tickets??[],onTicketClick:y}),(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(v,{variant:$.variant,children:e($.labelKey)})})}),(0,j.jsx)(l,{children:e($.tooltipKey)})]}),(0,j.jsx)(`code`,{className:t(`font-mono text-foreground/90 truncate`,De?`text-xs text-muted-foreground`:`text-sm`),children:D(w.command,ee)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,j.jsx)(`span`,{children:w.started_at?e(`detail.startedAgo`,{timeAgo:ie(new Date(w.started_at),{addSuffix:!0,locale:x()})}):e(`detail.queuedWaiting`)}),w.model&&(0,j.jsx)(`span`,{className:`text-muted-foreground/40`,children:w.model})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[w.hasTelemetry&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-7`,onClick:xe,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,j.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,j.jsx)(l,{children:e(`detail.exportDiagnosticTooltip`)})]}),we&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:Se,className:`h-7`,children:[(0,j.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,j.jsx)(l,{children:e(`detail.reExecuteTooltip`)})]}),Ee&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:ye,disabled:J,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,j.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(J?`detail.finalizing`:`detail.finalizeJob`)]})}),(0,j.jsx)(l,{children:e(`detail.finalizeJobTooltip`)})]}),Ce&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(f,{variant:`outline`,size:`sm`,onClick:ve,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Te?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,j.jsx)(l,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,j.jsx)(O,{phases:I,phaseDefinitions:P})]}),(w.status===`running`||w.status===`completed`||w.status===`failed`)&&(0,j.jsx)(oe,{job:w,events:M,defaultOpen:w.status===`completed`||w.status===`running`,pipelineTotals:Oe??void 0,phases:I,phaseDefinitions:P}),(0,j.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,j.jsx)(k,{events:M})}),Ee&&(0,j.jsxs)(`div`,{className:`shrink-0 border-t border-border/40 bg-surface/40 px-3 py-2 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[le&&(0,j.jsx)(a,{className:`w-3 h-3 animate-spin`}),e(le?`detail.interactive.working`:`detail.interactive.ready`)]}),G&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:e(`detail.interactive.liveTotals`,{turns:G.num_turns,cost:G.total_cost_usd.toFixed(4)})})]}),(0,j.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,j.jsx)(`textarea`,{value:q,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),be())},rows:2,placeholder:e(`detail.interactive.placeholder`),"aria-label":e(`detail.interactive.placeholder`),className:`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,j.jsxs)(f,{size:`sm`,onClick:()=>void be(),disabled:de||!q.trim(),className:`h-9 shrink-0`,children:[(0,j.jsx)(ae,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.interactive.send`)]})]})]})]})}export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,D as n,E as r,F as i,G as a,H as o,Hn as s,I as c,J as l,Jt as u,K as d,Kn as f,Kt as p,Ln as m,Ot as h,Q as g,R as _,Rn as v,U as y,V as ee,W as te,Yt as b,Z as x,at as S,cn as ne,dn as C,fn as re,g as w,q as T,t as E,tt as D,un as ie,wn as O}from"./index-CG4z4_Mq.js";import{t as ae}from"./format-command-BHymDa4r.js";import{t as k}from"./ExportDropdown-CWafyruY.js";var oe=ne(`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`}]]),A=e(f(),1),j=t();function M(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 N(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function P(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function F({label:e,a:t,b:n,highlight:r}){return(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,j.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function I(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=v(`jobs`),[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(!0),[s,c]=(0,A.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:p,resizeHandles:m,isFloating:h,guardBackdrop:g}=l();(0,A.useEffect)(()=>{let t=new AbortController;return fetch(`${O()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(c(e.message),o(!1))}),()=>t.abort()},[e]);function _(e,t){return(0,j.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,j.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,j.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,j.jsx)(b,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,j.jsx)(u,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,j.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:g(t),children:[(0,j.jsxs)(`div`,{ref:d,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(),style:f,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between ${h?`cursor-grab active:cursor-grabbing`:``}`,...p,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,j.jsx)(D,{className:`w-4 h-4`})})]}),a&&(0,j.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,j.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),s&&(0,j.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:s})}),r&&(()=>{let[e,t]=r.jobs,i=I(e.durationMs,t.durationMs,!0),a=I(e.totalCostUsd,t.totalCostUsd,!0),o=I(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,j.jsx)(`div`,{}),_(e,0),_(t,1)]}),(0,j.jsx)(F,{label:n(`comparison.duration`),a:M(e.durationMs),b:M(t.durationMs),highlight:i}),(0,j.jsx)(F,{label:n(`comparison.cost`),a:N(e.totalCostUsd),b:N(t.totalCostUsd),highlight:a}),(0,j.jsx)(F,{label:n(`comparison.tokensOut`),a:P(e.tokensOut),b:P(t.tokensOut),highlight:o}),(0,j.jsx)(F,{label:n(`comparison.tokensIn`),a:P(e.tokensIn),b:P(t.tokensIn),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.cacheRead`),a:P(e.tokensCacheRead),b:P(t.tokensCacheRead),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,j.jsx)(F,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,j.jsx)(T,{handles:m})]})}var ce={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`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],L={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function ue(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function de(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 fe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pe(e){try{return w(new Date(e),{addSuffix:!0,locale:re()})}catch{return e}}function R(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function z(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function B(e,t,n){if(!t&&!n)return!0;let r=new Date(e).getTime();return Number.isNaN(r)?!0:!(t&&r<R(t)||n&&r>z(n))}var V=10;function H({jobs:e,isLoading:t,onJobsCleared:n,onProposalClick:r,onProposalDelete:u}){let{t:f}=v(`jobs`),b=s(),{activeProjectId:ne,projects:C}=ie(),re=C.find(e=>e.id===ne)?.provider,[w,E]=(0,A.useState)(null),[D,k]=(0,A.useState)(``),[M,N]=(0,A.useState)(``),[P,F]=(0,A.useState)(!1),[I,H]=(0,A.useState)(``),[U,W]=(0,A.useState)(``),[me,he]=(0,A.useState)(!1),[G,K]=(0,A.useState)(null),[q,ge]=(0,A.useState)(V),[J,_e]=(0,A.useState)(!1),[Y,X]=(0,A.useState)([]),[ve,Z]=(0,A.useState)(null),{panelRef:ye,panelStyle:be,headerHandleProps:xe,resizeHandles:Se,isFloating:Ce,guardBackdrop:we}=l();(0,A.useEffect)(()=>{ge(V)},[e.length]);function Te(){_e(e=>!e),X([])}function Ee(e){X(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&&Z(n),n})}let Q=e.filter(e=>w&&e.status!==w?!1:B(e.started_at,D,M)),De=e.filter(e=>B(e.started_at,I,U)).length;async function $(e){he(!0);try{let t={};e===`range`&&(I&&(t.from=new Date(R(I)).toISOString()),U&&(t.to=new Date(z(U)).toISOString()));let r=await fetch(`${O()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();m.success(f(`recent.toast.cleared`,{count:e.deleted})),F(!1),H(``),W(``),n?.()}else m.error(f(`recent.toast.clearFailed`))}catch{m.error(f(`recent.toast.networkError`))}finally{he(!1)}}return t?(0,j.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,j.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,j.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,j.jsx)(p,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,j.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${w===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>E(w===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${w===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterStatus`,{status:f(`statusName.${t}`),count:n})},t)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:D,onChange:e=>k(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,j.jsx)(`input`,{type:`date`,value:M,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(D||M)&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>{k(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${J?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Te,children:(0,j.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(c,{children:f(J?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>F(!0),children:(0,j.jsx)(S,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(c,{children:f(`recent.clearJobs`)})]})]})]}),J&&(0,j.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,j.jsxs)(`span`,{children:[Y.length===0&&f(`recent.selectTwoToCompare`),Y.length===1&&f(`recent.selectOneMore`),Y.length===2&&f(`recent.readyToCompare`)]}),Y.length===2&&(0,j.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Z(Y),children:f(`recent.compareAction`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,j.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,j.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,j.jsx)(`div`,{className:`space-y-0.5`,children:Q.slice(0,q).map(e=>{let t=ce[e.status]??ce.queued,n=ue(e.total_cost_usd),a=de(e.started_at,e.finished_at),o=fe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),s=e.id.startsWith(`proposal:`),l=s?e.id.replace(`proposal:`,``):null,u=Y.includes(e.id),d=J&&!s&&Y.length===2&&!u;return(0,j.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${u?`bg-accent/70 ring-1 ring-border`:d?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(J&&!s){Ee(e.id);return}s&&l?r?.(l):b(`/jobs/${e.id}`)},children:[(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(x,{variant:t.variant,children:f(t.labelKey)})})}),(0,j.jsx)(c,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,j.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${L[e.priority].className}`,children:f(L[e.priority].labelKey)}),e.profile_name&&(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.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,j.jsx)(c,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(h,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,j.jsxs)(c,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,j.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ae(e.command,re)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:a??`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:o?`${o}`:`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:pe(e.started_at)}),s&&l&&(0,j.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(l)},title:f(`recent.deleteProposal`),children:(0,j.jsx)(S,{className:`w-3 h-3`})})]})]},e.id)})}),Q.length>q&&(0,j.jsx)(`div`,{className:`pt-1 text-center`,children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:f(`recent.loadMore`,{count:Q.length-q})})}),P&&(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:we(()=>F(!1)),children:[(0,j.jsxs)(`div`,{ref:ye,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:be,children:[(0,j.jsxs)(`div`,{...xe,className:Ce?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,j.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:me,onClick:()=>$(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:I,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:f(`recent.clearModal.fromPlaceholder`)}),(0,j.jsx)(`input`,{type:`date`,value:U,onChange:e=>W(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.toPlaceholder`)})]}),(0,j.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:me||!I&&!U,onClick:()=>$(`range`),children:I||U?f(`recent.clearModal.clearInRange`,{count:De}):f(`recent.clearModal.clearRange`)})]}),(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>F(!1),children:f(`common:actions.cancel`)})]}),(0,j.jsx)(T,{handles:Se})]}),(0,j.jsx)(ee,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,j.jsxs)(o,{className:`max-w-sm`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(d,{children:f(`recent.deleteProposalConfirm.title`)}),(0,j.jsx)(y,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,j.jsxs)(te,{children:[(0,j.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:f(`common:actions.cancel`)}),(0,j.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&u?.(G),K(null)},children:f(`common:actions.delete`)})]})]})}),ve&&(0,j.jsx)(se,{jobIds:ve,onClose:()=>{Z(null),X([]),_e(!1)}})]})}function U(){let{t:e}=v(`jobs`),{activeProjectId:t}=ie(),{recentJobs:i}=E(t),{data:s,isFirstLoad:c,refresh:l}=C({namespace:`jobs`,projectId:t,initialValue:i,fetcher:async()=>{let e=await fetch(`${O()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:u}=C({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async()=>{let e=await fetch(`${O()}/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`},p=u.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`})),h=[...s,...p].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[_,y]=(0,A.useState)(null),b=(0,A.useCallback)(async e=>{try{let t=await fetch(`${O()}/propose/${e}`);if(!t.ok)return;y((await t.json()).proposal)}catch{}},[]),S=(0,A.useCallback)(async t=>{try{(await fetch(`${O()}/propose/${t}`,{method:`DELETE`})).ok&&(m.success(e(`page.proposalDeleted`)),l())}catch{}},[l,e]);return(0,j.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,j.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,j.jsx)(k,{baseUrl:`${O()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,j.jsx)(H,{jobs:h,isLoading:c,onJobsCleared:l,onProposalClick:b,onProposalDelete:S}),(0,j.jsx)(ee,{open:_!==null,onOpenChange:e=>!e&&y(null),children:(0,j.jsx)(o,{className:`max-w-3xl glass-card`,children:_&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(d,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,j.jsx)(x,{variant:_.status===`created`?`success`:_.status===`cancelled`?`destructive`:`secondary`,children:_.status})]})}),(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:_.idea}),_.result_markdown?(0,j.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,j.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,j.jsx)(n,{remarkPlugins:[r],children:_.result_markdown})})}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),_.issue_url&&(0,j.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,j.jsx)(`a`,{href:_.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:_.issue_url})]}),(0,j.jsxs)(te,{children:[(0,j.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{S(_.id),y(null)},children:e(`common:actions.delete`)}),(0,j.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>y(null),children:e(`common:actions.close`)})]})]})})})]})}export{U as default};
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,D as n,E as r,F as i,G as a,H as o,Hn as s,I as c,J as l,Jt as u,K as d,Kn as f,Kt as p,Ln as m,Ot as h,Q as g,R as _,Rn as v,U as y,V as ee,W as te,Yt as b,Z as x,at as S,cn as ne,dn as C,fn as re,g as w,q as T,t as E,tt as D,un as ie,wn as O}from"./index-n2PmJGF6.js";import{t as ae}from"./format-command-BHymDa4r.js";import{t as k}from"./ExportDropdown-CezTK0EX.js";var oe=ne(`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`}]]),A=e(f(),1),j=t();function M(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 N(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function P(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function F({label:e,a:t,b:n,highlight:r}){return(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,j.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function I(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=v(`jobs`),[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(!0),[s,c]=(0,A.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:p,resizeHandles:m,isFloating:h,guardBackdrop:g}=l();(0,A.useEffect)(()=>{let t=new AbortController;return fetch(`${O()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(c(e.message),o(!1))}),()=>t.abort()},[e]);function _(e,t){return(0,j.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,j.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,j.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,j.jsx)(b,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,j.jsx)(u,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,j.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:g(t),children:[(0,j.jsxs)(`div`,{ref:d,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(),style:f,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between ${h?`cursor-grab active:cursor-grabbing`:``}`,...p,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,j.jsx)(D,{className:`w-4 h-4`})})]}),a&&(0,j.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,j.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),s&&(0,j.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:s})}),r&&(()=>{let[e,t]=r.jobs,i=I(e.durationMs,t.durationMs,!0),a=I(e.totalCostUsd,t.totalCostUsd,!0),o=I(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,j.jsx)(`div`,{}),_(e,0),_(t,1)]}),(0,j.jsx)(F,{label:n(`comparison.duration`),a:M(e.durationMs),b:M(t.durationMs),highlight:i}),(0,j.jsx)(F,{label:n(`comparison.cost`),a:N(e.totalCostUsd),b:N(t.totalCostUsd),highlight:a}),(0,j.jsx)(F,{label:n(`comparison.tokensOut`),a:P(e.tokensOut),b:P(t.tokensOut),highlight:o}),(0,j.jsx)(F,{label:n(`comparison.tokensIn`),a:P(e.tokensIn),b:P(t.tokensIn),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.cacheRead`),a:P(e.tokensCacheRead),b:P(t.tokensCacheRead),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,j.jsx)(F,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,j.jsx)(T,{handles:m})]})}var ce={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`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],L={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function ue(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function de(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 fe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pe(e){try{return w(new Date(e),{addSuffix:!0,locale:re()})}catch{return e}}function R(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function z(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function B(e,t,n){if(!t&&!n)return!0;let r=new Date(e).getTime();return Number.isNaN(r)?!0:!(t&&r<R(t)||n&&r>z(n))}var V=10;function H({jobs:e,isLoading:t,onJobsCleared:n,onProposalClick:r,onProposalDelete:u}){let{t:f}=v(`jobs`),b=s(),{activeProjectId:ne,projects:C}=ie(),re=C.find(e=>e.id===ne)?.provider,[w,E]=(0,A.useState)(null),[D,k]=(0,A.useState)(``),[M,N]=(0,A.useState)(``),[P,F]=(0,A.useState)(!1),[I,H]=(0,A.useState)(``),[U,W]=(0,A.useState)(``),[me,he]=(0,A.useState)(!1),[G,K]=(0,A.useState)(null),[q,ge]=(0,A.useState)(V),[J,_e]=(0,A.useState)(!1),[Y,X]=(0,A.useState)([]),[ve,Z]=(0,A.useState)(null),{panelRef:ye,panelStyle:be,headerHandleProps:xe,resizeHandles:Se,isFloating:Ce,guardBackdrop:we}=l();(0,A.useEffect)(()=>{ge(V)},[e.length]);function Te(){_e(e=>!e),X([])}function Ee(e){X(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&&Z(n),n})}let Q=e.filter(e=>w&&e.status!==w?!1:B(e.started_at,D,M)),De=e.filter(e=>B(e.started_at,I,U)).length;async function $(e){he(!0);try{let t={};e===`range`&&(I&&(t.from=new Date(R(I)).toISOString()),U&&(t.to=new Date(z(U)).toISOString()));let r=await fetch(`${O()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();m.success(f(`recent.toast.cleared`,{count:e.deleted})),F(!1),H(``),W(``),n?.()}else m.error(f(`recent.toast.clearFailed`))}catch{m.error(f(`recent.toast.networkError`))}finally{he(!1)}}return t?(0,j.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,j.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,j.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,j.jsx)(p,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,j.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${w===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>E(w===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${w===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterStatus`,{status:f(`statusName.${t}`),count:n})},t)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:D,onChange:e=>k(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,j.jsx)(`input`,{type:`date`,value:M,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(D||M)&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>{k(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${J?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Te,children:(0,j.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(c,{children:f(J?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>F(!0),children:(0,j.jsx)(S,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(c,{children:f(`recent.clearJobs`)})]})]})]}),J&&(0,j.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,j.jsxs)(`span`,{children:[Y.length===0&&f(`recent.selectTwoToCompare`),Y.length===1&&f(`recent.selectOneMore`),Y.length===2&&f(`recent.readyToCompare`)]}),Y.length===2&&(0,j.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Z(Y),children:f(`recent.compareAction`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,j.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,j.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,j.jsx)(`div`,{className:`space-y-0.5`,children:Q.slice(0,q).map(e=>{let t=ce[e.status]??ce.queued,n=ue(e.total_cost_usd),a=de(e.started_at,e.finished_at),o=fe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),s=e.id.startsWith(`proposal:`),l=s?e.id.replace(`proposal:`,``):null,u=Y.includes(e.id),d=J&&!s&&Y.length===2&&!u;return(0,j.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${u?`bg-accent/70 ring-1 ring-border`:d?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(J&&!s){Ee(e.id);return}s&&l?r?.(l):b(`/jobs/${e.id}`)},children:[(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(x,{variant:t.variant,children:f(t.labelKey)})})}),(0,j.jsx)(c,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,j.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${L[e.priority].className}`,children:f(L[e.priority].labelKey)}),e.profile_name&&(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.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,j.jsx)(c,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,j.jsxs)(i,{children:[(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(h,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,j.jsxs)(c,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,j.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ae(e.command,re)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:a??`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:o?`${o}`:`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:pe(e.started_at)}),s&&l&&(0,j.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(l)},title:f(`recent.deleteProposal`),children:(0,j.jsx)(S,{className:`w-3 h-3`})})]})]},e.id)})}),Q.length>q&&(0,j.jsx)(`div`,{className:`pt-1 text-center`,children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:f(`recent.loadMore`,{count:Q.length-q})})}),P&&(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:we(()=>F(!1)),children:[(0,j.jsxs)(`div`,{ref:ye,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:be,children:[(0,j.jsxs)(`div`,{...xe,className:Ce?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,j.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:me,onClick:()=>$(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:I,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:f(`recent.clearModal.fromPlaceholder`)}),(0,j.jsx)(`input`,{type:`date`,value:U,onChange:e=>W(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:f(`recent.clearModal.toPlaceholder`)})]}),(0,j.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:me||!I&&!U,onClick:()=>$(`range`),children:I||U?f(`recent.clearModal.clearInRange`,{count:De}):f(`recent.clearModal.clearRange`)})]}),(0,j.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>F(!1),children:f(`common:actions.cancel`)})]}),(0,j.jsx)(T,{handles:Se})]}),(0,j.jsx)(ee,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,j.jsxs)(o,{className:`max-w-sm`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(d,{children:f(`recent.deleteProposalConfirm.title`)}),(0,j.jsx)(y,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,j.jsxs)(te,{children:[(0,j.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:f(`common:actions.cancel`)}),(0,j.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{G&&u?.(G),K(null)},children:f(`common:actions.delete`)})]})]})}),ve&&(0,j.jsx)(se,{jobIds:ve,onClose:()=>{Z(null),X([]),_e(!1)}})]})}function U(){let{t:e}=v(`jobs`),{activeProjectId:t}=ie(),{recentJobs:i}=E(t),{data:s,isFirstLoad:c,refresh:l}=C({namespace:`jobs`,projectId:t,initialValue:i,fetcher:async()=>{let e=await fetch(`${O()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:u}=C({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async()=>{let e=await fetch(`${O()}/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`},p=u.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`})),h=[...s,...p].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[_,y]=(0,A.useState)(null),b=(0,A.useCallback)(async e=>{try{let t=await fetch(`${O()}/propose/${e}`);if(!t.ok)return;y((await t.json()).proposal)}catch{}},[]),S=(0,A.useCallback)(async t=>{try{(await fetch(`${O()}/propose/${t}`,{method:`DELETE`})).ok&&(m.success(e(`page.proposalDeleted`)),l())}catch{}},[l,e]);return(0,j.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,j.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,j.jsx)(k,{baseUrl:`${O()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,j.jsx)(H,{jobs:h,isLoading:c,onJobsCleared:l,onProposalClick:b,onProposalDelete:S}),(0,j.jsx)(ee,{open:_!==null,onOpenChange:e=>!e&&y(null),children:(0,j.jsx)(o,{className:`max-w-3xl glass-card`,children:_&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(d,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,j.jsx)(x,{variant:_.status===`created`?`success`:_.status===`cancelled`?`destructive`:`secondary`,children:_.status})]})}),(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:_.idea}),_.result_markdown?(0,j.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,j.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,j.jsx)(n,{remarkPlugins:[r],children:_.result_markdown})})}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),_.issue_url&&(0,j.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,j.jsx)(`a`,{href:_.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:_.issue_url})]}),(0,j.jsxs)(te,{children:[(0,j.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{S(_.id),y(null)},children:e(`common:actions.delete`)}),(0,j.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>y(null),children:e(`common:actions.close`)})]})]})})})]})}export{U as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$t as n,Cn as r,D as i,Dt as a,E as o,F as s,I as c,Jt as l,Kn as u,Ln as d,Q as f,Qt as p,R as m,Rn as h,Wt as g,Yt as _,f as v,mt as y,pn as b,qt as x}from"./index-
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$t as n,Cn as r,D as i,Dt as a,E as o,F as s,I as c,Jt as l,Kn as u,Ln as d,Q as f,Qt as p,R as m,Rn as h,Wt as g,Yt as _,f as v,mt as y,pn as b,qt as x}from"./index-n2PmJGF6.js";import{t as S}from"./lib-C-g8QbZl.js";var C=r();function w({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,C.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,C.jsxs)(`div`,{className:`flex items-center`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(m,{asChild:!0,children:(0,C.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,C.jsx)(T,{state:a}),(0,C.jsx)(`span`,{className:t(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400 aurora-light:text-accent-info`:a===`done`?`text-emerald-400 aurora-light:text-accent-success`:a===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:r.label})]})}),(0,C.jsxs)(c,{side:`bottom`,className:`max-w-[200px]`,children:[(0,C.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,C.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),o!==null&&(0,C.jsx)(`div`,{className:t(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:o===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},r.key)})})}function T({state:e}){return(0,C.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 aurora-light:bg-accent-info/10 ring-1 ring-blue-400/30 aurora-light:ring-accent-info/30 animate-pulse`:e===`done`?`bg-emerald-500/10 aurora-light:bg-accent-success/10`:e===`error`?`bg-red-500/10 aurora-light:bg-destructive/10`:`bg-muted/20`),children:[e===`running`&&(0,C.jsx)(a,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,C.jsx)(_,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,C.jsx)(l,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,C.jsx)(x,{className:`w-6 h-6 text-muted-foreground/20`})]})}var E=e(u(),1);function D(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 O(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}:D(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(b.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${b.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function k(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 A(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 j({events:e,isLoading:t}){let{t:r,i18n:i}=h(`jobs`),[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(!0),[l,u]=(0,E.useState)(new Set),p=(0,E.useRef)(null),m=(0,E.useRef)(null),{processedLines:_,groups:b,totalLines:x}=(0,E.useMemo)(()=>{let t=e.map((e,t)=>O(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
2
|
`+e.content:n.push({...e})}let r=k(n);return{processedLines:r,groups:A(r),totalLines:r.length}},[e,i.language]),S=(0,E.useMemo)(()=>{if(!a)return x;let e=a.toLowerCase();return _.filter(t=>t.content.toLowerCase().includes(e)).length},[a,_,x]),w=(0,E.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,E.useEffect)(()=>{s&&w()},[e.length,s,w]);function T(){let e=m.current;e&&c(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function D(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,C.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):x===0?(0,C.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,C.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,C.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,C.jsx)(y,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,C.jsx)(v,{placeholder:r(`logViewer.filterPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`pl-7 h-7`})]}),(0,C.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=_.map(e=>e.content).join(`
|
|
3
3
|
`);navigator.clipboard.writeText(e).then(()=>{d.success(r(`logViewer.copySuccess`))}).catch(()=>{d.error(r(`logViewer.copyFailed`))})},children:(0,C.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,C.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:S,total:x})})]}),(0,C.jsxs)(`div`,{ref:m,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:T,children:[b.map(e=>(0,C.jsx)(M,{group:e,filter:a,collapsed:l.has(e.key),onToggle:()=>D(e.key)},e.key)),(0,C.jsx)(`div`,{ref:p})]}),!s&&(0,C.jsxs)(f,{size:`sm`,variant:`secondary`,onClick:()=>{c(!0),w()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,C.jsx)(n,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var M=(0,E.memo)(function({group:e,filter:n,collapsed:r,onToggle:i}){let{t:a}=h(`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,C.jsx)(`div`,{children:o.map((e,t)=>(0,C.jsx)(P,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,C.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,C.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,C.jsx)(p,{className:t(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!r&&`rotate-90`)}),(0,C.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,C.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,C.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!r&&(0,C.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,C.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,C.jsx)(P,{line:e,even:t%2==0},e.id))})]})}),N=[S],P=(0,E.memo)(function({line:e,even:n}){let r=e.type===`assistant`,a=e.type===`diff-add`,s=e.type===`diff-remove`,c=e.type===`diff-meta`,l=e.type===`diff-hunk`;return(0,C.jsxs)(`div`,{className:t(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(a||s||c||l)&&(n?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/40 aurora-light:border-accent-success/40 mt-2 py-2`,a&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,s&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,c&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,l&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,C.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,C.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
4
|
prose-p:my-1 prose-p:leading-relaxed
|