specrails-desktop 2.30.2 → 2.30.3

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.
Files changed (28) hide show
  1. package/client/dist/assets/{ActivityFeedPage-9DZOvIcY.js → ActivityFeedPage-CcBOllqm.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-DqyHbzk7.js → AgentBrowserCapture-BOJkZUj_.js} +1 -1
  3. package/client/dist/assets/{AgentModeCodePane-BAYyFRmY.js → AgentModeCodePane-BIh67rGi.js} +2 -2
  4. package/client/dist/assets/{AgentModeJobsPane-CTIHMUKN.js → AgentModeJobsPane-C5tkU2Ed.js} +1 -1
  5. package/client/dist/assets/{AgentsPage-DuyJuaFs.js → AgentsPage-CNlE_Uh4.js} +1 -1
  6. package/client/dist/assets/{AnalyticsPage-BY7gtCx6.js → AnalyticsPage-cYcJxWPn.js} +1 -1
  7. package/client/dist/assets/{CodePage-vyQr40Vl.js → CodePage-D4QYa4t1.js} +1 -1
  8. package/client/dist/assets/{DesktopAnalyticsPage-CkXUFj3F.js → DesktopAnalyticsPage-DCmgYV86.js} +1 -1
  9. package/client/dist/assets/{DocsDialog-PhdCJNVj.js → DocsDialog-BXnOgm7V.js} +1 -1
  10. package/client/dist/assets/{DocsPage-BY-wDthx.js → DocsPage-nFkHh-Dc.js} +1 -1
  11. package/client/dist/assets/{InteractiveJobComposer-C9I0A4KR.js → InteractiveJobComposer-qoeZjwVY.js} +1 -1
  12. package/client/dist/assets/{JobDetailModal-I_RoQJV4.js → JobDetailModal-ChRBB9bc.js} +1 -1
  13. package/client/dist/assets/{JobDetailPage-CU4FEnUC.js → JobDetailPage-BuOnlndB.js} +1 -1
  14. package/client/dist/assets/{JobsPage-DcllM4Ip.js → JobsPage-C_UEIXWA.js} +1 -1
  15. package/client/dist/assets/{LoopBuilderPage-DGm_iuff.js → LoopBuilderPage-BV_wge0g.js} +1 -1
  16. package/client/dist/assets/{LoopPreviewModal-BC-TeFdD.js → LoopPreviewModal-Qk_Jaxo8.js} +1 -1
  17. package/client/dist/assets/{LoopsPage-SqglnXlp.js → LoopsPage-lLi6ax0p.js} +1 -1
  18. package/client/dist/assets/{PluginsPage-B89S8o1a.js → PluginsPage-DZIFv9kw.js} +1 -1
  19. package/client/dist/assets/{ProjectSettingsDialog-nEs-ENrE.js → ProjectSettingsDialog-DEHcyt_I.js} +1 -1
  20. package/client/dist/assets/{TemplatePreviewModal-D4qW-J9B.js → TemplatePreviewModal-Bxbtnzob.js} +1 -1
  21. package/client/dist/assets/{TicketDetailModal-CI47Dq9E.js → TicketDetailModal-CqQ5gx7O.js} +2 -2
  22. package/client/dist/assets/{dist-js-jwoXo0YD.js → dist-js-CBhuoTO6.js} +1 -1
  23. package/client/dist/assets/{dist-js-Dj72W6qo.js → dist-js-eSxaoEw0.js} +1 -1
  24. package/client/dist/assets/{index-F9r8mWP_.js → index-CewRMo0W.js} +10 -10
  25. package/client/dist/index.html +2 -2
  26. package/package.json +1 -1
  27. package/server/dist/core-update-manager.js +17 -1
  28. package/server/dist/framework-manager.js +19 -2
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{a as i}from"./i18n-Bf9Ckd10.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./dist-bVqfYmby.js";import{p as s}from"./useBrowserCaptureSession-CkBJShUw.js";import{i as c,n as l,r as u,t as d}from"./InteractiveJobComposer-C9I0A4KR.js";import{t as ee}from"./loader-circle-DcygOQpC.js";import{t as te}from"./x-CBMI9ejn.js";import{a as f,n as p}from"./auth-D_5bQv5W.js";import{t as m}from"./api-B2M7CtDw.js";import{t as h}from"./button-BUIIBQPT.js";import{c as ne,s as re}from"./dialog-CzIekCw0.js";import{t as ie}from"./formatDistanceToNow-ByKli7Q_.js";import{F as g,I as _,L as v,N as y,P as b,n as x,r as S}from"./index-F9r8mWP_.js";import{n as C,t as w}from"./job-time-BCL7wee9.js";var T=e(r(),1),E=e(t(),1),D=[1e3,2e3,4e3,8e3,16e3];function O(e,t){let[n,r]=(0,E.useState)(`connecting`),i=(0,E.useRef)(null),a=(0,E.useRef)(0),o=(0,E.useRef)(null),s=(0,E.useRef)(t);s.current=t;let c=(0,E.useCallback)(()=>{let t=p(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);s.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=D.length){r(`disconnected`);return}let t=D[e];a.current+=1,o.current=setTimeout(c,t)}},[e]);return(0,E.useEffect)(()=>(c(),()=>{o.current&&clearTimeout(o.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[c]),{connectionStatus:n}}var k=n();function ae(e,t){let n=C(e),r=C(t);if(!n||!r)return`—`;let i=r.getTime()-n.getTime();if(i<0)return`—`;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}var A={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`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function j({jobId:e,onClose:t,projectId:n}){let{t:r}=a(`jobs`),p=(0,E.useCallback)(()=>n?`${f}/api/projects/${n}`:m(),[n]),[D,j]=(0,E.useState)(null),[M,N]=(0,E.useState)([]),[P,F]=(0,E.useState)([]),[I,L]=(0,E.useState)({}),[R,z]=(0,E.useState)(!0),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(!1);(0,E.useEffect)(()=>{async function t(){try{let t=await fetch(`${p()}/jobs/${e}`);if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(j(n.job),N(n.events),n.phaseDefinitions){F(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;L(e)}}catch{V(!0)}finally{z(!1)}}t()},[e,p]);let K=(0,E.useCallback)(()=>{fetch(`${p()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&j(e.job)}).catch(()=>{})},[e,p]),q=(0,E.useRef)([]),J=(0,E.useRef)(null),Y=(0,E.useCallback)(()=>{J.current=null;let e=q.current;e.length!==0&&(q.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,E.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),O(s,(0,E.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`job.finalized`&&n.jobId===e||n.type===`job.interactive`&&n.jobId===e||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===e)K();else if(n.type===`phase`){let e=n.phase,t=n.state;L(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&D&&j(e=>e&&{...e,status:t.status})}},[e,D,Y,K])),(0,E.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(H){U(!1);return}t()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,H]);let X=D?S(D):`job`,Z=X===`loop-run`;async function oe(){G(!0);try{let t=await x({projectId:n??null,jobId:e,kind:X});t.ok?(o.success(r(Z?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:r(Z?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):o.error(r(`modal.toast.cancelFailed`),{description:t.error})}finally{G(!1)}}let Q=D?A[D.status]??A.queued:A.queued,se=D?.status===`running`,$=D?C(w(D)):null,{panelRef:ce,panelStyle:le,headerHandleProps:ue,resizeHandles:de,isFloating:fe,guardBackdrop:pe}=ne();return(0,T.createPortal)((0,k.jsx)(g,{delayDuration:400,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:pe(t)}),(0,k.jsxs)(`div`,{ref:ce,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:le,children:[(0,k.jsxs)(`div`,{...ue,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${fe?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y,{children:[(0,k.jsx)(_,{asChild:!0,children:(0,k.jsx)(`div`,{children:(0,k.jsx)(v,{variant:Q.variant,children:r(Q.labelKey)})})}),(0,k.jsx)(b,{children:r(Q.tooltipKey)})]}),(0,k.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:D.command}),(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:$?ie($,{addSuffix:!0,locale:i()}):`—`}),D.total_cost_usd!=null&&D.total_cost_usd>0&&(0,k.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,D.total_cost_usd.toFixed(4)]}),D.started_at&&D.finished_at&&(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ae(D.started_at,D.finished_at)})]}),R&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`common:states.loading`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[P.length>0&&(0,k.jsx)(`div`,{className:`mr-3`,children:(0,k.jsx)(c,{phases:I,phaseDefinitions:P})}),se&&(0,k.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),disabled:W,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[W&&(0,k.jsx)(ee,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),r(Z?`dashboard:railControls.stop`:X===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,k.jsx)(`button`,{onClick:t,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,k.jsx)(te,{className:`w-4 h-4`})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:B?(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`modal.notFound`)})}):D?.command.startsWith(`loop:`)?(0,k.jsx)(l,{events:M,jobStatus:D.status,isLoading:R,variant:`glass`,projectId:n}):(0,k.jsx)(u,{events:M,isLoading:R,projectId:n})}),!!D?.interactive&&D.status===`running`&&(0,k.jsx)(d,{jobId:e,projectId:n,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,k.jsx)(re,{handles:de}),H&&(0,k.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>U(!1)}),(0,k.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl glass-card border border-border/30 p-5 shadow-xl animate-in fade-in zoom-in-95 duration-150`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(Z?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,k.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:r(Z?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:r(`modal.keepRunning`)}),(0,k.jsx)(h,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),oe()},children:r(Z?`modal.stopRun`:X===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{j as JobDetailModal};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{a as i}from"./i18n-Bf9Ckd10.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./dist-bVqfYmby.js";import{p as s}from"./useBrowserCaptureSession-CkBJShUw.js";import{i as c,n as l,r as u,t as d}from"./InteractiveJobComposer-qoeZjwVY.js";import{t as ee}from"./loader-circle-DcygOQpC.js";import{t as te}from"./x-CBMI9ejn.js";import{a as f,n as p}from"./auth-D_5bQv5W.js";import{t as m}from"./api-B2M7CtDw.js";import{t as h}from"./button-BUIIBQPT.js";import{c as ne,s as re}from"./dialog-CzIekCw0.js";import{t as ie}from"./formatDistanceToNow-ByKli7Q_.js";import{F as g,I as _,L as v,N as y,P as b,n as x,r as S}from"./index-CewRMo0W.js";import{n as C,t as w}from"./job-time-BCL7wee9.js";var T=e(r(),1),E=e(t(),1),D=[1e3,2e3,4e3,8e3,16e3];function O(e,t){let[n,r]=(0,E.useState)(`connecting`),i=(0,E.useRef)(null),a=(0,E.useRef)(0),o=(0,E.useRef)(null),s=(0,E.useRef)(t);s.current=t;let c=(0,E.useCallback)(()=>{let t=p(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);s.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=D.length){r(`disconnected`);return}let t=D[e];a.current+=1,o.current=setTimeout(c,t)}},[e]);return(0,E.useEffect)(()=>(c(),()=>{o.current&&clearTimeout(o.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[c]),{connectionStatus:n}}var k=n();function ae(e,t){let n=C(e),r=C(t);if(!n||!r)return`—`;let i=r.getTime()-n.getTime();if(i<0)return`—`;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}var A={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`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function j({jobId:e,onClose:t,projectId:n}){let{t:r}=a(`jobs`),p=(0,E.useCallback)(()=>n?`${f}/api/projects/${n}`:m(),[n]),[D,j]=(0,E.useState)(null),[M,N]=(0,E.useState)([]),[P,F]=(0,E.useState)([]),[I,L]=(0,E.useState)({}),[R,z]=(0,E.useState)(!0),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(!1);(0,E.useEffect)(()=>{async function t(){try{let t=await fetch(`${p()}/jobs/${e}`);if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(j(n.job),N(n.events),n.phaseDefinitions){F(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;L(e)}}catch{V(!0)}finally{z(!1)}}t()},[e,p]);let K=(0,E.useCallback)(()=>{fetch(`${p()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&j(e.job)}).catch(()=>{})},[e,p]),q=(0,E.useRef)([]),J=(0,E.useRef)(null),Y=(0,E.useCallback)(()=>{J.current=null;let e=q.current;e.length!==0&&(q.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,E.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),O(s,(0,E.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};q.current.push(t),J.current||=requestAnimationFrame(Y)}else if(n.type===`job.finalized`&&n.jobId===e||n.type===`job.interactive`&&n.jobId===e||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===e)K();else if(n.type===`phase`){let e=n.phase,t=n.state;L(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&D&&j(e=>e&&{...e,status:t.status})}},[e,D,Y,K])),(0,E.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(H){U(!1);return}t()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,H]);let X=D?S(D):`job`,Z=X===`loop-run`;async function oe(){G(!0);try{let t=await x({projectId:n??null,jobId:e,kind:X});t.ok?(o.success(r(Z?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:r(Z?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):o.error(r(`modal.toast.cancelFailed`),{description:t.error})}finally{G(!1)}}let Q=D?A[D.status]??A.queued:A.queued,se=D?.status===`running`,$=D?C(w(D)):null,{panelRef:ce,panelStyle:le,headerHandleProps:ue,resizeHandles:de,isFloating:fe,guardBackdrop:pe}=ne();return(0,T.createPortal)((0,k.jsx)(g,{delayDuration:400,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:pe(t)}),(0,k.jsxs)(`div`,{ref:ce,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:le,children:[(0,k.jsxs)(`div`,{...ue,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${fe?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y,{children:[(0,k.jsx)(_,{asChild:!0,children:(0,k.jsx)(`div`,{children:(0,k.jsx)(v,{variant:Q.variant,children:r(Q.labelKey)})})}),(0,k.jsx)(b,{children:r(Q.tooltipKey)})]}),(0,k.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:D.command}),(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:$?ie($,{addSuffix:!0,locale:i()}):`—`}),D.total_cost_usd!=null&&D.total_cost_usd>0&&(0,k.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,D.total_cost_usd.toFixed(4)]}),D.started_at&&D.finished_at&&(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ae(D.started_at,D.finished_at)})]}),R&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`common:states.loading`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[P.length>0&&(0,k.jsx)(`div`,{className:`mr-3`,children:(0,k.jsx)(c,{phases:I,phaseDefinitions:P})}),se&&(0,k.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),disabled:W,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[W&&(0,k.jsx)(ee,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),r(Z?`dashboard:railControls.stop`:X===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,k.jsx)(`button`,{onClick:t,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,k.jsx)(te,{className:`w-4 h-4`})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:B?(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`modal.notFound`)})}):D?.command.startsWith(`loop:`)?(0,k.jsx)(l,{events:M,jobStatus:D.status,isLoading:R,variant:`glass`,projectId:n}):(0,k.jsx)(u,{events:M,isLoading:R,projectId:n})}),!!D?.interactive&&D.status===`running`&&(0,k.jsx)(d,{jobId:e,projectId:n,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,k.jsx)(re,{handles:de}),H&&(0,k.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>U(!1)}),(0,k.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl glass-card border border-border/30 p-5 shadow-xl animate-in fade-in zoom-in-95 duration-150`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(Z?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,k.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:r(Z?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:r(`modal.keepRunning`)}),(0,k.jsx)(h,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),oe()},children:r(Z?`modal.stopRun`:X===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{j as JobDetailModal};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as o}from"./i18n-Bf9Ckd10.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{n as c}from"./dist-bVqfYmby.js";import{c as l,l as u}from"./MinimizedChatsContext-Cs34FPTz.js";import{t as d}from"./chevron-right-CViMxucY.js";import{i as f,n as p,r as ee,t as te}from"./InteractiveJobComposer-C9I0A4KR.js";import{o as m}from"./TicketDetailModal-CI47Dq9E.js";import{t as ne}from"./circle-x-CMYsN4ZH.js";import{t as h}from"./download-CFHyyHcw.js";import{t as g}from"./loader-circle-DcygOQpC.js";import{n as _}from"./useSharedWebSocket-DaPh7QBL.js";import{t as v}from"./api-B2M7CtDw.js";import{r as y}from"./useDesktop-B4pSBIDd.js";import{t as b}from"./button-BUIIBQPT.js";import{t as x}from"./utils-BC4DHlz2.js";import{t as re}from"./formatDistanceToNow-ByKli7Q_.js";import{C as S,Dt as C,I as w,L as T,N as E,P as D,S as O,kt as k,n as A,st as j,vt as M}from"./index-F9r8mWP_.js";import{n as N}from"./job-time-BCL7wee9.js";import{t as P}from"./format-command-Dfa1o2d-.js";var F=e(t(),1),I=n();function L(e,t){let n=N(e),r=(typeof t==`number`?t:N(t)?.getTime()??NaN)-(n?.getTime()??NaN);if(!Number.isFinite(r)||r<0)return`—`;let i=Math.round(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60),o=i%60;return a<60?`${a}m ${o}s`:`${Math.floor(a/60)}h ${a%60}m`}function R(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 z={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function B(e,t){if(t.type===`reset`)return z;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=S(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 ie({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[c,l]=(0,F.useState)(n),d=(0,F.useMemo)(()=>R(t),[t]),f=e.status===`running`,p=e.status===`completed`,[ee,te]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[m,h]=(0,F.useReducer)(B,z),_=(0,F.useRef)(e.id);(0,F.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,h({type:`reset`})),h({type:`consume`,events:t})},[e.id,t]);let[v,y]=(0,F.useState)(!0);(0,F.useEffect)(()=>{if(!f)return;y(!0);let e=window.setTimeout(()=>y(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let b=e.finished_at?L(e.started_at,e.finished_at):f?L(e.started_at,ee):`—`,re=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${re?`~`:``}$${e.total_cost_usd.toFixed(4)}`,C=e.num_turns==null?null:String(e.num_turns),w=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=w==null?null:`${(w/1e3).toFixed(1)}k`,E=(0,F.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),D=f&&m.steps===0?`connecting`:m.actionKey||`thinking`,A=O.has(D)&&m.actionArg!==``,j=O.has(D)&&!A?`working`:D,M=A?o(`statusPanel.activity.${j}`,{arg:m.actionArg}):o(`statusPanel.activity.${j}`),N=E??(f&&m.steps===0?o(`statusPanel.activity.starting`):null),P=m.steps>0?o(`statusPanel.steps`,{count:m.steps}):null,ie=o(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),W=f?`border-accent-info/20 bg-accent-info/5`:p?`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`,ae=f?g:p?k:ne,G=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`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,I.jsxs)(`div`,{className:x(`mx-4 my-2 rounded-xl border transition-colors duration-500`,W),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,I.jsx)(ae,{className:G,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:ie}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`tabular-nums`,children:b}),f?P&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:P}):(0,I.jsxs)(I.Fragment,{children:[S&&(0,I.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),d.length>0&&(0,I.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,I.jsx)(u,{className:x(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,c&&`rotate-180`)})]}),c&&(0,I.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:b})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,I.jsx)(g,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),N&&(0,I.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:N}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:M}),P&&(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,P]})]})]}),v&&(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,I.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,I.jsx)(U,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.duration`),value:b}),(0,I.jsx)(H,{label:o(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.turns`),value:C,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.tokens`),value:T,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,I.jsx)(V,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(0,I.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})})]}),d.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,I.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 V({label:e,value:t,valueClass:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function H({label:e,value:t,valueClass:n,naCaption:r}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function U({label:e,caption:t,tooltip:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,I.jsx)(C,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var W=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,F.useState)(!1);if(e.length===0)return null;let a=e.length>=W&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,I.jsx)(G,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,I.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=W&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,I.jsx)(l,{className:`w-3 h-3`})]})]})}function G({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,I.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,I.jsx)(`span`,{className:x(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,I.jsxs)(`span`,{className:x(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,I.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var oe={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 K(){let{t:e}=s(`jobs`),{id:t}=a(),{activeProjectId:n,projects:l}=y(),u=l.find(e=>e.id===n)?.provider,ne=r(),{openTicketDetail:g}=m(),[S,C]=(0,F.useState)(null),[O,k]=(0,F.useState)([]),[N,L]=(0,F.useState)([]),[R,z]=(0,F.useState)({}),[B,V]=(0,F.useState)([]),[H,U]=(0,F.useState)(!0),[W,G]=(0,F.useState)(!1),[K,se]=(0,F.useState)(!1),q=(0,F.useRef)(!1),J=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!t)return;let e=new AbortController;C(null),k([]),L([]),z({}),U(!0),G(!1);async function n(){try{let n=await fetch(`${v()}/jobs/${t}`,{signal:e.signal});if(n.status===404){G(!0);return}if(!n.ok)throw Error(`Failed to fetch job`);let r=await n.json();C(r.job),k(r.events)}catch(e){if(e.name===`AbortError`)return;G(!0)}finally{e.signal.aborted||U(!1)}}return n(),()=>e.abort()},[t,n]),(0,F.useEffect)(()=>{if(!S?.pipeline_id){V([]);return}let e=S.pipeline_id;fetch(`${v()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&V(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,F.useRef)(n);Y.current=n;let ce=(0,F.useRef)(null);ce.current=S?.status??null;let X=(0,F.useRef)([]),Z=(0,F.useRef)(null),le=(0,F.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],k(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,F.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(le)},[le]);(0,F.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let ue=(0,F.useCallback)(e=>{let n=e;if(!(Y.current&&n.projectId&&n.projectId!==Y.current)){if(n.type===`init`){let e=n.phaseDefinitions??[];L(e);let t={};for(let r of e)t[r.key]=n.phases?.[r.key]??`idle`;z(t)}else if(n.type===`event`&&n.jobId===t){let e={id:Date.now(),job_id:t??``,seq:n.seq??0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};Q(e)}else if(n.type===`log`&&n.processId===t){let e={id:Date.now(),job_id:t??``,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};Q(e)}else if(n.type===`job.finalized`&&n.jobId===t||n.type===`job.interactive`&&n.jobId===t||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===t)fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{});else if(n.type===`phase`){let e=n.phase,t=n.state;z(n=>({...n,[e]:t}))}else if(n.type===`queue`){let e=n.jobs?.find(e=>e.id===t);if(e){let n=e.status,r=ce.current;C(e=>e&&{...e,status:n}),(n===`completed`||n===`failed`||n===`canceled`||n===`running`&&r!==`running`)&&fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{})}}}},[t,Q]),{registerHandler:de,unregisterHandler:fe}=_();(0,F.useEffect)(()=>(de(`job-detail-${t}`,ue),()=>fe(`job-detail-${t}`)),[t,ue,de,fe]),(0,F.useEffect)(()=>{if(!t||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${v()}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&C(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[t,S?.status,S?.hasTelemetry]);async function pe(){if(!t)return;let n=await A({projectId:null,jobId:t});n.ok?c.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?c.error(e(`detail.toast.networkError`)):c.error(e(`detail.toast.failed`),{description:n.error})}async function me(){if(S)try{let t=await fetch(`${v()}/jobs/${S.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-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){c.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function he(){if(!(!S||q.current)){q.current=!0,se(!0),J.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${S.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${v()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":J.current},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));J.current=null,c.success(e(`detail.toast.jobRequeued`)),ne(`/jobs/${n.jobId}`)}catch(e){c.error(e.message)}finally{q.current=!1,se(!1)}}}if(H)return(0,I.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,I.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,I.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(W||!S)return(0,I.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:t})}),(0,I.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(i,{to:`/`,children:[(0,I.jsx)(M,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=oe[S.status]??oe.queued,ge=S.status===`running`,_e=S.status===`completed`||S.status===`failed`,ve=!!S.interactive,ye=ve&&ge,be=(S.tickets?.length??0)>0,xe=S.command.startsWith(`loop:`),Se=B.length>1?{totalCostUsd:B.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:B.some(e=>e.total_cost_usd==null),costEstimated:B.some(e=>!!e.total_cost_usd_estimated),nullCostCount:B.filter(e=>e.total_cost_usd==null).length,totalTokensIn:B.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:B.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:B.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:B.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:B.length}:null;return(0,I.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,I.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,I.jsx)(M,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,I.jsx)(d,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:t?.slice(0,8)})})]}),be&&(0,I.jsx)(ae,{tickets:S.tickets??[],onTicketClick:g}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(`div`,{children:(0,I.jsx)(T,{variant:$.variant,children:e($.labelKey)})})}),(0,I.jsx)(D,{children:e($.tooltipKey)})]}),(0,I.jsx)(`code`,{className:x(`font-mono text-foreground/90 truncate`,be?`text-xs text-muted-foreground`:`text-sm`),children:P(S.command,u)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,I.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:re(new Date(S.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),S.model&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,className:`h-7`,onClick:me,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,I.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,I.jsx)(D,{children:e(`detail.exportDiagnosticTooltip`)})]}),_e&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,onClick:he,disabled:K,"aria-busy":K,className:`h-7`,children:[(0,I.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,I.jsx)(D,{children:e(`detail.reExecuteTooltip`)})]}),ge&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(b,{variant:`outline`,size:`sm`,onClick:pe,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ve?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,I.jsx)(D,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,I.jsx)(f,{phases:R,phaseDefinitions:N})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,I.jsx)(ie,{job:S,events:O,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:Se??void 0,phases:R,phaseDefinitions:N}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:xe?(0,I.jsx)(p,{events:O,jobStatus:S.status,variant:`page`}):(0,I.jsx)(ee,{events:O})}),ye&&(0,I.jsx)(te,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{K as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as o}from"./i18n-Bf9Ckd10.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{n as c}from"./dist-bVqfYmby.js";import{c as l,l as u}from"./MinimizedChatsContext-Cs34FPTz.js";import{t as d}from"./chevron-right-CViMxucY.js";import{i as f,n as p,r as ee,t as te}from"./InteractiveJobComposer-qoeZjwVY.js";import{o as m}from"./TicketDetailModal-CqQ5gx7O.js";import{t as ne}from"./circle-x-CMYsN4ZH.js";import{t as h}from"./download-CFHyyHcw.js";import{t as g}from"./loader-circle-DcygOQpC.js";import{n as _}from"./useSharedWebSocket-DaPh7QBL.js";import{t as v}from"./api-B2M7CtDw.js";import{r as y}from"./useDesktop-B4pSBIDd.js";import{t as b}from"./button-BUIIBQPT.js";import{t as x}from"./utils-BC4DHlz2.js";import{t as re}from"./formatDistanceToNow-ByKli7Q_.js";import{C as S,Dt as C,I as w,L as T,N as E,P as D,S as O,kt as k,n as A,st as j,vt as M}from"./index-CewRMo0W.js";import{n as N}from"./job-time-BCL7wee9.js";import{t as P}from"./format-command-Dfa1o2d-.js";var F=e(t(),1),I=n();function L(e,t){let n=N(e),r=(typeof t==`number`?t:N(t)?.getTime()??NaN)-(n?.getTime()??NaN);if(!Number.isFinite(r)||r<0)return`—`;let i=Math.round(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60),o=i%60;return a<60?`${a}m ${o}s`:`${Math.floor(a/60)}h ${a%60}m`}function R(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 z={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function B(e,t){if(t.type===`reset`)return z;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=S(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 ie({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[c,l]=(0,F.useState)(n),d=(0,F.useMemo)(()=>R(t),[t]),f=e.status===`running`,p=e.status===`completed`,[ee,te]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[m,h]=(0,F.useReducer)(B,z),_=(0,F.useRef)(e.id);(0,F.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,h({type:`reset`})),h({type:`consume`,events:t})},[e.id,t]);let[v,y]=(0,F.useState)(!0);(0,F.useEffect)(()=>{if(!f)return;y(!0);let e=window.setTimeout(()=>y(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let b=e.finished_at?L(e.started_at,e.finished_at):f?L(e.started_at,ee):`—`,re=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${re?`~`:``}$${e.total_cost_usd.toFixed(4)}`,C=e.num_turns==null?null:String(e.num_turns),w=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=w==null?null:`${(w/1e3).toFixed(1)}k`,E=(0,F.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),D=f&&m.steps===0?`connecting`:m.actionKey||`thinking`,A=O.has(D)&&m.actionArg!==``,j=O.has(D)&&!A?`working`:D,M=A?o(`statusPanel.activity.${j}`,{arg:m.actionArg}):o(`statusPanel.activity.${j}`),N=E??(f&&m.steps===0?o(`statusPanel.activity.starting`):null),P=m.steps>0?o(`statusPanel.steps`,{count:m.steps}):null,ie=o(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),W=f?`border-accent-info/20 bg-accent-info/5`:p?`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`,ae=f?g:p?k:ne,G=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`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,I.jsxs)(`div`,{className:x(`mx-4 my-2 rounded-xl border transition-colors duration-500`,W),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,I.jsx)(ae,{className:G,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:ie}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`tabular-nums`,children:b}),f?P&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:P}):(0,I.jsxs)(I.Fragment,{children:[S&&(0,I.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),d.length>0&&(0,I.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,I.jsx)(u,{className:x(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,c&&`rotate-180`)})]}),c&&(0,I.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:b})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,I.jsx)(g,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),N&&(0,I.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:N}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:M}),P&&(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,P]})]})]}),v&&(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,I.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,I.jsx)(U,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,I.jsx)(U,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.duration`),value:b}),(0,I.jsx)(H,{label:o(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.turns`),value:C,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(H,{label:o(`statusPanel.tokens`),value:T,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(V,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,I.jsx)(V,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(0,I.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})})]}),d.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,I.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 V({label:e,value:t,valueClass:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function H({label:e,value:t,valueClass:n,naCaption:r}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:x(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function U({label:e,caption:t,tooltip:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,I.jsx)(C,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var W=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,F.useState)(!1);if(e.length===0)return null;let a=e.length>=W&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,I.jsx)(G,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,I.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=W&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,I.jsx)(l,{className:`w-3 h-3`})]})]})}function G({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,I.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,I.jsx)(`span`,{className:x(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,I.jsxs)(`span`,{className:x(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,I.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var oe={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 K(){let{t:e}=s(`jobs`),{id:t}=a(),{activeProjectId:n,projects:l}=y(),u=l.find(e=>e.id===n)?.provider,ne=r(),{openTicketDetail:g}=m(),[S,C]=(0,F.useState)(null),[O,k]=(0,F.useState)([]),[N,L]=(0,F.useState)([]),[R,z]=(0,F.useState)({}),[B,V]=(0,F.useState)([]),[H,U]=(0,F.useState)(!0),[W,G]=(0,F.useState)(!1),[K,se]=(0,F.useState)(!1),q=(0,F.useRef)(!1),J=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!t)return;let e=new AbortController;C(null),k([]),L([]),z({}),U(!0),G(!1);async function n(){try{let n=await fetch(`${v()}/jobs/${t}`,{signal:e.signal});if(n.status===404){G(!0);return}if(!n.ok)throw Error(`Failed to fetch job`);let r=await n.json();C(r.job),k(r.events)}catch(e){if(e.name===`AbortError`)return;G(!0)}finally{e.signal.aborted||U(!1)}}return n(),()=>e.abort()},[t,n]),(0,F.useEffect)(()=>{if(!S?.pipeline_id){V([]);return}let e=S.pipeline_id;fetch(`${v()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&V(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,F.useRef)(n);Y.current=n;let ce=(0,F.useRef)(null);ce.current=S?.status??null;let X=(0,F.useRef)([]),Z=(0,F.useRef)(null),le=(0,F.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],k(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,F.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(le)},[le]);(0,F.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let ue=(0,F.useCallback)(e=>{let n=e;if(!(Y.current&&n.projectId&&n.projectId!==Y.current)){if(n.type===`init`){let e=n.phaseDefinitions??[];L(e);let t={};for(let r of e)t[r.key]=n.phases?.[r.key]??`idle`;z(t)}else if(n.type===`event`&&n.jobId===t){let e={id:Date.now(),job_id:t??``,seq:n.seq??0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};Q(e)}else if(n.type===`log`&&n.processId===t){let e={id:Date.now(),job_id:t??``,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};Q(e)}else if(n.type===`job.finalized`&&n.jobId===t||n.type===`job.interactive`&&n.jobId===t||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===t)fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{});else if(n.type===`phase`){let e=n.phase,t=n.state;z(n=>({...n,[e]:t}))}else if(n.type===`queue`){let e=n.jobs?.find(e=>e.id===t);if(e){let n=e.status,r=ce.current;C(e=>e&&{...e,status:n}),(n===`completed`||n===`failed`||n===`canceled`||n===`running`&&r!==`running`)&&fetch(`${v()}/jobs/${t}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{})}}}},[t,Q]),{registerHandler:de,unregisterHandler:fe}=_();(0,F.useEffect)(()=>(de(`job-detail-${t}`,ue),()=>fe(`job-detail-${t}`)),[t,ue,de,fe]),(0,F.useEffect)(()=>{if(!t||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${v()}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&C(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[t,S?.status,S?.hasTelemetry]);async function pe(){if(!t)return;let n=await A({projectId:null,jobId:t});n.ok?c.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?c.error(e(`detail.toast.networkError`)):c.error(e(`detail.toast.failed`),{description:n.error})}async function me(){if(S)try{let t=await fetch(`${v()}/jobs/${S.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-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){c.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function he(){if(!(!S||q.current)){q.current=!0,se(!0),J.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${S.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${v()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":J.current},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));J.current=null,c.success(e(`detail.toast.jobRequeued`)),ne(`/jobs/${n.jobId}`)}catch(e){c.error(e.message)}finally{q.current=!1,se(!1)}}}if(H)return(0,I.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,I.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,I.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(W||!S)return(0,I.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:t})}),(0,I.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(i,{to:`/`,children:[(0,I.jsx)(M,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=oe[S.status]??oe.queued,ge=S.status===`running`,_e=S.status===`completed`||S.status===`failed`,ve=!!S.interactive,ye=ve&&ge,be=(S.tickets?.length??0)>0,xe=S.command.startsWith(`loop:`),Se=B.length>1?{totalCostUsd:B.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:B.some(e=>e.total_cost_usd==null),costEstimated:B.some(e=>!!e.total_cost_usd_estimated),nullCostCount:B.filter(e=>e.total_cost_usd==null).length,totalTokensIn:B.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:B.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:B.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:B.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:B.length}:null;return(0,I.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,I.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,I.jsx)(M,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,I.jsx)(d,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:t?.slice(0,8)})})]}),be&&(0,I.jsx)(ae,{tickets:S.tickets??[],onTicketClick:g}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(`div`,{children:(0,I.jsx)(T,{variant:$.variant,children:e($.labelKey)})})}),(0,I.jsx)(D,{children:e($.tooltipKey)})]}),(0,I.jsx)(`code`,{className:x(`font-mono text-foreground/90 truncate`,be?`text-xs text-muted-foreground`:`text-sm`),children:P(S.command,u)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,I.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:re(new Date(S.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),S.model&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,className:`h-7`,onClick:me,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,I.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,I.jsx)(D,{children:e(`detail.exportDiagnosticTooltip`)})]}),_e&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsxs)(b,{variant:`outline`,size:`sm`,onClick:he,disabled:K,"aria-busy":K,className:`h-7`,children:[(0,I.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,I.jsx)(D,{children:e(`detail.reExecuteTooltip`)})]}),ge&&(0,I.jsxs)(E,{children:[(0,I.jsx)(w,{asChild:!0,children:(0,I.jsx)(b,{variant:`outline`,size:`sm`,onClick:pe,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ve?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,I.jsx)(D,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,I.jsx)(f,{phases:R,phaseDefinitions:N})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,I.jsx)(ie,{job:S,events:O,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:Se??void 0,phases:R,phaseDefinitions:N}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:xe?(0,I.jsx)(p,{events:O,jobStatus:S.status,variant:`page`}):(0,I.jsx)(ee,{events:O})}),ye&&(0,I.jsx)(te,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{K as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as i}from"./i18n-Bf9Ckd10.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./circle-x-CMYsN4ZH.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{t as d}from"./x-CBMI9ejn.js";import{a as f}from"./auth-D_5bQv5W.js";import{t as p}from"./api-B2M7CtDw.js";import{i as m,r as h}from"./useDesktop-B4pSBIDd.js";import{t as g}from"./button-BUIIBQPT.js";import{a as _,c as v,i as y,n as b,o as ee,r as x,s as S,t as te}from"./dialog-CzIekCw0.js";import{n as ne,t as re}from"./lib-CGdyxIWg.js";import{t as C}from"./formatDistanceToNow-ByKli7Q_.js";import{I as w,L as ie,N as T,Ot as E,P as D,gt as O,kt as k,t as A}from"./index-F9r8mWP_.js";import{n as j,t as M}from"./job-time-BCL7wee9.js";import{t as ae}from"./format-command-Dfa1o2d-.js";import{t as N}from"./ExportDropdown-BrtfWzEG.js";var oe=o(`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`}]]),P=e(t(),1),F=n();function I(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 L(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function R(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function z({label:e,a:t,b:n,highlight:r}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function B(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}=a(`jobs`),[r,i]=(0,P.useState)(null),[o,s]=(0,P.useState)(!0),[l,u]=(0,P.useState)(null),{panelRef:f,panelStyle:m,headerHandleProps:h,resizeHandles:g,isFloating:_,guardBackdrop:y}=v();(0,P.useEffect)(()=>{let t=new AbortController;return fetch(`${p()}/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),s(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),s(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,F.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,F.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,F.jsx)(k,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,F.jsx)(c,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,F.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,F.jsxs)(`div`,{ref:f,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:m,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between ${_?`cursor-grab active:cursor-grabbing`:``}`,...h,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,F.jsx)(d,{className:`w-4 h-4`})})]}),o&&(0,F.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,F.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,F.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:l})}),r&&(()=>{let[e,t]=r.jobs,i=B(e.durationMs,t.durationMs,!0),a=B(e.totalCostUsd,t.totalCostUsd,!0),o=B(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,F.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,F.jsx)(z,{label:n(`comparison.duration`),a:I(e.durationMs),b:I(t.durationMs),highlight:i}),(0,F.jsx)(z,{label:n(`comparison.cost`),a:L(e.totalCostUsd),b:L(t.totalCostUsd),highlight:a}),(0,F.jsx)(z,{label:n(`comparison.tokensOut`),a:R(e.tokensOut),b:R(t.tokensOut),highlight:o}),(0,F.jsx)(z,{label:n(`comparison.tokensIn`),a:R(e.tokensIn),b:R(t.tokensIn),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.cacheRead`),a:R(e.tokensCacheRead),b:R(t.tokensCacheRead),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,F.jsx)(z,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,F.jsx)(S,{handles:g})]})}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`],ue={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 de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=j(e),r=j(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=j(e);return t?C(t,{addSuffix:!0,locale:i()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=j(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:o,onProposalClick:c,onProposalDelete:d}){let{t:f}=a(`jobs`),m=r(),{activeProjectId:ne,projects:re}=h(),C=re.find(e=>e.id===ne)?.provider,[k,A]=(0,P.useState)(null),[j,N]=(0,P.useState)(``),[I,L]=(0,P.useState)(``),[R,z]=(0,P.useState)(!1),[B,H]=(0,P.useState)(``),[U,W]=(0,P.useState)(``),[G,ve]=(0,P.useState)(!1),[K,q]=(0,P.useState)(null),[J,ye]=(0,P.useState)(V),[Y,be]=(0,P.useState)(!1),[X,Z]=(0,P.useState)([]),[xe,Q]=(0,P.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=v();(0,P.useEffect)(()=>{ye(V)},[e.length]);function Oe(){be(e=>!e),Z([])}function ke(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>k&&e.status!==k?!1:_e(M(e),j,I)),Ae=e.filter(e=>_e(M(e),B,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),U&&(t.to=new Date(ge(U)).toISOString()));let n=await fetch(`${p()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();s.success(f(`recent.toast.cleared`,{count:e.deleted})),z(!1),H(``),W(``),o?.()}else s.error(f(`recent.toast.clearFailed`))}catch{s.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,F.jsxs)(`div`,{role:`alert`,"data-testid":`jobs-load-error`,className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,F.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,F.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,F.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:f(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,F.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,F.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,F.jsx)(E,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${k===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,F.jsx)(`button`,{type:`button`,onClick:()=>A(k===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${k===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,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:j,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.fromDate`)}),(0,F.jsx)(`input`,{type:`date`,value:I,onChange:e=>L(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(j||I)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{N(``),L(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Oe,children:(0,F.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,F.jsx)(l,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,F.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,F.jsxs)(`span`,{children:[X.length===0&&f(`recent.selectTwoToCompare`),X.length===1&&f(`recent.selectOneMore`),X.length===2&&f(`recent.readyToCompare`)]}),X.length===2&&(0,F.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,F.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),o=a?e.id.replace(`proposal:`,``):null,s=X.includes(e.id),u=Y&&!a&&X.length===2&&!s,d=()=>{if(Y&&!a){ke(e.id);return}a&&o?c?.(o):m(`/jobs/${e.id}`)};return(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${s?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(ie,{variant:t.variant,children:f(t.labelKey)})})}),(0,F.jsx)(D,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,F.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:f(ue[e.priority].labelKey)}),e.profile_name&&(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.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,F.jsx)(D,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(O,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,F.jsxs)(D,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,F.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ae(e.command,C)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&o&&(0,F.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(),q(o)},title:f(`recent.deleteProposal`),children:(0,F.jsx)(l,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,F.jsx)(`div`,{className:`pt-1 text-center`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>ye(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:$.length-J})})}),R&&(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>z(!1)),children:[(0,F.jsxs)(`div`,{ref:Se,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Ce,children:[(0,F.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,F.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,F.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:B,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,F.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,F.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!U,onClick:()=>je(`range`),children:B||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:f(`common:actions.cancel`)})]}),(0,F.jsx)(S,{handles:Te})]}),(0,F.jsx)(te,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,F.jsxs)(b,{className:`max-w-sm`,children:[(0,F.jsxs)(_,{children:[(0,F.jsx)(ee,{children:f(`recent.deleteProposalConfirm.title`)}),(0,F.jsx)(x,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,F.jsxs)(y,{children:[(0,F.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,F.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{K&&d?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,F.jsx)(se,{jobIds:xe,onClose:()=>{Q(null),Z([]),be(!1)}})]})}var U={input:`page.proposal.status.input`,exploring:`page.proposal.status.exploring`,review:`page.proposal.status.review`,refining:`page.proposal.status.refining`,creating_issue:`page.proposal.status.creatingIssue`,created:`page.proposal.status.created`,cancelled:`page.proposal.status.cancelled`};function W(e){return`${f}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=a(`jobs`),{activeProjectId:t}=h(),{recentJobs:n}=A(t),{data:r,isFirstLoad:i,isLoading:o,error:c,refresh:l}=m({namespace:`jobs`,projectId:t,initialValue:n,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4}),{data:u,isFirstLoad:d,isLoading:f,error:v,refresh:x}=m({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),S={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},C=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,enqueued_at:e.created_at,status:S[e.status]??`queued`})),w=[...r,...C].sort((e,t)=>(j(M(t))?.getTime()??0)-(j(M(e))?.getTime()??0)),[T,E]=(0,P.useState)(null),D=(0,P.useCallback)(async e=>{try{let t=await fetch(`${p()}/propose/${e}`);if(!t.ok)return;let n=await t.json();E(n.proposal)}catch{}},[]),O=(0,P.useCallback)(async t=>{try{(await fetch(`${p()}/propose/${t}`,{method:`DELETE`})).ok&&(s.success(e(`page.proposalDeleted`)),await x())}catch{}},[x,e]);return(0,F.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,F.jsx)(N,{baseUrl:`${p()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,F.jsx)(H,{jobs:w,isLoading:i||d||o||f,error:c??v,onRetry:()=>{Promise.all([l(),x()])},onJobsCleared:l,onProposalClick:D,onProposalDelete:O}),(0,F.jsx)(te,{open:T!==null,onOpenChange:e=>!e&&E(null),children:(0,F.jsx)(b,{className:`max-w-3xl glass-card`,children:T&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(_,{children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(ee,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,F.jsx)(ie,{variant:T.status===`created`?`success`:T.status===`cancelled`?`destructive`:`secondary`,children:e(U[T.status]??`page.proposal.status.unknown`,{status:T.status})})]})}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:T.idea}),T.result_markdown?(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,F.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,F.jsx)(ne,{remarkPlugins:[re],children:T.result_markdown})})}):(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),T.issue_url&&(0,F.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,F.jsx)(`a`,{href:T.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:T.issue_url})]}),(0,F.jsxs)(y,{children:[(0,F.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{O(T.id),E(null)},children:e(`common:actions.delete`)}),(0,F.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>E(null),children:e(`common:actions.close`)})]})]})})})]})}export{G as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as i}from"./i18n-Bf9Ckd10.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./circle-x-CMYsN4ZH.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{t as d}from"./x-CBMI9ejn.js";import{a as f}from"./auth-D_5bQv5W.js";import{t as p}from"./api-B2M7CtDw.js";import{i as m,r as h}from"./useDesktop-B4pSBIDd.js";import{t as g}from"./button-BUIIBQPT.js";import{a as _,c as v,i as y,n as b,o as ee,r as x,s as S,t as te}from"./dialog-CzIekCw0.js";import{n as ne,t as re}from"./lib-CGdyxIWg.js";import{t as C}from"./formatDistanceToNow-ByKli7Q_.js";import{I as w,L as ie,N as T,Ot as E,P as D,gt as O,kt as k,t as A}from"./index-CewRMo0W.js";import{n as j,t as M}from"./job-time-BCL7wee9.js";import{t as ae}from"./format-command-Dfa1o2d-.js";import{t as N}from"./ExportDropdown-BrtfWzEG.js";var oe=o(`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`}]]),P=e(t(),1),F=n();function I(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 L(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function R(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function z({label:e,a:t,b:n,highlight:r}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,F.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function B(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}=a(`jobs`),[r,i]=(0,P.useState)(null),[o,s]=(0,P.useState)(!0),[l,u]=(0,P.useState)(null),{panelRef:f,panelStyle:m,headerHandleProps:h,resizeHandles:g,isFloating:_,guardBackdrop:y}=v();(0,P.useEffect)(()=>{let t=new AbortController;return fetch(`${p()}/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),s(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),s(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,F.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,F.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,F.jsx)(k,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,F.jsx)(c,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,F.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,F.jsxs)(`div`,{ref:f,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:m,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between ${_?`cursor-grab active:cursor-grabbing`:``}`,...h,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,F.jsx)(d,{className:`w-4 h-4`})})]}),o&&(0,F.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,F.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,F.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:l})}),r&&(()=>{let[e,t]=r.jobs,i=B(e.durationMs,t.durationMs,!0),a=B(e.totalCostUsd,t.totalCostUsd,!0),o=B(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,F.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,F.jsx)(z,{label:n(`comparison.duration`),a:I(e.durationMs),b:I(t.durationMs),highlight:i}),(0,F.jsx)(z,{label:n(`comparison.cost`),a:L(e.totalCostUsd),b:L(t.totalCostUsd),highlight:a}),(0,F.jsx)(z,{label:n(`comparison.tokensOut`),a:R(e.tokensOut),b:R(t.tokensOut),highlight:o}),(0,F.jsx)(z,{label:n(`comparison.tokensIn`),a:R(e.tokensIn),b:R(t.tokensIn),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.cacheRead`),a:R(e.tokensCacheRead),b:R(t.tokensCacheRead),highlight:null}),(0,F.jsx)(z,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,F.jsx)(z,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,F.jsx)(S,{handles:g})]})}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`],ue={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 de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=j(e),r=j(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=j(e);return t?C(t,{addSuffix:!0,locale:i()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=j(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:o,onProposalClick:c,onProposalDelete:d}){let{t:f}=a(`jobs`),m=r(),{activeProjectId:ne,projects:re}=h(),C=re.find(e=>e.id===ne)?.provider,[k,A]=(0,P.useState)(null),[j,N]=(0,P.useState)(``),[I,L]=(0,P.useState)(``),[R,z]=(0,P.useState)(!1),[B,H]=(0,P.useState)(``),[U,W]=(0,P.useState)(``),[G,ve]=(0,P.useState)(!1),[K,q]=(0,P.useState)(null),[J,ye]=(0,P.useState)(V),[Y,be]=(0,P.useState)(!1),[X,Z]=(0,P.useState)([]),[xe,Q]=(0,P.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=v();(0,P.useEffect)(()=>{ye(V)},[e.length]);function Oe(){be(e=>!e),Z([])}function ke(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>k&&e.status!==k?!1:_e(M(e),j,I)),Ae=e.filter(e=>_e(M(e),B,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),U&&(t.to=new Date(ge(U)).toISOString()));let n=await fetch(`${p()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();s.success(f(`recent.toast.cleared`,{count:e.deleted})),z(!1),H(``),W(``),o?.()}else s.error(f(`recent.toast.clearFailed`))}catch{s.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,F.jsxs)(`div`,{role:`alert`,"data-testid":`jobs-load-error`,className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,F.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,F.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,F.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:f(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,F.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,F.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,F.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,F.jsx)(E,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${k===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,F.jsx)(`button`,{type:`button`,onClick:()=>A(k===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${k===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,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:j,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.fromDate`)}),(0,F.jsx)(`input`,{type:`date`,value:I,onChange:e=>L(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(j||I)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{N(``),L(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:Oe,children:(0,F.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,F.jsx)(l,{className:`w-3.5 h-3.5`})})}),(0,F.jsx)(D,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,F.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,F.jsxs)(`span`,{children:[X.length===0&&f(`recent.selectTwoToCompare`),X.length===1&&f(`recent.selectOneMore`),X.length===2&&f(`recent.readyToCompare`)]}),X.length===2&&(0,F.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,F.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),o=a?e.id.replace(`proposal:`,``):null,s=X.includes(e.id),u=Y&&!a&&X.length===2&&!s,d=()=>{if(Y&&!a){ke(e.id);return}a&&o?c?.(o):m(`/jobs/${e.id}`)};return(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${s?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(ie,{variant:t.variant,children:f(t.labelKey)})})}),(0,F.jsx)(D,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,F.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:f(ue[e.priority].labelKey)}),e.profile_name&&(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.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,F.jsx)(D,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{asChild:!0,children:(0,F.jsx)(O,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,F.jsxs)(D,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,F.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ae(e.command,C)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,F.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,F.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,F.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&o&&(0,F.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(),q(o)},title:f(`recent.deleteProposal`),children:(0,F.jsx)(l,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,F.jsx)(`div`,{className:`pt-1 text-center`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>ye(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:$.length-J})})}),R&&(0,F.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>z(!1)),children:[(0,F.jsxs)(`div`,{ref:Se,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Ce,children:[(0,F.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,F.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,F.jsx)(g,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(`input`,{type:`date`,value:B,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,F.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,F.jsx)(g,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!U,onClick:()=>je(`range`),children:B||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,F.jsx)(g,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:f(`common:actions.cancel`)})]}),(0,F.jsx)(S,{handles:Te})]}),(0,F.jsx)(te,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,F.jsxs)(b,{className:`max-w-sm`,children:[(0,F.jsxs)(_,{children:[(0,F.jsx)(ee,{children:f(`recent.deleteProposalConfirm.title`)}),(0,F.jsx)(x,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,F.jsxs)(y,{children:[(0,F.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,F.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{K&&d?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,F.jsx)(se,{jobIds:xe,onClose:()=>{Q(null),Z([]),be(!1)}})]})}var U={input:`page.proposal.status.input`,exploring:`page.proposal.status.exploring`,review:`page.proposal.status.review`,refining:`page.proposal.status.refining`,creating_issue:`page.proposal.status.creatingIssue`,created:`page.proposal.status.created`,cancelled:`page.proposal.status.cancelled`};function W(e){return`${f}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=a(`jobs`),{activeProjectId:t}=h(),{recentJobs:n}=A(t),{data:r,isFirstLoad:i,isLoading:o,error:c,refresh:l}=m({namespace:`jobs`,projectId:t,initialValue:n,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4}),{data:u,isFirstLoad:d,isLoading:f,error:v,refresh:x}=m({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${W(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),S={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},C=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,enqueued_at:e.created_at,status:S[e.status]??`queued`})),w=[...r,...C].sort((e,t)=>(j(M(t))?.getTime()??0)-(j(M(e))?.getTime()??0)),[T,E]=(0,P.useState)(null),D=(0,P.useCallback)(async e=>{try{let t=await fetch(`${p()}/propose/${e}`);if(!t.ok)return;let n=await t.json();E(n.proposal)}catch{}},[]),O=(0,P.useCallback)(async t=>{try{(await fetch(`${p()}/propose/${t}`,{method:`DELETE`})).ok&&(s.success(e(`page.proposalDeleted`)),await x())}catch{}},[x,e]);return(0,F.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,F.jsx)(N,{baseUrl:`${p()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,F.jsx)(H,{jobs:w,isLoading:i||d||o||f,error:c??v,onRetry:()=>{Promise.all([l(),x()])},onJobsCleared:l,onProposalClick:D,onProposalDelete:O}),(0,F.jsx)(te,{open:T!==null,onOpenChange:e=>!e&&E(null),children:(0,F.jsx)(b,{className:`max-w-3xl glass-card`,children:T&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(_,{children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(ee,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,F.jsx)(ie,{variant:T.status===`created`?`success`:T.status===`cancelled`?`destructive`:`secondary`,children:e(U[T.status]??`page.proposal.status.unknown`,{status:T.status})})]})}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:T.idea}),T.result_markdown?(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,F.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,F.jsx)(ne,{remarkPlugins:[re],children:T.result_markdown})})}):(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),T.issue_url&&(0,F.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,F.jsx)(`a`,{href:T.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:T.issue_url})]}),(0,F.jsxs)(y,{children:[(0,F.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{O(T.id),E(null)},children:e(`common:actions.delete`)}),(0,F.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>E(null),children:e(`common:actions.close`)})]})]})})})]})}export{G as default};