specrails-desktop 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/client/dist/assets/{ActivityFeedPage-CzMoyXH1.js → ActivityFeedPage-BpjXuX2H.js} +1 -1
  2. package/client/dist/assets/{AgentsPage-ClIs2Gio.js → AgentsPage-D-7fDbTc.js} +1 -1
  3. package/client/dist/assets/{AnalyticsPage-1oKv_dqQ.js → AnalyticsPage-BD0paa75.js} +1 -1
  4. package/client/dist/assets/{BarChart-Cx2nKLkI.js → BarChart-D8ZZRab3.js} +1 -1
  5. package/client/dist/assets/{CodePage-sMBftx0a.js → CodePage-B6q6CiYJ.js} +1 -1
  6. package/client/dist/assets/{DesktopAnalyticsPage-zeI2hEc4.js → DesktopAnalyticsPage-mwd8460_.js} +1 -1
  7. package/client/dist/assets/{DocsDialog-DZAg7yxC.js → DocsDialog-D_dyF2h9.js} +1 -1
  8. package/client/dist/assets/{DocsPage-Bv5oHAxO.js → DocsPage-C9-Ru8wE.js} +1 -1
  9. package/client/dist/assets/{ExportDropdown-lHMFeaal.js → ExportDropdown-CLYmQhic.js} +1 -1
  10. package/client/dist/assets/{IntegrationsPage-WQ2Tzm5R.js → IntegrationsPage-3WWtx9hi.js} +1 -1
  11. package/client/dist/assets/JobDetailPage-DgN-79s-.js +16 -0
  12. package/client/dist/assets/{JobsPage-CF03VyL2.js → JobsPage-Du8_w1ob.js} +1 -1
  13. package/client/dist/assets/{dist-js-DAazzqbg.js → dist-js-BOu_cXw3.js} +1 -1
  14. package/client/dist/assets/{dist-js-DM8sRRAb.js → dist-js-D3MxtOYa.js} +1 -1
  15. package/client/dist/assets/index-D17R4Cjc.css +2 -0
  16. package/client/dist/assets/{index-D_VMXR78.js → index-D9G_K4L-.js} +9 -9
  17. package/client/dist/assets/jobs-2N3RXDAM.js +1 -0
  18. package/client/dist/assets/jobs-2f6Hdc72.js +1 -0
  19. package/client/dist/assets/jobs-3j3_npyo.js +1 -0
  20. package/client/dist/assets/jobs-BqEbCCxD.js +1 -0
  21. package/client/dist/assets/jobs-DPPT6bV6.js +1 -0
  22. package/client/dist/assets/jobs-DRzjWI9u.js +1 -0
  23. package/client/dist/assets/jobs-cHYInoau.js +1 -0
  24. package/client/dist/assets/jobs-vGfzIDQa.js +1 -0
  25. package/client/dist/assets/{lib-pFaBHHQU.js → lib-DQ2hrj8m.js} +1 -1
  26. package/client/dist/assets/{useProjectCache-CqO7QEtg.js → useProjectCache-BxY4aTjd.js} +1 -1
  27. package/client/dist/index.html +3 -3
  28. package/package.json +1 -1
  29. package/server/dist/chat-manager.js +4 -0
  30. package/server/dist/project-router.js +10 -3
  31. package/server/dist/providers/claude-adapter.js +35 -17
  32. package/client/dist/assets/JobDetailPage-D59Uhx1u.js +0 -16
  33. package/client/dist/assets/index-CimDRRi7.css +0 -2
  34. package/client/dist/assets/jobs-BE1siB0M.js +0 -1
  35. package/client/dist/assets/jobs-BHcQ_Faf.js +0 -1
  36. package/client/dist/assets/jobs-CFfc2dNX.js +0 -1
  37. package/client/dist/assets/jobs-CSi5n8X_.js +0 -1
  38. package/client/dist/assets/jobs-Dc3X86PY.js +0 -1
  39. package/client/dist/assets/jobs-De5tASex.js +0 -1
  40. package/client/dist/assets/jobs-DsoXEdo7.js +0 -1
  41. package/client/dist/assets/jobs-Wl-ApPMb.js +0 -1
@@ -1,16 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{A as t,B as n,K as r,Kt as i,L as a,Mt as o,Nt as s,O as c,Qt as l,St as u,Xt as d,Zt as f,_ as p,a as m,at as h,bt as g,c as _,ct as v,d as y,f as b,it as x,jt as S,k as C,l as w,lt as T,nt as E,ot as D,qt as O,tn as k,tt as A,ut as j,v as M,vt as N,xt as ee,y as P}from"./index-D_VMXR78.js";import{t as F}from"./lib-pFaBHHQU.js";import{t as te}from"./format-command-CwGuwzGA.js";var ne=N(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),I=e(k(),1),L=o();function re({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,L.jsx)(`div`,{className:`flex items-center`,children:n.map((r,i)=>{let a=e[r.key]??`idle`,o=i<n.length-1?e[n[i+1].key]??`idle`:null;return(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,L.jsx)(R,{state:a}),(0,L.jsx)(`span`,{className:t(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:r.label})]})}),(0,L.jsxs)(M,{side:`bottom`,className:`max-w-[200px]`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,L.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),o!==null&&(0,L.jsx)(`div`,{className:t(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},r.key)})})}function R({state:e}){return(0,L.jsxs)(`div`,{className:t(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,L.jsx)(r,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,L.jsx)(D,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,L.jsx)(h,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,L.jsx)(x,{className:`w-6 h-6 text-muted-foreground/20`})]})}function z(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function B(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 V={turns:0,tokens:0,lastSeenIdx:0};function H(e,t){if(t.type===`reset`)return V;if(t.type===`consume`){let{events:n}=t;if(n.length<=e.lastSeenIdx)return e;let{turns:r,tokens:i}=e;for(let t=e.lastSeenIdx;t<n.length;t++){let e=n[t];if(e.event_type===`assistant`){r+=1;try{let t=JSON.parse(e.payload)?.message?.usage,n=e=>typeof e==`number`?e:0;i+=n(t?.input_tokens)+n(t?.output_tokens)+n(t?.cache_read_input_tokens)+n(t?.cache_creation_input_tokens)}catch{}}}return{turns:r,tokens:i,lastSeenIdx:n.length}}return e}var U=new Set([`completed`,`failed`,`canceled`,`zombie_terminated`,`skipped`]);function ie({job:e,events:n,defaultOpen:i=!0,pipelineTotals:a}){let{t:o}=O(`jobs`),[s,c]=(0,I.useState)(i),l=(0,I.useMemo)(()=>B(n),[n]),u=e.status===`running`,d=e.status===`completed`,f=U.has(e.status),[p,m]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[g,_]=(0,I.useReducer)(H,V),v=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:n})},[e.id,n]);let y=e.num_turns??(f?null:g.turns),b=e.tokens_in==null?f?null:g.tokens:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),x=e.tokens_in==null&&!f&&b!=null,S=e.num_turns==null&&!f&&y!=null,C=e.finished_at?z(e.started_at,e.finished_at):u?z(e.started_at,p):`—`,w=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),T=u?`border-accent-info/20 bg-accent-info/5`:d?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`,E=u?r:d?D:h,k=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`w-4 h-4 text-emerald-400 shrink-0`:`w-4 h-4 text-red-400 shrink-0`,A=!!e.total_cost_usd_estimated,M=e.total_cost_usd==null?`—`:`${A?`~`:``}$${e.total_cost_usd.toFixed(4)}`,N=e.total_cost_usd==null;return(0,L.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border`,T),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(E,{className:k,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:w}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:C}),N?(0,L.jsx)(`span`,{className:`tabular-nums`,children:`—`}):(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400`,children:M}),l.length>0&&(0,L.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:l.length})})]}),(0,L.jsx)(j,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,L.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,L.jsx)(W,{label:o(`statusPanel.duration`),value:C}),(0,L.jsx)(W,{label:o(`statusPanel.cost`),value:M,valueClass:N?`text-muted-foreground`:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.turns`),value:y==null?`—`:`${S?`~`:``}${y}`}),(0,L.jsx)(W,{label:o(`statusPanel.tokens`),value:b==null?`—`:`${x?`~`:``}${(b/1e3).toFixed(1)}k`})]}),a&&(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:a.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(W,{label:o(`statusPanel.totalCost`),value:`$${a.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,L.jsx)(W,{label:o(`statusPanel.totalTokens`),value:`${((a.totalTokensIn+a.totalTokensOut+a.totalTokensCacheRead+a.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),l.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:l.map(e=>(0,L.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})]})}function W({label:e,value:n,valueClass: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:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}var G=4;function ae({tickets:e,onTicketClick:t}){let{t:n}=O(`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)(K,{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)(j,{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)(v,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:n}){let{t:r}=O(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:t(a,`text-muted-foreground bg-muted/20 select-none`),title:r(`ticketHeader.deletedTooltip`),children:r(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,L.jsxs)(`span`,{className:t(a,`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})]})}function q(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function J(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}:q(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(u.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${u.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function Y(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 X(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}){let{t:n,i18n:r}=O(`jobs`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(!0),[u,d]=(0,I.useState)(new Set),f=(0,I.useRef)(null),p=(0,I.useRef)(null),{processedLines:h,groups:g,totalLines:_}=(0,I.useMemo)(()=>{let t=e.map((e,t)=>J(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
2
- `+e.content:n.push({...e})}let r=Y(n);return{processedLines:r,groups:X(r),totalLines:r.length}},[e,r.language]),v=(0,I.useMemo)(()=>{if(!o)return _;let e=o.toLowerCase();return h.filter(t=>t.content.toLowerCase().includes(e)).length},[o,h,_]),y=(0,I.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,I.useEffect)(()=>{c&&y()},[e.length,c,y]);function b(){let e=p.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function x(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.loading`)})}):_===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.empty`)})}):(0,L.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,L.jsx)(a,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,L.jsx)(m,{placeholder:n(`logViewer.filterPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`pl-7 h-7`})]}),(0,L.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=h.map(e=>e.content).join(`
3
- `);navigator.clipboard.writeText(e).then(()=>{i.success(n(`logViewer.copySuccess`))}).catch(()=>{i.error(n(`logViewer.copyFailed`))})},children:(0,L.jsx)(E,{className:`w-3.5 h-3.5`})}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`logViewer.lineCount`,{filtered:v,total:_})})]}),(0,L.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:b,children:[g.map(e=>(0,L.jsx)(Z,{group:e,filter:o,collapsed:u.has(e.key),onToggle:()=>x(e.key)},e.key)),(0,L.jsx)(`div`,{ref:f})]}),!c&&(0,L.jsxs)(C,{size:`sm`,variant:`secondary`,onClick:()=>{l(!0),y()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,L.jsx)(j,{className:`w-3 h-3`}),n(`logViewer.jumpToBottom`)]})]})}var Z=(0,I.memo)(function({group:e,filter:n,collapsed:r,onToggle:i}){let{t:a}=O(`jobs`),o=n?e.lines.filter(e=>e.content.toLowerCase().includes(n.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,L.jsx)(`div`,{children:o.map((e,t)=>(0,L.jsx)($,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,L.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:i,className:t(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,L.jsx)(T,{className:t(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!r&&`rotate-90`)}),(0,L.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,L.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,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!r&&(0,L.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,L.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(n?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,L.jsx)($,{line:e,even:t%2==0},e.id))})]})}),Q=[F],$=(0,I.memo)(function({line:e,even:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`;return(0,L.jsxs)(`div`,{className:t(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(i||a||o||s)&&(n?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 border-l-2 border-emerald-500/40 mt-2 py-2`,i&&`bg-emerald-500/8 border-l-2 border-emerald-500/50`,a&&`bg-red-500/8 border-l-2 border-red-500/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,L.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,L.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
4
- prose-p:my-1 prose-p:leading-relaxed
5
- prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
6
- prose-ul:my-1 prose-ol:my-1 prose-li:my-0
7
- prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
8
- prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
9
- prose-strong:text-foreground prose-em:text-foreground/70
10
- prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
11
- prose-table:my-2 prose-table:text-[11px]
12
- prose-thead:border-border prose-thead:bg-muted/30
13
- prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
14
- prose-td:px-3 prose-td:py-1.5 prose-td:border-border
15
- prose-tr:border-border
16
- text-foreground/80`,children:(0,L.jsx)(b,{remarkPlugins:[y],rehypePlugins:Q,children:e.content})}):(0,L.jsx)(`span`,{className:t(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 text-[11px]`,e.type===`stderr`&&`text-orange-400`,e.type===`result`&&`text-emerald-400 font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,i&&`text-emerald-400`,a&&`text-red-400`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:e.content})]})}),se={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 ce(){let{t:e}=O(`jobs`),{id:r}=l(),{activeProjectId:a,projects:o}=g(),u=o.find(e=>e.id===a)?.provider,m=f(),{openTicketDetail:h}=_(),[v,y]=(0,I.useState)(null),[b,x]=(0,I.useState)([]),[E,D]=(0,I.useState)([]),[k,j]=(0,I.useState)({}),[N,F]=(0,I.useState)([]),[R,z]=(0,I.useState)(!0),[B,V]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!r)return;let e=new AbortController;y(null),x([]),D([]),j({}),z(!0),V(!1);async function t(){try{let t=await fetch(`${s()}/jobs/${r}`,{signal:e.signal});if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();y(n.job),x(n.events)}catch(e){if(e.name===`AbortError`)return;V(!0)}finally{e.signal.aborted||z(!1)}}return t(),()=>e.abort()},[r,a]),(0,I.useEffect)(()=>{if(!v?.pipeline_id){F([]);return}let e=v.pipeline_id;fetch(`${s()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&F(e.jobs)}).catch(()=>{})},[v?.pipeline_id,v?.status]);let H=(0,I.useRef)(a);H.current=a;let U=(0,I.useRef)([]),W=(0,I.useRef)(null),G=(0,I.useCallback)(()=>{W.current=null;let e=U.current;e.length!==0&&(U.current=[],x(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,I.useEffect)(()=>()=>{W.current&&cancelAnimationFrame(W.current)},[]);let K=(0,I.useCallback)(e=>{let t=e;if(!(H.current&&t.projectId&&t.projectId!==H.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];D(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;j(n)}else if(t.type===`log`&&t.processId===r){let e={id:Date.now(),job_id:r??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};U.current.push(e),W.current||=requestAnimationFrame(G)}else if(t.type===`phase`){let e=t.phase,n=t.state;j(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===r);if(e){let t=e.status;y(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${s()}/jobs/${r}`).then(e=>e.json()).then(e=>y(e.job)).catch(()=>{})}}}},[r,G]),{registerHandler:q,unregisterHandler:J}=S();(0,I.useEffect)(()=>(q(`job-detail-${r}`,K),()=>J(`job-detail-${r}`)),[r,K,q,J]),(0,I.useEffect)(()=>{if(!r||!v||v.status!==`running`||v.hasTelemetry)return;let e=setInterval(()=>{fetch(`${s()}/jobs/${r}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&y(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[r,v?.status,v?.hasTelemetry]);async function Y(){if(r)try{let t=await fetch(`${s()}/jobs/${r}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(i.success(e(`detail.toast.jobDeleted`)),m(`/jobs`)):i.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();i.error(e(`detail.toast.failed`),{description:n.error})}}catch{i.error(e(`detail.toast.networkError`))}}async function X(){if(v)try{let t=await fetch(`${s()}/jobs/${v.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${v.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){i.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Z(){if(v)try{let t=await fetch(`${s()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:v.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));i.success(e(`detail.toast.jobRequeued`)),m(`/jobs/${n.jobId}`)}catch(e){i.error(e.message)}}if(R)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(B||!v)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:r})}),(0,L.jsx)(C,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsxs)(d,{to:`/`,children:[(0,L.jsx)(ne,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Q=se[v.status]??se.queued,$=v.status===`running`,ce=v.status===`completed`||v.status===`failed`,le=(v.tickets?.length??0)>0,ue=N.length>1?{totalCostUsd:N.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:N.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:N.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:N.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:N.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:N.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)(d,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,L.jsx)(ne,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,L.jsx)(T,{className:`w-3 h-3`}),(0,L.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:r?.slice(0,8)})})]}),le&&(0,L.jsx)(ae,{tickets:v.tickets??[],onTicketClick:h}),(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)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(c,{variant:Q.variant,children:e(Q.labelKey)})})}),(0,L.jsx)(M,{children:e(Q.tooltipKey)})]}),(0,L.jsx)(`code`,{className:t(`font-mono text-foreground/90 truncate`,le?`text-xs text-muted-foreground`:`text-sm`),children:te(v.command,u)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,L.jsx)(`span`,{children:v.started_at?e(`detail.startedAgo`,{timeAgo:w(new Date(v.started_at),{addSuffix:!0,locale:ee()})}):e(`detail.queuedWaiting`)}),v.model&&(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,children:v.model})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[v.hasTelemetry&&(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsxs)(C,{variant:`outline`,size:`sm`,className:`h-7`,onClick:X,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,L.jsx)(A,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,L.jsx)(M,{children:e(`detail.exportDiagnosticTooltip`)})]}),ce&&(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsxs)(C,{variant:`outline`,size:`sm`,onClick:Z,className:`h-7`,children:[(0,L.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,L.jsx)(M,{children:e(`detail.reExecuteTooltip`)})]}),$&&(0,L.jsxs)(p,{children:[(0,L.jsx)(P,{asChild:!0,children:(0,L.jsx)(C,{variant:`outline`,size:`sm`,onClick:Y,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(`detail.cancelJob`)})}),(0,L.jsx)(M,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,L.jsx)(re,{phases:k,phaseDefinitions:E})]}),(v.status===`running`||v.status===`completed`||v.status===`failed`)&&(0,L.jsx)(ie,{job:v,events:b,defaultOpen:v.status===`completed`||v.status===`running`,pipelineTotals:ue??void 0}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,L.jsx)(oe,{events:b})})]})}export{ce as default};