specrails-desktop 2.43.0 → 2.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-DoEMumQS.js → ActivityFeedPage-C7XJ5-bJ.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DIh4K0gh.js → AgentBrowserCapture-C_WpXceT.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-mbq4WEoO.js → AgentModeAnalyticsPane-PEZKjyZS.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-CKh7zuA4.js → AgentModeCodePane-D_Xcq5t5.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-BDokPiLJ.js → AgentModeJobsPane-CDSkOuNP.js} +1 -1
- package/client/dist/assets/{AgentsPage-BFVAZbBj.js → AgentsPage-D577NzIM.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-3Y9LuWwz.js → AnalyticsPage-C6ZZI_zg.js} +1 -1
- package/client/dist/assets/{CodePage-C9KyuV_C.js → CodePage-B5z5oLnP.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-Bhi54bXQ.js → DesktopAnalyticsPage-D_V9RuGg.js} +1 -1
- package/client/dist/assets/{DocsDialog-Dj6mt4ga.js → DocsDialog-Beg82MEe.js} +1 -1
- package/client/dist/assets/{DocsPage-24yWglNI.js → DocsPage-BkE4m4wp.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-C1ucmxQh.js → InteractiveJobComposer-wBBBNaJn.js} +1 -1
- package/client/dist/assets/JobDetailModal-BCxue_Do.js +1 -0
- package/client/dist/assets/{JobDetailPage-BcajZyuu.js → JobDetailPage-_rIDpNfo.js} +1 -1
- package/client/dist/assets/{JobsPage-B9nTZw6e.js → JobsPage-C6xcijbs.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-Oc48iOFW.js → LoopBuilderPage-A-Mt6EjT.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-ae0Fr6SU.js → LoopPreviewModal-DqHiG4Dt.js} +1 -1
- package/client/dist/assets/{LoopsPage-CUEqzUBI.js → LoopsPage-B-ketPET.js} +1 -1
- package/client/dist/assets/{PluginsPage-C1xtARIx.js → PluginsPage-Dn2jPvJL.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-JZzrXFBN.js → ProjectSettingsDialog-CVTj4VLt.js} +1 -1
- package/client/dist/assets/{RepositoryDeliveries-CSDsiVUz.js → RepositoryDeliveries-IiQCcndQ.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-x5EfGTiL.js → ReviewPacketPage-BBd617OM.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-BSyuZxGq.js → TemplatePreviewModal-COHFkUS4.js} +1 -1
- package/client/dist/assets/{TicketDetailModalContext-DqyF0so-.js → TicketDetailModalContext-BNa1mdXq.js} +3 -3
- package/client/dist/assets/{button-DCBqEaZl.js → button-Ccc9Dc-D.js} +1 -1
- package/client/dist/assets/dialog-xXB2q5HJ.js +45 -0
- package/client/dist/assets/index-D5n_jg_I.css +2 -0
- package/client/dist/assets/index-m5pKr1T6.js +76 -0
- package/client/dist/index.html +6 -6
- package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +11 -0
- package/docs/internals/core-runtime-updates.md +7 -0
- package/docs/internals/interactive-jobs.md +53 -0
- package/package.json +1 -1
- package/server/dist/loop-executors.js +14 -1
- package/server/dist/loop-factory.js +24 -5
- package/server/dist/loop-run-manager.js +12 -0
- package/server/dist/loop-templates.js +14 -33
- package/server/dist/rails-router.js +2 -2
- package/server/dist/workspace-manager.js +54 -3
- package/client/dist/assets/JobDetailModal-DNWmgVHD.js +0 -1
- package/client/dist/assets/dialog-SRw01_QU.js +0 -45
- package/client/dist/assets/index-DwAmL7m5.css +0 -2
- package/client/dist/assets/index-EzrkUb8B.js +0 -76
package/client/dist/assets/{InteractiveJobComposer-C1ucmxQh.js → InteractiveJobComposer-wBBBNaJn.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{J as r,X as i,z as a}from"./TicketDetailModalContext-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{J as r,X as i,z as a}from"./TicketDetailModalContext-BNa1mdXq.js";import{h as o,l as s,r as c}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as l,t as u}from"./createLucideIcon-Bjbbp_KS.js";import{a as d,r as f,s as p}from"./useDesktop-RSMTyy7V.js";import{d as m,u as h}from"./MinimizedChatsContext-Deg39peL.js";import{t as g}from"./brain-DI9lHkKY.js";import{n as _}from"./file-text-BcLCfcWZ.js";import{t as v}from"./circle-x-CMYsN4ZH.js";import{t as y}from"./git-branch-BRM0F5GN.js";import{t as b}from"./loader-circle-DcygOQpC.js";import{n as x,t as S}from"./square-Ci-PFcFe.js";import{t as C}from"./search-Cq_gE3Ik.js";import{t as w}from"./triangle-alert-H9T4jAmh.js";import{t as T}from"./x-CBMI9ejn.js";import{t as E}from"./utils-BC4DHlz2.js";import{n as D,t as O}from"./lib-CGdyxIWg.js";import{t as k}from"./button-Ccc9Dc-D.js";import{Et as A,F as j,G as M,J as ee,K as N,R as P,V as F,bt as te,dt as ne,f as I,jt as L,kt as R,lt as re,p as z,q as B,rt as ie,ut as ae,z as V}from"./index-m5pKr1T6.js";import{t as oe}from"./lib-C7Mhm-gT.js";var se=u(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),ce=u(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),le=u(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),ue=u(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),de=u(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),H=n();function fe({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,H.jsx)(`div`,{className:`flex items-center`,children:t.map((n,r)=>{let i=e[n.key]??`idle`,a=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,H.jsxs)(`div`,{className:`flex items-center`,children:[(0,H.jsxs)(P,{children:[(0,H.jsx)(F,{asChild:!0,children:(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,H.jsx)(pe,{state:i}),(0,H.jsx)(`span`,{className:E(`text-xs font-medium transition-colors`,i===`running`?`text-blue-400 aurora-light:text-accent-info`:i===`done`?`text-emerald-400 aurora-light:text-accent-success`:i===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:n.label})]})}),(0,H.jsxs)(V,{side:`bottom`,className:`max-w-[200px]`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,H.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,H.jsx)(`div`,{className:E(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,a===`done`||i===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:a===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},n.key)})})}function pe({state:e}){return(0,H.jsxs)(`div`,{className:E(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 aurora-light:bg-accent-info/10 ring-1 ring-blue-400/30 aurora-light:ring-accent-info/30 animate-pulse`:e===`done`?`bg-emerald-500/10 aurora-light:bg-accent-success/10`:e===`error`?`bg-red-500/10 aurora-light:bg-destructive/10`:`bg-muted/20`),children:[e===`running`&&(0,H.jsx)(b,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,H.jsx)(L,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,H.jsx)(v,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,H.jsx)(r,{className:`w-6 h-6 text-muted-foreground/20`})]})}var U=e(t(),1);function me(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}var he=new Set;function ge({ticketId:e,onOpen:t,children:n}){let{t:r}=l(`agent`),i=r(`refs.openTicket`,{id:e});return(0,H.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:`inline cursor-pointer p-0 align-baseline text-accent-primary/90 underline decoration-accent-primary/50 decoration-dotted underline-offset-2 transition-colors hover:text-accent-primary hover:decoration-solid`,children:n})}function _e(e){if(!e.includes(`#`))return null;let t=B(e,he);return t.some(e=>e.kind===`ticket`)?t:null}function ve(e,t){let n=_e(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,H.jsx)(ge,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,H.jsx)(U.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var ye=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function be(e){return e.kind===`ticket`?{type:`link`,url:M({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function xe(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!ye.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=B(n.value,he);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(be))}else xe(n)}}function Se(){return e=>xe(e)}function Ce(e){let{activeProjectId:t}=f(),{openRef:n}=ee(),r=e??t??void 0;return(0,U.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function we(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:me(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(o.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${o.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function Te(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function Ee(e){let t=[];for(let n of e){let e=t.length>0?t[t.length-1]:null;n.type===`assistant`&&e?.type===`assistant`?e.content+=`
|
|
2
2
|
`+n.content:t.push({...n})}return t}function De(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function Oe({events:e,isLoading:t,projectId:n}){let{t:r,i18n:i}=l(`jobs`),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!0),[u,d]=(0,U.useState)(new Set),f=(0,U.useRef)(null),m=(0,U.useRef)(null),g=Ce(n),{processedLines:_,groups:v,totalLines:y}=(0,U.useMemo)(()=>{let t=Te(Ee(e.map((e,t)=>we(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:De(t),totalLines:t.length}},[e,i.language]),b=(0,U.useMemo)(()=>{if(!a)return y;let e=a.toLowerCase();return _.filter(t=>t.content.toLowerCase().includes(e)).length},[a,_,y]),x=(0,U.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,U.useEffect)(()=>{s&&x()},[e.length,s,x]);function S(){let e=m.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<50;c(t)}function w(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):y===0?(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,H.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,H.jsx)(C,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,H.jsx)(j,{placeholder:r(`logViewer.filterPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`pl-7 h-7`})]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=_.map(e=>e.content).join(`
|
|
3
3
|
`);navigator.clipboard.writeText(e).then(()=>{p.success(r(`logViewer.copySuccess`))}).catch(()=>{p.error(r(`logViewer.copyFailed`))})},children:(0,H.jsx)(R,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:b,total:y})})]}),(0,H.jsxs)(`div`,{ref:m,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:S,children:[v.map(e=>(0,H.jsx)(ke,{group:e,filter:a,collapsed:u.has(e.key),onToggle:()=>w(e.key),onOpenTicket:g},e.key)),(0,H.jsx)(`div`,{ref:f})]}),!s&&(0,H.jsxs)(k,{size:`sm`,variant:`secondary`,onClick:()=>{c(!0),x()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,H.jsx)(h,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var ke=(0,U.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:i}){let{t:a}=l(`jobs`),o=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,H.jsx)(`div`,{children:o.map((e,t)=>(0,H.jsx)(W,{line:e,even:t%2==0,onOpenTicket:i},e.id))});let s=e.header.content;return(0,H.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:E(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,H.jsx)(_,{className:E(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,H.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,H.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,H.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,H.jsx)(W,{line:e,even:t%2==0,onOpenTicket:i},e.id))})]})}),Ae=[oe],je=[O],Me=[O,Se],W=(0,U.memo)(function({line:e,even:t,onOpenTicket:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`,c=i||a||o||s,l=n!=null&&(e.type===`plain`||e.type===`log`),u=(0,U.useMemo)(()=>l&&n?ve(e.content,n):e.content,[l,n,e.content]),d=r&&n?Me:je,f=(0,U.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=N(e);return r?.kind===`ticket`?(0,H.jsx)(ge,{ticketId:r.ticketId,onOpen:n,children:t}):(0,H.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,H.jsxs)(`div`,{className:E(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!c&&(t?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/40 aurora-light:border-accent-success/40 mt-2 py-2`,i&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,a&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),r?(0,H.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
4
|
prose-p:my-1 prose-p:leading-relaxed
|
|
@@ -0,0 +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{ct as i,it as a}from"./TicketDetailModalContext-BNa1mdXq.js";import{a as o,c as s,l as c,m as l}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as u}from"./createLucideIcon-Bjbbp_KS.js";import{a as d,s as f}from"./useDesktop-RSMTyy7V.js";import{a as p,i as ee,n as m,o as h,r as g,s as _,t as te}from"./InteractiveJobComposer-wBBBNaJn.js";import{t as v}from"./loader-circle-DcygOQpC.js";import{t as y}from"./x-CBMI9ejn.js";import{M as b,N as x,j as ne}from"./dialog-xXB2q5HJ.js";import{t as re}from"./formatDistanceToNow-DSj5DprF.js";import{t as S}from"./button-Ccc9Dc-D.js";import{B as ie,I as ae,L as oe,R as se,V as ce,x as le,z as ue}from"./index-m5pKr1T6.js";import{n as C,t as de}from"./job-time-BCL7wee9.js";var fe=e(r(),1),w=e(t(),1),T=[1e3,2e3,4e3,8e3,16e3];function E(e,t){let[n,r]=(0,w.useState)(`connecting`),i=(0,w.useRef)(t);return i.current=t,(0,w.useEffect)(()=>{let t=!1,n=!1,a=null,c=0,l=null;async function u(){if(!(t||n||a)){n=!0;try{await s()}catch{}finally{n=!1}!t&&!a&&f()}}function d(){if(t)return;l!==null&&clearTimeout(l),r(`connecting`);let e=T[c++]??3e4;l=setTimeout(()=>{l=null,u()},e)}function f(){if(t||a)return;let n=o(),s;try{s=n?new WebSocket(e,[`specrails-desktop`,n]):new WebSocket(e)}catch{d();return}a=s,r(`connecting`),s.onopen=()=>{t||a!==s||(c=0,r(`connected`))},s.onmessage=e=>{if(!(t||a!==s))try{i.current(JSON.parse(e.data))}catch{}},s.onclose=()=>{t||a!==s||(a=null,d())}}let p=()=>{t||a||(l!==null&&clearTimeout(l),l=null,u())};return window.addEventListener(`online`,p),window.addEventListener(`focus`,p),f(),()=>{t=!0,window.removeEventListener(`online`,p),window.removeEventListener(`focus`,p),l!==null&&clearTimeout(l);let e=a;if(a=null,e){e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null;try{e.close()}catch{}}}},[e]),{connectionStatus:n}}var D=n();function pe(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 O={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 k({jobId:e,onClose:t,projectId:n}){let{t:r}=u(`jobs`),{t:o}=u(`narration`),s=(0,w.useCallback)(()=>n?`${c}/api/projects/${n}`:d(),[n]),[T,k]=(0,w.useState)(m),A=(0,w.useCallback)(e=>{k(e),g(e)},[]),[j,M]=(0,w.useState)(null),[N,P]=(0,w.useState)([]),[F,I]=(0,w.useState)([]),[L,R]=(0,w.useState)({}),[z,B]=(0,w.useState)(!0),[me,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(!1);(0,w.useEffect)(()=>{async function t(){try{let t=await fetch(`${s()}/jobs/${e}`);if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(M(n.job),P(n.events),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{V(!0)}finally{B(!1)}}t()},[e,s]);let K=(0,w.useCallback)(()=>{fetch(`${s()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&M(e.job)}).catch(()=>{})},[e,s]),q=(0,w.useRef)([]),J=(0,w.useRef)(null),Y=(0,w.useCallback)(()=>{J.current=null;let e=q.current;e.length!==0&&(q.current=[],P(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,w.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),E(i,(0,w.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;R(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&j&&M(e=>e&&{...e,status:t.status})}},[e,j,Y,K])),(0,w.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=j?oe(j):`job`,Z=X===`loop-run`;async function he(){G(!0);try{let t=await ae({projectId:n??null,jobId:e,kind:X});t.ok?(f.success(r(Z?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:r(Z?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):f.error(r(`modal.toast.cancelFailed`),{description:t.error})}finally{G(!1)}}let Q=j?O[j.status]??O.queued:O.queued,ge=j?.status===`running`,$=j?C(de(j)):null,{panelRef:_e,panelStyle:ve,headerHandleProps:ye,resizeHandles:be,isFloating:xe,guardBackdrop:Se}=b();return(0,fe.createPortal)((0,D.jsx)(ie,{delayDuration:400,children:(0,D.jsxs)(`div`,{style:x(),className:`fixed inset-0 z-[65] flex items-stretch justify-center p-[clamp(12px,2vmin,24px)]`,children:[(0,D.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:Se(t)}),(0,D.jsxs)(`div`,{ref:_e,className:`relative w-full min-w-0 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:ve,children:[(0,D.jsxs)(`div`,{...ye,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${xe?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[j&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(se,{children:[(0,D.jsx)(ce,{asChild:!0,children:(0,D.jsx)(`div`,{children:(0,D.jsx)(le,{variant:Q.variant,children:r(Q.labelKey)})})}),(0,D.jsx)(ue,{children:r(Q.tooltipKey)})]}),(0,D.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:j.command}),(0,D.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:$?re($,{addSuffix:!0,locale:l()}):`—`}),j.total_cost_usd!=null&&j.total_cost_usd>0&&(0,D.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,j.total_cost_usd.toFixed(4)]}),j.started_at&&j.finished_at&&(0,D.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:pe(j.started_at,j.finished_at)})]}),z&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`common:states.loading`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[F.length>0&&(0,D.jsx)(`div`,{className:`mr-3`,children:(0,D.jsx)(_,{phases:L,phaseDefinitions:F})}),ge&&(0,D.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>U(!0),disabled:W,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[W&&(0,D.jsx)(v,{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,D.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,D.jsx)(y,{className:`w-4 h-4`})})]})]}),(0,D.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:me?(0,D.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`modal.notFound`)})}):a&&j?(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/40 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>A(e),"aria-pressed":T===e,"data-testid":`modal-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${T===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface/60`}`,children:o(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,D.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:T===`narrated`?(0,D.jsx)(ee,{events:N,settled:j.status!==`running`&&j.status!==`queued`,elapsedMs:j.duration_ms??null,variant:`glass`}):j.command.startsWith(`loop:`)?(0,D.jsx)(p,{events:N,jobStatus:j.status,isLoading:z,variant:`glass`,projectId:n}):(0,D.jsx)(h,{events:N,isLoading:z,projectId:n})})]}):j?.command.startsWith(`loop:`)?(0,D.jsx)(p,{events:N,jobStatus:j.status,isLoading:z,variant:`glass`,projectId:n}):(0,D.jsx)(h,{events:N,isLoading:z,projectId:n})}),!!j?.interactive&&j.status===`running`&&(0,D.jsx)(te,{jobId:e,projectId:n,settleMode:j.interactiveSettleMode,initialAcceptingTurns:j.interactiveAcceptingTurns,kind:j.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,D.jsx)(ne,{handles:be}),H&&(0,D.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,D.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>U(!1)}),(0,D.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,D.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(Z?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,D.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:r(Z?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,D.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,D.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:r(`modal.keepRunning`)}),(0,D.jsx)(S,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),he()},children:r(Z?`modal.stopRun`:X===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{k 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{d as r,n as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{it as o,n as s}from"./TicketDetailModalContext-DqyF0so-.js";import{m as ee,r as c}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as l}from"./createLucideIcon-Bjbbp_KS.js";import{a as u,r as d,s as f}from"./useDesktop-RSMTyy7V.js";import{l as p,u as m}from"./MinimizedChatsContext-Deg39peL.js";import{n as h}from"./file-text-BcLCfcWZ.js";import{a as g,c as _,i as te,n as v,o as y,r as ne,s as b,t as re}from"./InteractiveJobComposer-C1ucmxQh.js";import{t as ie}from"./circle-x-CMYsN4ZH.js";import{t as x}from"./download-CFHyyHcw.js";import{t as S}from"./loader-circle-DcygOQpC.js";import{t as C}from"./utils-BC4DHlz2.js";import{t as ae}from"./formatDistanceToNow-DSj5DprF.js";import{t as w}from"./button-DCBqEaZl.js";import{I as T,R as E,V as D,d as O,jt as k,p as A,ut as j,x as M,xt as N,z as P}from"./index-EzrkUb8B.js";import{n as F}from"./job-time-BCL7wee9.js";import{t as oe}from"./format-command-C0D9IPmV.js";var I=e(t(),1),L=n();function R(e,t){let n=F(e),r=(typeof t==`number`?t:F(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 z(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 B={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function V(e,t){if(t.type===`reset`)return B;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=A(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 se({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=l(`jobs`),[s,ee]=(0,I.useState)(n),c=(0,I.useMemo)(()=>z(t),[t]),u=e.status===`running`,d=e.status===`completed`,[f,p]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>p(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[h,g]=(0,I.useReducer)(V,B),_=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,g({type:`reset`})),g({type:`consume`,events:t})},[e.id,t]);let[te,v]=(0,I.useState)(!0);(0,I.useEffect)(()=>{if(!u)return;v(!0);let e=window.setTimeout(()=>v(!1),8e3);return()=>window.clearTimeout(e)},[u,e.id]);let y=e.finished_at?R(e.started_at,e.finished_at):u?R(e.started_at,f):`—`,ne=!!e.total_cost_usd_estimated,b=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,re=e.num_turns==null?null:String(e.num_turns),x=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),ae=x==null?null:`${(x/1e3).toFixed(1)}k`,w=(0,I.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),T=u&&h.steps===0?`connecting`:h.actionKey||`thinking`,E=O.has(T)&&h.actionArg!==``,D=O.has(T)&&!E?`working`:T,A=E?o(`statusPanel.activity.${D}`,{arg:h.actionArg}):o(`statusPanel.activity.${D}`),j=w??(u&&h.steps===0?o(`statusPanel.activity.starting`):null),M=h.steps>0?o(`statusPanel.steps`,{count:h.steps}):null,N=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),P=u?`border-accent-info/20 bg-accent-info/5`:d?`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`,F=u?S:d?k:ie,oe=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`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,L.jsxs)(`div`,{className:C(`mx-4 my-2 rounded-xl border transition-colors duration-500`,P),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>ee(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(F,{className:oe,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:N}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:y}),u?M&&(0,L.jsx)(`span`,{className:`tabular-nums`,children:M}):(0,L.jsxs)(L.Fragment,{children:[b&&(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:b}),c.length>0&&(0,L.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:c.length})})]})]}),(0,L.jsx)(m,{className:C(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,L.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:u?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,L.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,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:y})]}),(0,L.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,L.jsx)(S,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),j&&(0,L.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:j}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:A}),M&&(0,L.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,M]})]})]}),te&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,L.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,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,L.jsx)(W,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,L.jsx)(W,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,L.jsx)(W,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,L.jsx)(H,{label:o(`statusPanel.duration`),value:y}),(0,L.jsx)(U,{label:o(`statusPanel.cost`),value:b,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,L.jsx)(U,{label:o(`statusPanel.turns`),value:re,naCaption:o(`statusPanel.notAvailable`)}),(0,L.jsx)(U,{label:o(`statusPanel.tokens`),value:ae,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(H,{label:o(`statusPanel.totalCost`),value:r.costUnavailable?`—`:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,L.jsx)(H,{label:o(`statusPanel.totalTokens`),value:r.tokensUnavailable?`—`:`${(r.nullTokenCount??0)>0?`≥`:``}${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&!r.costUnavailable&&(0,L.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})}),r.costUnavailable&&(0,L.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:o(`statusPanel.pipelineCostUnavailable`)}),(r.nullTokenCount??0)>0&&(0,L.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:o(`statusPanel.pipelineUsageTooltip`),children:r.tokensUnavailable?o(`statusPanel.pipelineUsageUnavailable`):o(`statusPanel.pipelineUsagePartial`,{count:r.nullTokenCount??0})})]}),c.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>(0,L.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 H({label:e,value:t,valueClass:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function U({label:e,value:t,valueClass:n,naCaption:r}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function W({label:e,caption:t,tooltip:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,L.jsx)(_,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var G=4;function ce({tickets:e,onTicketClick:t}){let{t:n}=l(`jobs`),[r,i]=(0,I.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,L.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,L.jsx)(le,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,L.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,L.jsx)(m,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,L.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,L.jsx)(p,{className:`w-3 h-3`})]})]})}function le({ticket:e,onClick:t}){let{t:n}=l(`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,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:C(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.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,L.jsxs)(`span`,{className:C(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,L.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var ue={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}=l(`jobs`),{t}=l(`narration`),{id:n}=r(),{activeProjectId:p,projects:m}=d(),_=m.find(e=>e.id===p)?.provider,ie=a(),{openTicketDetail:S}=s(),[O,k]=(0,I.useState)(null),[A,F]=(0,I.useState)([]),[R,z]=(0,I.useState)([]),[B,V]=(0,I.useState)({}),[H,U]=(0,I.useState)([]),[W,G]=(0,I.useState)(!0),[le,K]=(0,I.useState)(!1),[q,de]=(0,I.useState)(v),[fe,J]=(0,I.useState)(null),pe=(0,I.useCallback)(e=>{de(e),ne(e)},[]),Y=O?.command??null;(0,I.useEffect)(()=>{if(!o||q!==`narrated`||!p||!Y)return;let e=!1,t=`command=${encodeURIComponent(Y)}`;try{Promise.resolve(fetch(`${u()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||J(t?.range??null)}).catch(()=>{e||J(null)})}catch{J(null)}return()=>{e=!0}},[p,Y,q]);let[me,he]=(0,I.useState)(!1),X=(0,I.useRef)(!1),Z=(0,I.useRef)(null);(0,I.useEffect)(()=>{X.current=!1,Z.current=null,he(!1)},[n]),(0,I.useEffect)(()=>{if(!n)return;let e=new AbortController;k(null),F([]),z([]),V({}),G(!0),K(!1);async function t(){try{let t=await fetch(`${u()}/jobs/${n}`,{signal:e.signal});if(t.status===404){K(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();k(r.job),F(r.events)}catch(e){if(e.name===`AbortError`)return;K(!0)}finally{e.signal.aborted||G(!1)}}return t(),()=>e.abort()},[n,p]),(0,I.useEffect)(()=>{if(!O?.pipeline_id){U([]);return}let e=O.pipeline_id;fetch(`${u()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&U(e.jobs)}).catch(()=>{})},[O?.pipeline_id,O?.status]);let ge=(0,I.useRef)(p);ge.current=p;let _e=(0,I.useRef)(null);_e.current=O?.status??null;let Q=(0,I.useRef)([]),$=(0,I.useRef)(null),ve=(0,I.useCallback)(()=>{$.current=null;let e=Q.current;e.length!==0&&(Q.current=[],F(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),ye=(0,I.useCallback)(e=>{let t=Q.current;t.push(e),t.length>1e4&&(Q.current=t.slice(-8e3)),$.current||=requestAnimationFrame(ve)},[ve]);(0,I.useEffect)(()=>()=>{$.current&&cancelAnimationFrame($.current)},[]);let be=(0,I.useCallback)(e=>{let t=e;if(!(ge.current&&t.projectId&&t.projectId!==ge.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];z(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;V(n)}else if(t.type===`event`&&t.jobId===n){let e={id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};ye(e)}else if(t.type===`log`&&t.processId===n){let e={id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};ye(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;V(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status,r=_e.current;k(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{})}}}},[n,ye]),{registerHandler:xe,unregisterHandler:Se}=c();(0,I.useEffect)(()=>(xe(`job-detail-${n}`,be),()=>Se(`job-detail-${n}`)),[n,be,xe,Se]),(0,I.useEffect)(()=>{if(!n||!O||O.status!==`running`||O.hasTelemetry)return;let e=setInterval(()=>{fetch(`${u()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&k(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,O?.status,O?.hasTelemetry]);async function Ce(){if(!n)return;let t=await T({projectId:null,jobId:n});t.ok?f.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?f.error(e(`detail.toast.networkError`)):f.error(e(`detail.toast.failed`),{description:t.error})}async function we(){if(O)try{let t=await fetch(`${u()}/jobs/${O.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-${O.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){f.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Te(){if(!(!O||X.current)){X.current=!0,he(!0),Z.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${O.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${u()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":Z.current},body:JSON.stringify({rerunOfJobId:O.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));Z.current=null,f.success(e(`detail.toast.jobRequeued`)),ie(`/jobs/${n.jobId}`)}catch(e){f.error(e.message)}finally{X.current=!1,he(!1)}}}if(W)return(0,L.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,L.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,L.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(le||!O)return(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,L.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,L.jsx)(w,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsxs)(i,{to:`/`,children:[(0,L.jsx)(N,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Ee=ue[O.status]??ue.queued,De=O.status===`running`,Oe=O.status===`completed`||O.status===`failed`,ke=!!O.interactive,Ae=ke&&De,je=(O.tickets?.length??0)>0,Me=O.command.startsWith(`loop:`),Ne=H.length>1?{totalCostUsd:H.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:H.some(e=>e.total_cost_usd==null),costEstimated:H.some(e=>!!e.total_cost_usd_estimated),nullCostCount:H.filter(e=>e.total_cost_usd==null).length,costUnavailable:H.every(e=>e.total_cost_usd==null),totalTokensIn:H.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:H.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:H.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:H.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:H.filter(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null).length,tokensUnavailable:H.every(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null),jobCount:H.length}:null;return(0,L.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,L.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,L.jsx)(N,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,L.jsx)(h,{className:`w-3 h-3`}),(0,L.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),je&&(0,L.jsx)(ce,{tickets:O.tickets??[],onTicketClick:S}),(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(M,{variant:Ee.variant,children:e(Ee.labelKey)})})}),(0,L.jsx)(P,{children:e(Ee.tooltipKey)})]}),(0,L.jsx)(`code`,{className:C(`font-mono text-foreground/90 truncate`,je?`text-xs text-muted-foreground`:`text-sm`),children:oe(O.command,_)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,L.jsx)(`span`,{children:O.started_at?e(`detail.startedAgo`,{timeAgo:ae(new Date(O.started_at),{addSuffix:!0,locale:ee()})}):e(`detail.queuedWaiting`)}),O.model&&(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,children:O.model})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[O.hasTelemetry&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsxs)(w,{variant:`outline`,size:`sm`,className:`h-7`,onClick:we,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,L.jsx)(x,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,L.jsx)(P,{children:e(`detail.exportDiagnosticTooltip`)})]}),Oe&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:Te,disabled:me,"aria-busy":me,className:`h-7`,children:[(0,L.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,L.jsx)(P,{children:e(`detail.reExecuteTooltip`)})]}),De&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(w,{variant:`outline`,size:`sm`,onClick:Ce,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ke?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,L.jsx)(P,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,L.jsx)(b,{phases:B,phaseDefinitions:R})]}),(O.status===`running`||O.status===`completed`||O.status===`failed`)&&(0,L.jsx)(se,{job:O,events:A,defaultOpen:O.status===`completed`||O.status===`running`,pipelineTotals:Ne??void 0,phases:B,phaseDefinitions:R}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:o?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>pe(e),"aria-pressed":q===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${q===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:q===`narrated`?(0,L.jsx)(te,{events:A,settled:O.status!==`running`&&O.status!==`queued`,durationRange:fe,elapsedMs:O.duration_ms??null,variant:`page`}):Me?(0,L.jsx)(g,{events:A,jobStatus:O.status,variant:`page`}):(0,L.jsx)(y,{events:A})})]}):Me?(0,L.jsx)(g,{events:A,jobStatus:O.status,variant:`page`}):(0,L.jsx)(y,{events:A})}),Ae&&(0,L.jsx)(re,{jobId:O.id,settleMode:O.interactiveSettleMode,initialAcceptingTurns:O.interactiveAcceptingTurns,kind:O.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{d as r,n as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{it as o,n as s}from"./TicketDetailModalContext-BNa1mdXq.js";import{m as ee,r as c}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as l}from"./createLucideIcon-Bjbbp_KS.js";import{a as u,r as d,s as f}from"./useDesktop-RSMTyy7V.js";import{l as p,u as m}from"./MinimizedChatsContext-Deg39peL.js";import{n as h}from"./file-text-BcLCfcWZ.js";import{a as g,c as _,i as te,n as v,o as y,r as ne,s as b,t as re}from"./InteractiveJobComposer-wBBBNaJn.js";import{t as ie}from"./circle-x-CMYsN4ZH.js";import{t as x}from"./download-CFHyyHcw.js";import{t as S}from"./loader-circle-DcygOQpC.js";import{t as C}from"./utils-BC4DHlz2.js";import{t as ae}from"./formatDistanceToNow-DSj5DprF.js";import{t as w}from"./button-Ccc9Dc-D.js";import{I as T,R as E,V as D,d as O,jt as k,p as A,ut as j,x as M,xt as N,z as P}from"./index-m5pKr1T6.js";import{n as F}from"./job-time-BCL7wee9.js";import{t as oe}from"./format-command-C0D9IPmV.js";var I=e(t(),1),L=n();function R(e,t){let n=F(e),r=(typeof t==`number`?t:F(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 z(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 B={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function V(e,t){if(t.type===`reset`)return B;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=A(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 se({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=l(`jobs`),[s,ee]=(0,I.useState)(n),c=(0,I.useMemo)(()=>z(t),[t]),u=e.status===`running`,d=e.status===`completed`,[f,p]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>p(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[h,g]=(0,I.useReducer)(V,B),_=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,g({type:`reset`})),g({type:`consume`,events:t})},[e.id,t]);let[te,v]=(0,I.useState)(!0);(0,I.useEffect)(()=>{if(!u)return;v(!0);let e=window.setTimeout(()=>v(!1),8e3);return()=>window.clearTimeout(e)},[u,e.id]);let y=e.finished_at?R(e.started_at,e.finished_at):u?R(e.started_at,f):`—`,ne=!!e.total_cost_usd_estimated,b=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,re=e.num_turns==null?null:String(e.num_turns),x=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),ae=x==null?null:`${(x/1e3).toFixed(1)}k`,w=(0,I.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),T=u&&h.steps===0?`connecting`:h.actionKey||`thinking`,E=O.has(T)&&h.actionArg!==``,D=O.has(T)&&!E?`working`:T,A=E?o(`statusPanel.activity.${D}`,{arg:h.actionArg}):o(`statusPanel.activity.${D}`),j=w??(u&&h.steps===0?o(`statusPanel.activity.starting`):null),M=h.steps>0?o(`statusPanel.steps`,{count:h.steps}):null,N=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),P=u?`border-accent-info/20 bg-accent-info/5`:d?`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`,F=u?S:d?k:ie,oe=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`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,L.jsxs)(`div`,{className:C(`mx-4 my-2 rounded-xl border transition-colors duration-500`,P),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>ee(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(F,{className:oe,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:N}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:y}),u?M&&(0,L.jsx)(`span`,{className:`tabular-nums`,children:M}):(0,L.jsxs)(L.Fragment,{children:[b&&(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:b}),c.length>0&&(0,L.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:c.length})})]})]}),(0,L.jsx)(m,{className:C(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,L.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:u?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,L.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,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:y})]}),(0,L.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,L.jsx)(S,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),j&&(0,L.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:j}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:A}),M&&(0,L.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,M]})]})]}),te&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,L.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,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,L.jsx)(W,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,L.jsx)(W,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,L.jsx)(W,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,L.jsx)(H,{label:o(`statusPanel.duration`),value:y}),(0,L.jsx)(U,{label:o(`statusPanel.cost`),value:b,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,L.jsx)(U,{label:o(`statusPanel.turns`),value:re,naCaption:o(`statusPanel.notAvailable`)}),(0,L.jsx)(U,{label:o(`statusPanel.tokens`),value:ae,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(H,{label:o(`statusPanel.totalCost`),value:r.costUnavailable?`—`:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,L.jsx)(H,{label:o(`statusPanel.totalTokens`),value:r.tokensUnavailable?`—`:`${(r.nullTokenCount??0)>0?`≥`:``}${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&!r.costUnavailable&&(0,L.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})}),r.costUnavailable&&(0,L.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:o(`statusPanel.pipelineCostUnavailable`)}),(r.nullTokenCount??0)>0&&(0,L.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:o(`statusPanel.pipelineUsageTooltip`),children:r.tokensUnavailable?o(`statusPanel.pipelineUsageUnavailable`):o(`statusPanel.pipelineUsagePartial`,{count:r.nullTokenCount??0})})]}),c.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>(0,L.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 H({label:e,value:t,valueClass:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function U({label:e,value:t,valueClass:n,naCaption:r}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function W({label:e,caption:t,tooltip:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,L.jsx)(_,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var G=4;function ce({tickets:e,onTicketClick:t}){let{t:n}=l(`jobs`),[r,i]=(0,I.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,L.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,L.jsx)(le,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,L.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,L.jsx)(m,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,L.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,L.jsx)(p,{className:`w-3 h-3`})]})]})}function le({ticket:e,onClick:t}){let{t:n}=l(`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,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:C(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.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,L.jsxs)(`span`,{className:C(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,L.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var ue={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}=l(`jobs`),{t}=l(`narration`),{id:n}=r(),{activeProjectId:p,projects:m}=d(),_=m.find(e=>e.id===p)?.provider,ie=a(),{openTicketDetail:S}=s(),[O,k]=(0,I.useState)(null),[A,F]=(0,I.useState)([]),[R,z]=(0,I.useState)([]),[B,V]=(0,I.useState)({}),[H,U]=(0,I.useState)([]),[W,G]=(0,I.useState)(!0),[le,K]=(0,I.useState)(!1),[q,de]=(0,I.useState)(v),[fe,J]=(0,I.useState)(null),pe=(0,I.useCallback)(e=>{de(e),ne(e)},[]),Y=O?.command??null;(0,I.useEffect)(()=>{if(!o||q!==`narrated`||!p||!Y)return;let e=!1,t=`command=${encodeURIComponent(Y)}`;try{Promise.resolve(fetch(`${u()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||J(t?.range??null)}).catch(()=>{e||J(null)})}catch{J(null)}return()=>{e=!0}},[p,Y,q]);let[me,he]=(0,I.useState)(!1),X=(0,I.useRef)(!1),Z=(0,I.useRef)(null);(0,I.useEffect)(()=>{X.current=!1,Z.current=null,he(!1)},[n]),(0,I.useEffect)(()=>{if(!n)return;let e=new AbortController;k(null),F([]),z([]),V({}),G(!0),K(!1);async function t(){try{let t=await fetch(`${u()}/jobs/${n}`,{signal:e.signal});if(t.status===404){K(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();k(r.job),F(r.events)}catch(e){if(e.name===`AbortError`)return;K(!0)}finally{e.signal.aborted||G(!1)}}return t(),()=>e.abort()},[n,p]),(0,I.useEffect)(()=>{if(!O?.pipeline_id){U([]);return}let e=O.pipeline_id;fetch(`${u()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&U(e.jobs)}).catch(()=>{})},[O?.pipeline_id,O?.status]);let ge=(0,I.useRef)(p);ge.current=p;let _e=(0,I.useRef)(null);_e.current=O?.status??null;let Q=(0,I.useRef)([]),$=(0,I.useRef)(null),ve=(0,I.useCallback)(()=>{$.current=null;let e=Q.current;e.length!==0&&(Q.current=[],F(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),ye=(0,I.useCallback)(e=>{let t=Q.current;t.push(e),t.length>1e4&&(Q.current=t.slice(-8e3)),$.current||=requestAnimationFrame(ve)},[ve]);(0,I.useEffect)(()=>()=>{$.current&&cancelAnimationFrame($.current)},[]);let be=(0,I.useCallback)(e=>{let t=e;if(!(ge.current&&t.projectId&&t.projectId!==ge.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];z(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;V(n)}else if(t.type===`event`&&t.jobId===n){let e={id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};ye(e)}else if(t.type===`log`&&t.processId===n){let e={id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};ye(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;V(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status,r=_e.current;k(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>k(e.job)).catch(()=>{})}}}},[n,ye]),{registerHandler:xe,unregisterHandler:Se}=c();(0,I.useEffect)(()=>(xe(`job-detail-${n}`,be),()=>Se(`job-detail-${n}`)),[n,be,xe,Se]),(0,I.useEffect)(()=>{if(!n||!O||O.status!==`running`||O.hasTelemetry)return;let e=setInterval(()=>{fetch(`${u()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&k(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,O?.status,O?.hasTelemetry]);async function Ce(){if(!n)return;let t=await T({projectId:null,jobId:n});t.ok?f.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?f.error(e(`detail.toast.networkError`)):f.error(e(`detail.toast.failed`),{description:t.error})}async function we(){if(O)try{let t=await fetch(`${u()}/jobs/${O.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-${O.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){f.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Te(){if(!(!O||X.current)){X.current=!0,he(!0),Z.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${O.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${u()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":Z.current},body:JSON.stringify({rerunOfJobId:O.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));Z.current=null,f.success(e(`detail.toast.jobRequeued`)),ie(`/jobs/${n.jobId}`)}catch(e){f.error(e.message)}finally{X.current=!1,he(!1)}}}if(W)return(0,L.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,L.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,L.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(le||!O)return(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,L.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,L.jsx)(w,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsxs)(i,{to:`/`,children:[(0,L.jsx)(N,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Ee=ue[O.status]??ue.queued,De=O.status===`running`,Oe=O.status===`completed`||O.status===`failed`,ke=!!O.interactive,Ae=ke&&De,je=(O.tickets?.length??0)>0,Me=O.command.startsWith(`loop:`),Ne=H.length>1?{totalCostUsd:H.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:H.some(e=>e.total_cost_usd==null),costEstimated:H.some(e=>!!e.total_cost_usd_estimated),nullCostCount:H.filter(e=>e.total_cost_usd==null).length,costUnavailable:H.every(e=>e.total_cost_usd==null),totalTokensIn:H.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:H.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:H.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:H.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:H.filter(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null).length,tokensUnavailable:H.every(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null),jobCount:H.length}:null;return(0,L.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,L.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,L.jsx)(N,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,L.jsx)(h,{className:`w-3 h-3`}),(0,L.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),je&&(0,L.jsx)(ce,{tickets:O.tickets??[],onTicketClick:S}),(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(M,{variant:Ee.variant,children:e(Ee.labelKey)})})}),(0,L.jsx)(P,{children:e(Ee.tooltipKey)})]}),(0,L.jsx)(`code`,{className:C(`font-mono text-foreground/90 truncate`,je?`text-xs text-muted-foreground`:`text-sm`),children:oe(O.command,_)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,L.jsx)(`span`,{children:O.started_at?e(`detail.startedAgo`,{timeAgo:ae(new Date(O.started_at),{addSuffix:!0,locale:ee()})}):e(`detail.queuedWaiting`)}),O.model&&(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,children:O.model})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[O.hasTelemetry&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsxs)(w,{variant:`outline`,size:`sm`,className:`h-7`,onClick:we,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,L.jsx)(x,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,L.jsx)(P,{children:e(`detail.exportDiagnosticTooltip`)})]}),Oe&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:Te,disabled:me,"aria-busy":me,className:`h-7`,children:[(0,L.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,L.jsx)(P,{children:e(`detail.reExecuteTooltip`)})]}),De&&(0,L.jsxs)(E,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(w,{variant:`outline`,size:`sm`,onClick:Ce,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(ke?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,L.jsx)(P,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,L.jsx)(b,{phases:B,phaseDefinitions:R})]}),(O.status===`running`||O.status===`completed`||O.status===`failed`)&&(0,L.jsx)(se,{job:O,events:A,defaultOpen:O.status===`completed`||O.status===`running`,pipelineTotals:Ne??void 0,phases:B,phaseDefinitions:R}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:o?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>pe(e),"aria-pressed":q===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${q===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:q===`narrated`?(0,L.jsx)(te,{events:A,settled:O.status!==`running`&&O.status!==`queued`,durationRange:fe,elapsedMs:O.duration_ms??null,variant:`page`}):Me?(0,L.jsx)(g,{events:A,jobStatus:O.status,variant:`page`}):(0,L.jsx)(y,{events:A})})]}):Me?(0,L.jsx)(g,{events:A,jobStatus:O.status,variant:`page`}):(0,L.jsx)(y,{events:A})}),Ae&&(0,L.jsx)(re,{jobId:O.id,settleMode:O.interactiveSettleMode,initialAcceptingTurns:O.interactiveAcceptingTurns,kind:O.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{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{l as i,m as a}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,i as l,r as u,s as d}from"./useDesktop-RSMTyy7V.js";import{t as f}from"./circle-x-CMYsN4ZH.js";import{t as p}from"./trash-2-BOU3WdZZ.js";import{t as m}from"./triangle-alert-H9T4jAmh.js";import{t as h}from"./x-CBMI9ejn.js";import{M as g,a as _,i as v,j as y,l as b,o as x,r as ee,t as te}from"./dialog-SRw01_QU.js";import{n as ne,t as re}from"./lib-CGdyxIWg.js";import{t as S}from"./formatDistanceToNow-DSj5DprF.js";import{t as C}from"./button-DCBqEaZl.js";import{At as ie,R as w,V as T,jt as E,t as D,x as ae,yt as O,z as k}from"./index-EzrkUb8B.js";import{n as A,t as j}from"./job-time-BCL7wee9.js";import{t as oe}from"./format-command-C0D9IPmV.js";import{t as M}from"./ExportDropdown-ophapHrT.js";var se=s(`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`}]]),N=e(t(),1),P=n();function F(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 I(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function L(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R({label:e,a:t,b:n,highlight:r}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function z(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ce({jobIds:e,onClose:t}){let{t:n}=o(`jobs`),[r,i]=(0,N.useState)(null),[a,s]=(0,N.useState)(!0),[l,u]=(0,N.useState)(null),{panelRef:d,panelStyle:p,headerHandleProps:m,resizeHandles:_,isFloating:v,guardBackdrop:b}=g();(0,N.useEffect)(()=>{let t=new AbortController;return fetch(`${c()}/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 x(e,t){return(0,P.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,P.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,P.jsx)(E,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,P.jsx)(f,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,P.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:b(t),children:[(0,P.jsxs)(`div`,{ref:d,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:p,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,P.jsx)(h,{className:`w-4 h-4`})})]}),a&&(0,P.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,P.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,P.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=z(e.durationMs,t.durationMs,!0),a=z(e.totalCostUsd,t.totalCostUsd,!0),o=z(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,P.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,P.jsx)(R,{label:n(`comparison.duration`),a:F(e.durationMs),b:F(t.durationMs),highlight:i}),(0,P.jsx)(R,{label:n(`comparison.cost`),a:I(e.totalCostUsd),b:I(t.totalCostUsd),highlight:a}),(0,P.jsx)(R,{label:n(`comparison.tokensOut`),a:L(e.tokensOut),b:L(t.tokensOut),highlight:o}),(0,P.jsx)(R,{label:n(`comparison.tokensIn`),a:L(e.tokensIn),b:L(t.tokensIn),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.cacheRead`),a:L(e.tokensCacheRead),b:L(t.tokensCacheRead),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,P.jsx)(R,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,P.jsx)(y,{handles:_})]})}var le={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`}},ue=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],de={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 fe(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function pe(e,t){let n=A(e),r=A(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 me(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function he(e){let t=A(e);return t?S(t,{addSuffix:!0,locale:a()}):`—`}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function _e(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function B(e,t,n){if(!t&&!n)return!0;let r=A(e);if(!r)return!0;let i=r.getTime();return!(t&&i<ge(t)||n&&i>_e(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:s,onProposalDelete:l}){let{t:f}=o(`jobs`),h=r(),{activeProjectId:ne,projects:re}=u(),S=re.find(e=>e.id===ne)?.provider,[E,D]=(0,N.useState)(null),[A,M]=(0,N.useState)(``),[F,I]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),[z,H]=(0,N.useState)(``),[U,W]=(0,N.useState)(``),[G,ve]=(0,N.useState)(!1),[K,q]=(0,N.useState)(null),[J,ye]=(0,N.useState)(V),[Y,be]=(0,N.useState)(!1),[X,Z]=(0,N.useState)([]),[xe,Q]=(0,N.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=g();(0,N.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=>E&&e.status!==E?!1:B(j(e),A,F)),Ae=e.filter(e=>B(j(e),z,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(z&&(t.from=new Date(ge(z)).toISOString()),U&&(t.to=new Date(_e(U)).toISOString()));let n=await fetch(`${c()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();d.success(f(`recent.toast.cleared`,{count:e.deleted})),R(!1),H(``),W(``),a?.()}else d.error(f(`recent.toast.clearFailed`))}catch{d.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,P.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,P.jsx)(m,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,P.jsx)(C,{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,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,P.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,P.jsx)(ie,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,P.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${E===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),ue.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(E===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${E===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,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:A,onChange:e=>M(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,P.jsx)(`input`,{type:`date`,value:F,onChange:e=>I(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(A||F)&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{M(``),I(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(C,{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,P.jsx)(se,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(k,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),children:(0,P.jsx)(p,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(k,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,P.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,P.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,P.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,P.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,P.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=le[e.status]??le.queued,n=fe(e.total_cost_usd),r=pe(e.started_at,e.finished_at),i=me((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,c=X.includes(e.id),l=Y&&!a&&X.length===2&&!c,u=()=>{if(Y&&!a){ke(e.id);return}a&&o?s?.(o):h(`/jobs/${e.id}`)};return(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${c?`bg-accent/70 ring-1 ring-border`:l?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:u,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),u()))},children:[(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(`div`,{children:(0,P.jsx)(ae,{variant:t.variant,children:f(t.labelKey)})})}),(0,P.jsx)(k,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${de[e.priority].className}`,children:f(de[e.priority].labelKey)}),e.profile_name&&(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.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,P.jsx)(k,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(O,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,P.jsxs)(k,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,P.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:oe(e.command,S)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:he(e.started_at)}),a&&o&&(0,P.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,P.jsx)(p,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,P.jsx)(`div`,{className:`pt-1 text-center`,children:(0,P.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})})}),L&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>R(!1)),children:[(0,P.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,P.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,P.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:z,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,P.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,P.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!z&&!U,onClick:()=>je(`range`),children:z||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,P.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>R(!1),children:f(`common:actions.cancel`)})]}),(0,P.jsx)(y,{handles:Te})]}),(0,P.jsx)(te,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,P.jsxs)(ee,{className:`max-w-sm`,children:[(0,P.jsxs)(x,{children:[(0,P.jsx)(b,{children:f(`recent.deleteProposalConfirm.title`)}),(0,P.jsx)(v,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,P.jsxs)(_,{children:[(0,P.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,P.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{K&&l?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,P.jsx)(ce,{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`${i}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=o(`jobs`),{activeProjectId:t}=u(),{recentJobs:n}=D(t),{data:r,isFirstLoad:i,isLoading:a,error:s,refresh:f}=l({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:p,isFirstLoad:m,isLoading:h,error:g,refresh:v}=l({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}),y={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},S=p.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:y[e.status]??`queued`})),ie=[...r,...S].sort((e,t)=>(A(j(t))?.getTime()??0)-(A(j(e))?.getTime()??0)),[w,T]=(0,N.useState)(null),E=(0,N.useCallback)(async e=>{try{let t=await fetch(`${c()}/propose/${e}`);if(!t.ok)return;let n=await t.json();T(n.proposal)}catch{}},[]),O=(0,N.useCallback)(async t=>{try{(await fetch(`${c()}/propose/${t}`,{method:`DELETE`})).ok&&(d.success(e(`page.proposalDeleted`)),await v())}catch{}},[v,e]);return(0,P.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,P.jsx)(M,{baseUrl:`${c()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,P.jsx)(H,{jobs:ie,isLoading:i||m||a||h,error:s??g,onRetry:()=>{Promise.all([f(),v()])},onJobsCleared:f,onProposalClick:E,onProposalDelete:O}),(0,P.jsx)(te,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,P.jsx)(ee,{className:`max-w-3xl glass-card`,children:w&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(x,{children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(b,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,P.jsx)(ae,{variant:w.status===`created`?`success`:w.status===`cancelled`?`destructive`:`secondary`,children:e(U[w.status]??`page.proposal.status.unknown`,{status:w.status})})]})}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:w.idea}),w.result_markdown?(0,P.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,P.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,P.jsx)(ne,{remarkPlugins:[re],children:w.result_markdown})})}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),w.issue_url&&(0,P.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,P.jsx)(`a`,{href:w.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:w.issue_url})]}),(0,P.jsxs)(_,{children:[(0,P.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{O(w.id),T(null)},children:e(`common:actions.delete`)}),(0,P.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>T(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{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{l as i,m as a}from"./useSharedWebSocket-BOdS5_Iz.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,i as l,r as u,s as d}from"./useDesktop-RSMTyy7V.js";import{t as f}from"./circle-x-CMYsN4ZH.js";import{t as p}from"./trash-2-BOU3WdZZ.js";import{t as m}from"./triangle-alert-H9T4jAmh.js";import{t as h}from"./x-CBMI9ejn.js";import{M as g,a as _,i as v,j as y,l as b,o as x,r as ee,t as te}from"./dialog-xXB2q5HJ.js";import{n as ne,t as re}from"./lib-CGdyxIWg.js";import{t as S}from"./formatDistanceToNow-DSj5DprF.js";import{t as C}from"./button-Ccc9Dc-D.js";import{At as ie,R as w,V as T,jt as E,t as D,x as ae,yt as O,z as k}from"./index-m5pKr1T6.js";import{n as A,t as j}from"./job-time-BCL7wee9.js";import{t as oe}from"./format-command-C0D9IPmV.js";import{t as M}from"./ExportDropdown-ophapHrT.js";var se=s(`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`}]]),N=e(t(),1),P=n();function F(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 I(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function L(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R({label:e,a:t,b:n,highlight:r}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function z(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ce({jobIds:e,onClose:t}){let{t:n}=o(`jobs`),[r,i]=(0,N.useState)(null),[a,s]=(0,N.useState)(!0),[l,u]=(0,N.useState)(null),{panelRef:d,panelStyle:p,headerHandleProps:m,resizeHandles:_,isFloating:v,guardBackdrop:b}=g();(0,N.useEffect)(()=>{let t=new AbortController;return fetch(`${c()}/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 x(e,t){return(0,P.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,P.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,P.jsx)(E,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,P.jsx)(f,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,P.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:b(t),children:[(0,P.jsxs)(`div`,{ref:d,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:p,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,P.jsx)(h,{className:`w-4 h-4`})})]}),a&&(0,P.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,P.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,P.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=z(e.durationMs,t.durationMs,!0),a=z(e.totalCostUsd,t.totalCostUsd,!0),o=z(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,P.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,P.jsx)(R,{label:n(`comparison.duration`),a:F(e.durationMs),b:F(t.durationMs),highlight:i}),(0,P.jsx)(R,{label:n(`comparison.cost`),a:I(e.totalCostUsd),b:I(t.totalCostUsd),highlight:a}),(0,P.jsx)(R,{label:n(`comparison.tokensOut`),a:L(e.tokensOut),b:L(t.tokensOut),highlight:o}),(0,P.jsx)(R,{label:n(`comparison.tokensIn`),a:L(e.tokensIn),b:L(t.tokensIn),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.cacheRead`),a:L(e.tokensCacheRead),b:L(t.tokensCacheRead),highlight:null}),(0,P.jsx)(R,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,P.jsx)(R,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,P.jsx)(y,{handles:_})]})}var le={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`}},ue=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],de={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 fe(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function pe(e,t){let n=A(e),r=A(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 me(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function he(e){let t=A(e);return t?S(t,{addSuffix:!0,locale:a()}):`—`}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function _e(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function B(e,t,n){if(!t&&!n)return!0;let r=A(e);if(!r)return!0;let i=r.getTime();return!(t&&i<ge(t)||n&&i>_e(n))}var V=10;function H({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:s,onProposalDelete:l}){let{t:f}=o(`jobs`),h=r(),{activeProjectId:ne,projects:re}=u(),S=re.find(e=>e.id===ne)?.provider,[E,D]=(0,N.useState)(null),[A,M]=(0,N.useState)(``),[F,I]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),[z,H]=(0,N.useState)(``),[U,W]=(0,N.useState)(``),[G,ve]=(0,N.useState)(!1),[K,q]=(0,N.useState)(null),[J,ye]=(0,N.useState)(V),[Y,be]=(0,N.useState)(!1),[X,Z]=(0,N.useState)([]),[xe,Q]=(0,N.useState)(null),{panelRef:Se,panelStyle:Ce,headerHandleProps:we,resizeHandles:Te,isFloating:Ee,guardBackdrop:De}=g();(0,N.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=>E&&e.status!==E?!1:B(j(e),A,F)),Ae=e.filter(e=>B(j(e),z,U)).length;async function je(e){ve(!0);try{let t={};e===`range`&&(z&&(t.from=new Date(ge(z)).toISOString()),U&&(t.to=new Date(_e(U)).toISOString()));let n=await fetch(`${c()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();d.success(f(`recent.toast.cleared`,{count:e.deleted})),R(!1),H(``),W(``),a?.()}else d.error(f(`recent.toast.clearFailed`))}catch{d.error(f(`recent.toast.networkError`))}finally{ve(!1)}}let Me=n?(0,P.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,P.jsx)(m,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{className:`flex-1`,children:f(`recent.loadFailed`)}),i&&(0,P.jsx)(C,{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,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,P.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,P.jsx)(ie,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:f(`recent.emptyTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:f(`recent.emptyDescription`)})]}):(0,P.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${E===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:f(`recent.filterAll`,{count:e.length})}),ue.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(E===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${E===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,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:A,onChange:e=>M(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.fromDate`)}),(0,P.jsx)(`input`,{type:`date`,value:F,onChange:e=>I(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:f(`recent.toDate`)}),(A||F)&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{M(``),I(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:f(`recent.clear`)}),(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(C,{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,P.jsx)(se,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(k,{children:f(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),children:(0,P.jsx)(p,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(k,{children:f(`recent.clearJobs`)})]})]})]}),Y&&(0,P.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,P.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,P.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:f(`recent.compareAction`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,P.jsx)(`span`,{className:`w-14`,children:f(`recent.colStatus`)}),(0,P.jsx)(`span`,{className:`flex-1 min-w-0`,children:f(`recent.colCommand`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:f(`recent.colDuration`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colTokens`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:f(`recent.colCost`)}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:f(`recent.colStarted`)})]})]}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let t=le[e.status]??le.queued,n=fe(e.total_cost_usd),r=pe(e.started_at,e.finished_at),i=me((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,c=X.includes(e.id),l=Y&&!a&&X.length===2&&!c,u=()=>{if(Y&&!a){ke(e.id);return}a&&o?s?.(o):h(`/jobs/${e.id}`)};return(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${c?`bg-accent/70 ring-1 ring-border`:l?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:u,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),u()))},children:[(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(`div`,{children:(0,P.jsx)(ae,{variant:t.variant,children:f(t.labelKey)})})}),(0,P.jsx)(k,{children:f(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${de[e.priority].className}`,children:f(de[e.priority].labelKey)}),e.profile_name&&(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.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,P.jsx)(k,{children:f(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,P.jsxs)(w,{children:[(0,P.jsx)(T,{asChild:!0,children:(0,P.jsx)(O,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,P.jsxs)(k,{children:[f(`recent.pipelinePart`),e.depends_on_job_id&&` ${f(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,P.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:oe(e.command,S)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:he(e.started_at)}),a&&o&&(0,P.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,P.jsx)(p,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,P.jsx)(`div`,{className:`pt-1 text-center`,children:(0,P.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})})}),L&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:De(()=>R(!1)),children:[(0,P.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,P.jsxs)(`div`,{...we,className:Ee?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:f(`recent.clearModal.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:f(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,P.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:f(`recent.clearModal.clearAll`,{count:e.length})}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f(`recent.clearModal.orByRange`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:z,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,P.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,P.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!z&&!U,onClick:()=>je(`range`),children:z||U?f(`recent.clearModal.clearInRange`,{count:Ae}):f(`recent.clearModal.clearRange`)})]}),(0,P.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>R(!1),children:f(`common:actions.cancel`)})]}),(0,P.jsx)(y,{handles:Te})]}),(0,P.jsx)(te,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,P.jsxs)(ee,{className:`max-w-sm`,children:[(0,P.jsxs)(x,{children:[(0,P.jsx)(b,{children:f(`recent.deleteProposalConfirm.title`)}),(0,P.jsx)(v,{children:f(`recent.deleteProposalConfirm.description`)})]}),(0,P.jsxs)(_,{children:[(0,P.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:f(`common:actions.cancel`)}),(0,P.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{K&&l?.(K),q(null)},children:f(`common:actions.delete`)})]})]})}),xe&&(0,P.jsx)(ce,{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`${i}/api/projects/${encodeURIComponent(e)}`}function G(){let{t:e}=o(`jobs`),{activeProjectId:t}=u(),{recentJobs:n}=D(t),{data:r,isFirstLoad:i,isLoading:a,error:s,refresh:f}=l({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:p,isFirstLoad:m,isLoading:h,error:g,refresh:v}=l({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}),y={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},S=p.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:y[e.status]??`queued`})),ie=[...r,...S].sort((e,t)=>(A(j(t))?.getTime()??0)-(A(j(e))?.getTime()??0)),[w,T]=(0,N.useState)(null),E=(0,N.useCallback)(async e=>{try{let t=await fetch(`${c()}/propose/${e}`);if(!t.ok)return;let n=await t.json();T(n.proposal)}catch{}},[]),O=(0,N.useCallback)(async t=>{try{(await fetch(`${c()}/propose/${t}`,{method:`DELETE`})).ok&&(d.success(e(`page.proposalDeleted`)),await v())}catch{}},[v,e]);return(0,P.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,P.jsx)(M,{baseUrl:`${c()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,P.jsx)(H,{jobs:ie,isLoading:i||m||a||h,error:s??g,onRetry:()=>{Promise.all([f(),v()])},onJobsCleared:f,onProposalClick:E,onProposalDelete:O}),(0,P.jsx)(te,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,P.jsx)(ee,{className:`max-w-3xl glass-card`,children:w&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(x,{children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(b,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,P.jsx)(ae,{variant:w.status===`created`?`success`:w.status===`cancelled`?`destructive`:`secondary`,children:e(U[w.status]??`page.proposal.status.unknown`,{status:w.status})})]})}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:w.idea}),w.result_markdown?(0,P.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,P.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,P.jsx)(ne,{remarkPlugins:[re],children:w.result_markdown})})}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),w.issue_url&&(0,P.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,P.jsx)(`a`,{href:w.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:w.issue_url})]}),(0,P.jsxs)(_,{children:[(0,P.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{O(w.id),T(null)},children:e(`common:actions.delete`)}),(0,P.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>T(null),children:e(`common:actions.close`)})]})]})})})]})}export{G as default};
|