specrails-desktop 2.64.0 → 2.64.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 (30) hide show
  1. package/client/dist/assets/{ActivityFeedPage-D23wXKgy.js → ActivityFeedPage-Dtp7EyHc.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-DQzS4XcK.js → AgentBrowserCapture-CLqlEFw8.js} +1 -1
  3. package/client/dist/assets/{AgentModeAnalyticsPane-CFTiSl8T.js → AgentModeAnalyticsPane-B8_hM3Tw.js} +2 -2
  4. package/client/dist/assets/{AgentModeCodePane-DAaSzIPA.js → AgentModeCodePane-CNF8ZNjE.js} +2 -2
  5. package/client/dist/assets/{AgentModeJobsPane-C29YpixV.js → AgentModeJobsPane-CJpJbO9m.js} +1 -1
  6. package/client/dist/assets/AgentsPage-BC8XSR79.js +120 -0
  7. package/client/dist/assets/{AnalyticsPage-81fI80nA.js → AnalyticsPage-Cdv4jLtW.js} +1 -1
  8. package/client/dist/assets/{CodePage-Ct4XEPdx.js → CodePage-DI1kegAr.js} +1 -1
  9. package/client/dist/assets/{DesktopAnalyticsPage-Bt37XOLF.js → DesktopAnalyticsPage-Bdp8E8U6.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-_IEr8umI.js → DocsDialog-Bm4RS7FX.js} +1 -1
  11. package/client/dist/assets/{DocsPage-DX9WOqt2.js → DocsPage-DihYcU8r.js} +1 -1
  12. package/client/dist/assets/{InteractiveJobComposer-DDI6TdsS.js → InteractiveJobComposer-BO6ASN-2.js} +1 -1
  13. package/client/dist/assets/{JobDetailModal-CkD0PBaZ.js → JobDetailModal-CuPYq7tP.js} +1 -1
  14. package/client/dist/assets/{JobDetailPage-B8Rd4U5J.js → JobDetailPage-BusMjJi9.js} +1 -1
  15. package/client/dist/assets/{JobsPage-ChOiSbJn.js → JobsPage-C0QbsF2d.js} +1 -1
  16. package/client/dist/assets/{LoopBuilderPage-6Xwt2G6G.js → LoopBuilderPage-B7TlU4iS.js} +1 -1
  17. package/client/dist/assets/{LoopPreviewModal-CyDapSvB.js → LoopPreviewModal-BRWtXOD2.js} +1 -1
  18. package/client/dist/assets/{LoopWindowSurface-gRdx4nmg.js → LoopWindowSurface-DE0v2K1p.js} +1 -1
  19. package/client/dist/assets/{LoopsPage-BPGVFsH-.js → LoopsPage-C4q1DmCE.js} +1 -1
  20. package/client/dist/assets/{PluginsPage-DQRRdCUi.js → PluginsPage-Z1JHSMdR.js} +1 -1
  21. package/client/dist/assets/{ProjectSettingsDialog-Ce8DSG6H.js → ProjectSettingsDialog-BUNj0tvN.js} +1 -1
  22. package/client/dist/assets/{ReviewPacketPage-WVoio8GJ.js → ReviewPacketPage-hwfPNjyy.js} +1 -1
  23. package/client/dist/assets/{TemplatePreviewModal-CTBZUXAN.js → TemplatePreviewModal-V7FpMWuw.js} +1 -1
  24. package/client/dist/assets/{index-IdGpV21X.js → index-Ce4yZtKf.js} +6 -6
  25. package/client/dist/index.html +1 -1
  26. package/docs/internals/core-runtime-updates.md +3 -3
  27. package/local-runner/dist/specrails-local-runner.js +487 -148
  28. package/mcp-bridge/dist/specrails-mcp.js +330 -42
  29. package/package.json +6 -3
  30. package/client/dist/assets/AgentsPage-B-sSTP1I.js +0 -118
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{h as r,l as i,r as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{a as c,r as l,s as u}from"./useDesktop-BjLT0_EE.js";import{B as d,Q as f,V as p,Z as m,et as h}from"./TicketDetailModalContext-Dkwo2cDs.js";import{n as g}from"./provider-capabilities-lePfeT_Y.js";import{n as _}from"./chevron-up-6EFqEHBj.js";import{n as v}from"./file-text-C0blZHLh.js";import{t as y}from"./circle-x-D2ttKotB.js";import{t as b}from"./git-branch-yf6LE1Bw.js";import{t as x}from"./loader-circle-BqV9xYGf.js";import{n as S,t as C}from"./square-D0JTbRSR.js";import{t as w}from"./rotate-ccw-DalJAQQX.js";import{t as T}from"./search-BDVp3fkH.js";import{t as E}from"./triangle-alert-Cxpn8bqr.js";import{t as D}from"./x-Bu7X_eR2.js";import{L as O,l as k,n as A,r as j,t as M,u as N}from"./dialog-DtdR05v1.js";import{t as P}from"./utils-BC4DHlz2.js";import{n as F,t as I}from"./lib-DWJfei6y.js";import{t as L}from"./button-4FS1ZDTp.js";import{n as R}from"./project-repositories-Cnnuj9Ia.js";import{t as ee}from"./useRuntimeRuns-C97qEqMg.js";import{$t as te,A as ne,D as re,E as ie,Et as ae,Gt as z,Ht as B,It as oe,J as V,Jt as H,Nt as se,Pt as ce,S as le,T as ue,W as de,X as fe,Xt as pe,_t as me,an as he,b as ge,ct as _e,et as ve,nt as ye,q as be,tt as xe,w as Se,wt as Ce,x as we}from"./index-IdGpV21X.js";import{l as Te,n as Ee,p as De,r as Oe,t as ke}from"./loop-layout-CyXj9223.js";import{t as Ae}from"./lib-CQJT8S6Q.js";import{n as je}from"./job-time-BCL7wee9.js";var Me={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};Me.node;var Ne=s(Me),Pe={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Pe.node;var Fe=s(Pe),Ie={name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ie.node;var Le=s(Ie),Re={name:`circle-pause`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]],aliases:[`pause-circle`]};Re.node;var ze=s(Re),Be={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Be.node;var Ve=s(Be),He={name:`hourglass`,size:24,node:[[`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`}]]};He.node;var Ue=s(He),We={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};We.node;var Ge=s(We),U=e(t(),1),W=n();function Ke({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,W.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,W.jsxs)(`div`,{className:`flex items-center`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(fe,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,W.jsx)(qe,{state:i}),(0,W.jsx)(`span`,{className:P(`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,W.jsxs)(V,{side:`bottom`,className:`max-w-[200px]`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,W.jsx)(`div`,{className:P(`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 qe({state:e}){return(0,W.jsxs)(`div`,{className:P(`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,W.jsx)(x,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,W.jsx)(H,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,W.jsx)(y,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,W.jsx)(m,{className:`w-6 h-6 text-muted-foreground/20`})]})}function Je(e,t){let n=je(e??null),r=(typeof t==`number`?t:je(t??null)?.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 Ye(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 Xe={steps:0,actionKey:``,actionArg:``,turns:0,tokens:0,lastSeenIdx:0};function Ze(e){if(e.event_type!==`assistant`)return null;try{let t=JSON.parse(e.payload);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.message,r=(n&&typeof n==`object`&&!Array.isArray(n)?n:t).usage;if(!r||typeof r!=`object`||Array.isArray(r))return null;let i=r,a=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return a(i.input_tokens)+a(i.output_tokens)+a(i.cache_read_input_tokens)+a(i.cache_creation_input_tokens)}catch{return null}}function Qe(e,t){if(t.type===`reset`)return Xe;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,turns:s,tokens:c}=e;for(let e=r;e<n.length;e++){let t=le(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``);let r=Ze(n[e]);r!=null&&(s+=1,c+=r)}return{steps:i,actionKey:a,actionArg:o,turns:s,tokens:c,lastSeenIdx:n.length}}return e}function $e(e,t){let[n,r]=(0,U.useReducer)(Qe,Xe),i=(0,U.useRef)(e);return(0,U.useEffect)(()=>{i.current!==e&&(i.current=e,r({type:`reset`})),r({type:`consume`,events:t})},[e,t]),n}function et(e,t){let n=t&&e.steps===0?`connecting`:e.actionKey||`thinking`,r=n===`delegating`||ge.has(n),i=r&&e.actionArg!==``;return{key:r&&!i?`working`:n,arg:i?e.actionArg:null}}function tt(e){return`${(e/1e3).toFixed(1)}k`}function nt(e){let t=!!e.total_cost_usd_estimated,n=e.total_cost_usd==null?null:`${t?`~`:``}$${e.total_cost_usd.toFixed(4)}`,r=e.num_turns==null?null:String(e.num_turns),i=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0);return{cost:n,turns:r,tokens:i==null?null:tt(i)}}function rt(e){if(e.length<=1)return null;let t=e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null;return{totalCostUsd:e.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:e.some(e=>e.total_cost_usd==null),costEstimated:e.some(e=>!!e.total_cost_usd_estimated),nullCostCount:e.filter(e=>e.total_cost_usd==null).length,costUnavailable:e.every(e=>e.total_cost_usd==null),totalTokensIn:e.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:e.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:e.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:e.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:e.filter(t).length,tokensUnavailable:e.every(t),jobCount:e.length}}function it(e){return e.costUnavailable?`—`:`${e.costEstimated?`~`:``}${e.hasNullCost?`≥`:``}$${e.totalCostUsd.toFixed(4)}`}function at(e){if(e.tokensUnavailable)return`—`;let t=e.totalTokensIn+e.totalTokensOut+e.totalTokensCacheRead+e.totalTokensCacheCreate;return`${(e.nullTokenCount??0)>0?`≥`:``}${tt(t)}`}var ot=`specrails-desktop:job-run-details`;function st(e){try{let t=localStorage.getItem(ot);return t?JSON.parse(t)?.[e]===!0:!1}catch{return!1}}function ct(e,t){try{let n=localStorage.getItem(ot),r={};if(n)try{let e=JSON.parse(n);e&&typeof e==`object`&&(r=e)}catch{}r[e]=t,localStorage.setItem(ot,JSON.stringify(r))}catch{}}var lt={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`},skipped:{variant:`queued`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}};function ut({job:e,events:t,phases:n,phaseDefinitions:r,projectId:i,variant:a,pipelineTotals:s,actions:c,onOpenRun:l}){let{t:u}=o(`jobs`),{t:d}=o(`agentRuntime`),f=e.status===`running`,p=e.status===`queued`,m=e.command.startsWith(`loop:`),h=lt[e.status]??lt.queued,[_,v]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!f)return;v(Date.now());let e=window.setInterval(()=>v(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let y=e.finished_at?Je(e.started_at,e.finished_at):f?Je(e.started_at,_):`—`,b=$e(e.id,t),S=ee(i,{jobId:e.id,enabled:!!i}),C=S.runs[0],[w,T]=(0,U.useState)(()=>st(a)),E=e=>{T(e),ct(a,e)},D=(0,U.useMemo)(()=>r.find(e=>n[e.key]===`running`)?.label??null,[n,r]),O=C?.nextStep?d(`roles.${C.nextStep}`,{defaultValue:C.nextStep}):null,k=D??O,{key:A,arg:j}=et(b,f),M=j==null?u(`statusPanel.activity.${A}`):u(`statusPanel.activity.${A}`,{arg:j}),N=f?k?u(`runHeader.phaseActivity`,{phase:k,activity:M}):M:C&&!C.active&&C.nextStep&&(C.canResume||C.pendingQuestion||C.pendingApproval)?u(`runHeader.phaseActivity`,{phase:d(`runs.status.${C.status}`,{defaultValue:C.status}),activity:d(`runs.phase`,{phase:O})}):null,F=m&&f&&b.steps>0?u(`statusPanel.steps`,{count:b.steps}):null,I=nt(e),R=!f&&!p,te=(0,U.useMemo)(()=>R?Ye(t):[],[t,R]),ae=f&&b.turns>0,z=S.runs.length>0?S.error:``,B=!!C?.pendingQuestion&&!!C.canResume&&!C.recoverableSteps.length,oe=R||ae||!!C&&!!i||!!z,H=S.busy!==null,se=C?(0,W.jsxs)(W.Fragment,{children:[C.canResume&&!B&&(C.engineVersion===2&&C.recoverableSteps.length>0?(0,W.jsx)(re,{run:C,busy:H,onRecover:e=>void S.act(C,`recover`,e)},`${i}:${C.runId}`):(0,W.jsx)(L,{size:`sm`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,C.recoverableSteps.length?`recover`:C.pendingApproval?`approve`:`resume`),children:C.recoverableSteps.length?d(`runs.recover`):C.pendingApproval?d(`runs.approve`):d(`runs.resume`)})),B&&(0,W.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 border-accent-warning/40 text-accent-warning hover:bg-accent-warning/10`,onClick:()=>E(!0),children:[(0,W.jsx)(Ge,{className:`w-3.5 h-3.5 mr-1.5`,"aria-hidden":!0}),u(`runHeader.questionPending`)]}),C.canSettle&&(0,W.jsx)(L,{size:`sm`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,`settle`),children:d(`runs.prepareDelivery`)}),C.forkSuccessor&&l&&(0,W.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>l(C.forkSuccessor),children:u(`loopExplorer.openFork`)}),C.canCancel&&(0,W.jsx)(L,{size:`sm`,variant:`secondary`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,`cancel`),children:d(`runs.cancel`)})]}):null;return(0,W.jsxs)(`div`,{"data-testid":`job-run-header`,className:P(`shrink-0`,a===`glass`?`border-b border-border/30 bg-surface/30`:`border-b border-border bg-background`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap px-3 py-2 min-w-0`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(fe,{asChild:!0,children:(0,W.jsx)(`div`,{children:(0,W.jsx)(ne,{variant:h.variant,children:u(h.labelKey)})})}),(0,W.jsx)(V,{children:u(h.tooltipKey)})]}),(0,W.jsxs)(`span`,{className:P(`inline-flex items-center gap-1.5 text-xs tabular-nums`,f?`text-accent-info font-medium`:`text-muted-foreground`),title:u(f?`statusPanel.liveTooltip`:`statusPanel.duration`),children:[f&&(0,W.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,"aria-hidden":!0}),y]}),N&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 flex-1 basis-40 text-xs text-muted-foreground`,children:[f&&(0,W.jsx)(x,{className:`w-3 h-3 shrink-0 text-accent-info animate-spin`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`truncate`,"data-testid":`job-run-activity`,children:N})]}),!N&&(0,W.jsx)(`span`,{className:`flex-1`}),F&&(0,W.jsx)(`span`,{className:`text-[11px] text-muted-foreground/70 tabular-nums shrink-0`,children:F}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[se,c,oe&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>E(!w),"aria-expanded":w,className:`inline-flex items-center gap-1 h-7 px-2 rounded-md text-[11px] text-muted-foreground hover:text-foreground hover:bg-surface/60 transition-colors`,children:[u(`runHeader.details`),(0,W.jsx)(pe,{className:P(`w-3.5 h-3.5 transition-transform duration-150`,w&&`rotate-180`),"aria-hidden":!0})]})]})]}),r.length>0&&(0,W.jsx)(`div`,{className:`px-3 pb-2 overflow-x-auto`,children:(0,W.jsx)(Ke,{phases:n,phaseDefinitions:r})}),oe&&w&&(0,W.jsxs)(`div`,{"data-testid":`job-run-details`,className:`px-3 pb-3 space-y-3 border-t border-border/20 pt-3 text-xs`,children:[ae&&(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 max-w-sm`,children:[(0,W.jsx)(G,{label:u(`statusPanel.turns`),value:String(b.turns)}),(0,W.jsx)(G,{label:u(`statusPanel.tokens`),value:tt(b.tokens)})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 mt-1`,children:u(`runHeader.liveReported`)})]}),R&&(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-w-lg`,children:[(0,W.jsx)(G,{label:u(`statusPanel.cost`),value:I.cost,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:g(e.provider)?u(`statusPanel.costUnknownLocal`):u(`statusPanel.notAvailable`),naTooltip:g(e.provider)?u(`statusPanel.costUnknownLocalTooltip`):void 0}),(0,W.jsx)(G,{label:u(`statusPanel.turns`),value:I.turns,naCaption:u(`statusPanel.notAvailable`)}),(0,W.jsx)(G,{label:u(`statusPanel.tokens`),value:I.tokens,naCaption:u(`statusPanel.notAvailable`)})]}),R&&s&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:u(`statusPanel.pipelineTotal`,{count:s.jobCount})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 max-w-sm`,children:[(0,W.jsx)(G,{label:u(`statusPanel.totalCost`),value:it(s),valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,W.jsx)(G,{label:u(`statusPanel.totalTokens`),value:at(s)})]}),s.hasNullCost&&!s.costUnavailable&&(0,W.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:u(`statusPanel.pipelinePartialTooltip`),children:u(`statusPanel.pipelinePartial`,{count:s.nullCostCount??0})}),s.costUnavailable&&(0,W.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:u(`statusPanel.pipelineCostUnavailable`)}),(s.nullTokenCount??0)>0&&(0,W.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:u(`statusPanel.pipelineUsageTooltip`),children:s.tokensUnavailable?u(`statusPanel.pipelineUsageUnavailable`):u(`statusPanel.pipelineUsagePartial`,{count:s.nullTokenCount??0})})]}),te.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:u(`statusPanel.filesModified`)}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:te.map(e=>(0,W.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))})]}),(C||z)&&i&&(0,W.jsxs)(`section`,{"aria-label":d(`runs.implementation`),className:`space-y-2`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[z&&(0,W.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:z}),C?.historical&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`evidence.historical`)}),C?.status===`succeeded`&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`runs.reviewDelivery`)}),C?.canResume&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`runs.preserveProgress`)}),C?.error&&(0,W.jsx)(`p`,{className:`text-destructive`,children:C.error}),C?.pendingApproval?.reason&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:C.pendingApproval.reason}),C?.pendingQuestion&&(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:d(`runs.question`)}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap`,children:C.pendingQuestion.question}),B&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`block space-y-1`,children:[d(`runs.answerLabel`),(0,W.jsx)(`textarea`,{className:`min-h-20 w-full rounded-md border border-input bg-background px-2 py-1 text-sm`,maxLength:2e4,placeholder:d(`runs.answerPlaceholder`),value:S.answers[C.runId]??``,onChange:e=>S.setAnswer(C.runId,e.target.value)})]}),(0,W.jsx)(L,{size:`sm`,disabled:H||!S.answers[C.runId]?.trim(),onClick:()=>void S.act(C,`answer`),children:d(`runs.answer`)})]})]}),C?.metrics&&(0,W.jsx)(Se,{metrics:C.metrics}),C&&(0,W.jsx)(ie,{projectId:i,runId:C.runId,summary:C.efficiencySummary,historical:C.historical}),C&&(0,W.jsx)(ue,{projectId:i,run:C,onAccepted:S.refresh})]})]})]})}function G({label:e,value:t,valueClass:n,naCaption:r,naTooltip:i}){return(0,W.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-2.5 py-1.5`,title:t==null?i:void 0,children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,W.jsx)(`p`,{className:P(`text-sm font-semibold tabular-nums`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&r&&(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/40`,children:r})]})}function dt(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 ft=new Set;function pt({ticketId:e,onOpen:t,children:n}){let{t:r}=o(`agent`),i=r(`refs.openTicket`,{id:e});return(0,W.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 mt(e){if(!e.includes(`#`))return null;let t=ye(e,ft);return t.some(e=>e.kind===`ticket`)?t:null}function ht(e,t){let n=mt(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,W.jsx)(pt,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,W.jsx)(U.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var gt=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function _t(e){return e.kind===`ticket`?{type:`link`,url:ve({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function vt(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!gt.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=ye(n.value,ft);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(_t))}else vt(n)}}function yt(){return e=>vt(e)}function bt(e){let{activeProjectId:t}=l(),{openRef:n}=_e(),r=e??t??void 0;return(0,U.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function xt(e,t){let n=`${e.id??t}`,i=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:i}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:i}:dt(t)?{id:n,content:t,type:`assistant`,timestamp:i}:{id:n,content:t,type:`plain`,timestamp:i}: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),a=[];return t.duration_ms&&a.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&a.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&a.push(r.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${r.t(`jobs:logViewer.completed`)}${a.length?` — ${a.join(` · `)}`:``}`,type:`result`,timestamp:i}}catch{return null}return null}function St(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 Ct(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+=`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{h as r,l as i,r as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as o,t as s}from"./createLucideIcon-DtODIU64.js";import{a as c,r as l,s as u}from"./useDesktop-BjLT0_EE.js";import{B as d,Q as f,V as p,Z as m,et as h}from"./TicketDetailModalContext-Dkwo2cDs.js";import{n as g}from"./provider-capabilities-lePfeT_Y.js";import{n as _}from"./chevron-up-6EFqEHBj.js";import{n as v}from"./file-text-C0blZHLh.js";import{t as y}from"./circle-x-D2ttKotB.js";import{t as b}from"./git-branch-yf6LE1Bw.js";import{t as x}from"./loader-circle-BqV9xYGf.js";import{n as S,t as C}from"./square-D0JTbRSR.js";import{t as w}from"./rotate-ccw-DalJAQQX.js";import{t as T}from"./search-BDVp3fkH.js";import{t as E}from"./triangle-alert-Cxpn8bqr.js";import{t as D}from"./x-Bu7X_eR2.js";import{L as O,l as k,n as A,r as j,t as M,u as N}from"./dialog-DtdR05v1.js";import{t as P}from"./utils-BC4DHlz2.js";import{n as F,t as I}from"./lib-DWJfei6y.js";import{t as L}from"./button-4FS1ZDTp.js";import{n as R}from"./project-repositories-Cnnuj9Ia.js";import{t as ee}from"./useRuntimeRuns-C97qEqMg.js";import{$t as te,A as ne,D as re,E as ie,Et as ae,Gt as z,Ht as B,It as oe,J as V,Jt as H,Nt as se,Pt as ce,S as le,T as ue,W as de,X as fe,Xt as pe,_t as me,an as he,b as ge,ct as _e,et as ve,nt as ye,q as be,tt as xe,w as Se,wt as Ce,x as we}from"./index-Ce4yZtKf.js";import{l as Te,n as Ee,p as De,r as Oe,t as ke}from"./loop-layout-CyXj9223.js";import{t as Ae}from"./lib-CQJT8S6Q.js";import{n as je}from"./job-time-BCL7wee9.js";var Me={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};Me.node;var Ne=s(Me),Pe={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Pe.node;var Fe=s(Pe),Ie={name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ie.node;var Le=s(Ie),Re={name:`circle-pause`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]],aliases:[`pause-circle`]};Re.node;var ze=s(Re),Be={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Be.node;var Ve=s(Be),He={name:`hourglass`,size:24,node:[[`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`}]]};He.node;var Ue=s(He),We={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};We.node;var Ge=s(We),U=e(t(),1),W=n();function Ke({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,W.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,W.jsxs)(`div`,{className:`flex items-center`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(fe,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,W.jsx)(qe,{state:i}),(0,W.jsx)(`span`,{className:P(`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,W.jsxs)(V,{side:`bottom`,className:`max-w-[200px]`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,W.jsx)(`div`,{className:P(`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 qe({state:e}){return(0,W.jsxs)(`div`,{className:P(`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,W.jsx)(x,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,W.jsx)(H,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,W.jsx)(y,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,W.jsx)(m,{className:`w-6 h-6 text-muted-foreground/20`})]})}function Je(e,t){let n=je(e??null),r=(typeof t==`number`?t:je(t??null)?.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 Ye(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 Xe={steps:0,actionKey:``,actionArg:``,turns:0,tokens:0,lastSeenIdx:0};function Ze(e){if(e.event_type!==`assistant`)return null;try{let t=JSON.parse(e.payload);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.message,r=(n&&typeof n==`object`&&!Array.isArray(n)?n:t).usage;if(!r||typeof r!=`object`||Array.isArray(r))return null;let i=r,a=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return a(i.input_tokens)+a(i.output_tokens)+a(i.cache_read_input_tokens)+a(i.cache_creation_input_tokens)}catch{return null}}function Qe(e,t){if(t.type===`reset`)return Xe;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,turns:s,tokens:c}=e;for(let e=r;e<n.length;e++){let t=le(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``);let r=Ze(n[e]);r!=null&&(s+=1,c+=r)}return{steps:i,actionKey:a,actionArg:o,turns:s,tokens:c,lastSeenIdx:n.length}}return e}function $e(e,t){let[n,r]=(0,U.useReducer)(Qe,Xe),i=(0,U.useRef)(e);return(0,U.useEffect)(()=>{i.current!==e&&(i.current=e,r({type:`reset`})),r({type:`consume`,events:t})},[e,t]),n}function et(e,t){let n=t&&e.steps===0?`connecting`:e.actionKey||`thinking`,r=n===`delegating`||ge.has(n),i=r&&e.actionArg!==``;return{key:r&&!i?`working`:n,arg:i?e.actionArg:null}}function tt(e){return`${(e/1e3).toFixed(1)}k`}function nt(e){let t=!!e.total_cost_usd_estimated,n=e.total_cost_usd==null?null:`${t?`~`:``}$${e.total_cost_usd.toFixed(4)}`,r=e.num_turns==null?null:String(e.num_turns),i=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0);return{cost:n,turns:r,tokens:i==null?null:tt(i)}}function rt(e){if(e.length<=1)return null;let t=e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null;return{totalCostUsd:e.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:e.some(e=>e.total_cost_usd==null),costEstimated:e.some(e=>!!e.total_cost_usd_estimated),nullCostCount:e.filter(e=>e.total_cost_usd==null).length,costUnavailable:e.every(e=>e.total_cost_usd==null),totalTokensIn:e.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:e.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:e.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:e.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:e.filter(t).length,tokensUnavailable:e.every(t),jobCount:e.length}}function it(e){return e.costUnavailable?`—`:`${e.costEstimated?`~`:``}${e.hasNullCost?`≥`:``}$${e.totalCostUsd.toFixed(4)}`}function at(e){if(e.tokensUnavailable)return`—`;let t=e.totalTokensIn+e.totalTokensOut+e.totalTokensCacheRead+e.totalTokensCacheCreate;return`${(e.nullTokenCount??0)>0?`≥`:``}${tt(t)}`}var ot=`specrails-desktop:job-run-details`;function st(e){try{let t=localStorage.getItem(ot);return t?JSON.parse(t)?.[e]===!0:!1}catch{return!1}}function ct(e,t){try{let n=localStorage.getItem(ot),r={};if(n)try{let e=JSON.parse(n);e&&typeof e==`object`&&(r=e)}catch{}r[e]=t,localStorage.setItem(ot,JSON.stringify(r))}catch{}}var lt={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`},skipped:{variant:`queued`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}};function ut({job:e,events:t,phases:n,phaseDefinitions:r,projectId:i,variant:a,pipelineTotals:s,actions:c,onOpenRun:l}){let{t:u}=o(`jobs`),{t:d}=o(`agentRuntime`),f=e.status===`running`,p=e.status===`queued`,m=e.command.startsWith(`loop:`),h=lt[e.status]??lt.queued,[_,v]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!f)return;v(Date.now());let e=window.setInterval(()=>v(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let y=e.finished_at?Je(e.started_at,e.finished_at):f?Je(e.started_at,_):`—`,b=$e(e.id,t),S=ee(i,{jobId:e.id,enabled:!!i}),C=S.runs[0],[w,T]=(0,U.useState)(()=>st(a)),E=e=>{T(e),ct(a,e)},D=(0,U.useMemo)(()=>r.find(e=>n[e.key]===`running`)?.label??null,[n,r]),O=C?.nextStep?d(`roles.${C.nextStep}`,{defaultValue:C.nextStep}):null,k=D??O,{key:A,arg:j}=et(b,f),M=j==null?u(`statusPanel.activity.${A}`):u(`statusPanel.activity.${A}`,{arg:j}),N=f?k?u(`runHeader.phaseActivity`,{phase:k,activity:M}):M:C&&!C.active&&C.nextStep&&(C.canResume||C.pendingQuestion||C.pendingApproval)?u(`runHeader.phaseActivity`,{phase:d(`runs.status.${C.status}`,{defaultValue:C.status}),activity:d(`runs.phase`,{phase:O})}):null,F=m&&f&&b.steps>0?u(`statusPanel.steps`,{count:b.steps}):null,I=nt(e),R=!f&&!p,te=(0,U.useMemo)(()=>R?Ye(t):[],[t,R]),ae=f&&b.turns>0,z=S.runs.length>0?S.error:``,B=!!C?.pendingQuestion&&!!C.canResume&&!C.recoverableSteps.length,oe=R||ae||!!C&&!!i||!!z,H=S.busy!==null,se=C?(0,W.jsxs)(W.Fragment,{children:[C.canResume&&!B&&(C.engineVersion===2&&C.recoverableSteps.length>0?(0,W.jsx)(re,{run:C,busy:H,onRecover:e=>void S.act(C,`recover`,e)},`${i}:${C.runId}`):(0,W.jsx)(L,{size:`sm`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,C.recoverableSteps.length?`recover`:C.pendingApproval?`approve`:`resume`),children:C.recoverableSteps.length?d(`runs.recover`):C.pendingApproval?d(`runs.approve`):d(`runs.resume`)})),B&&(0,W.jsxs)(L,{size:`sm`,variant:`outline`,className:`h-7 border-accent-warning/40 text-accent-warning hover:bg-accent-warning/10`,onClick:()=>E(!0),children:[(0,W.jsx)(Ge,{className:`w-3.5 h-3.5 mr-1.5`,"aria-hidden":!0}),u(`runHeader.questionPending`)]}),C.canSettle&&(0,W.jsx)(L,{size:`sm`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,`settle`),children:d(`runs.prepareDelivery`)}),C.forkSuccessor&&l&&(0,W.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>l(C.forkSuccessor),children:u(`loopExplorer.openFork`)}),C.canCancel&&(0,W.jsx)(L,{size:`sm`,variant:`secondary`,className:`h-7`,disabled:H,onClick:()=>void S.act(C,`cancel`),children:d(`runs.cancel`)})]}):null;return(0,W.jsxs)(`div`,{"data-testid":`job-run-header`,className:P(`shrink-0`,a===`glass`?`border-b border-border/30 bg-surface/30`:`border-b border-border bg-background`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap px-3 py-2 min-w-0`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(fe,{asChild:!0,children:(0,W.jsx)(`div`,{children:(0,W.jsx)(ne,{variant:h.variant,children:u(h.labelKey)})})}),(0,W.jsx)(V,{children:u(h.tooltipKey)})]}),(0,W.jsxs)(`span`,{className:P(`inline-flex items-center gap-1.5 text-xs tabular-nums`,f?`text-accent-info font-medium`:`text-muted-foreground`),title:u(f?`statusPanel.liveTooltip`:`statusPanel.duration`),children:[f&&(0,W.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,"aria-hidden":!0}),y]}),N&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 flex-1 basis-40 text-xs text-muted-foreground`,children:[f&&(0,W.jsx)(x,{className:`w-3 h-3 shrink-0 text-accent-info animate-spin`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`truncate`,"data-testid":`job-run-activity`,children:N})]}),!N&&(0,W.jsx)(`span`,{className:`flex-1`}),F&&(0,W.jsx)(`span`,{className:`text-[11px] text-muted-foreground/70 tabular-nums shrink-0`,children:F}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[se,c,oe&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>E(!w),"aria-expanded":w,className:`inline-flex items-center gap-1 h-7 px-2 rounded-md text-[11px] text-muted-foreground hover:text-foreground hover:bg-surface/60 transition-colors`,children:[u(`runHeader.details`),(0,W.jsx)(pe,{className:P(`w-3.5 h-3.5 transition-transform duration-150`,w&&`rotate-180`),"aria-hidden":!0})]})]})]}),r.length>0&&(0,W.jsx)(`div`,{className:`px-3 pb-2 overflow-x-auto`,children:(0,W.jsx)(Ke,{phases:n,phaseDefinitions:r})}),oe&&w&&(0,W.jsxs)(`div`,{"data-testid":`job-run-details`,className:`px-3 pb-3 space-y-3 border-t border-border/20 pt-3 text-xs`,children:[ae&&(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 max-w-sm`,children:[(0,W.jsx)(G,{label:u(`statusPanel.turns`),value:String(b.turns)}),(0,W.jsx)(G,{label:u(`statusPanel.tokens`),value:tt(b.tokens)})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 mt-1`,children:u(`runHeader.liveReported`)})]}),R&&(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-w-lg`,children:[(0,W.jsx)(G,{label:u(`statusPanel.cost`),value:I.cost,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:g(e.provider)?u(`statusPanel.costUnknownLocal`):u(`statusPanel.notAvailable`),naTooltip:g(e.provider)?u(`statusPanel.costUnknownLocalTooltip`):void 0}),(0,W.jsx)(G,{label:u(`statusPanel.turns`),value:I.turns,naCaption:u(`statusPanel.notAvailable`)}),(0,W.jsx)(G,{label:u(`statusPanel.tokens`),value:I.tokens,naCaption:u(`statusPanel.notAvailable`)})]}),R&&s&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:u(`statusPanel.pipelineTotal`,{count:s.jobCount})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 max-w-sm`,children:[(0,W.jsx)(G,{label:u(`statusPanel.totalCost`),value:it(s),valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,W.jsx)(G,{label:u(`statusPanel.totalTokens`),value:at(s)})]}),s.hasNullCost&&!s.costUnavailable&&(0,W.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:u(`statusPanel.pipelinePartialTooltip`),children:u(`statusPanel.pipelinePartial`,{count:s.nullCostCount??0})}),s.costUnavailable&&(0,W.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:u(`statusPanel.pipelineCostUnavailable`)}),(s.nullTokenCount??0)>0&&(0,W.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:u(`statusPanel.pipelineUsageTooltip`),children:s.tokensUnavailable?u(`statusPanel.pipelineUsageUnavailable`):u(`statusPanel.pipelineUsagePartial`,{count:s.nullTokenCount??0})})]}),te.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:u(`statusPanel.filesModified`)}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:te.map(e=>(0,W.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))})]}),(C||z)&&i&&(0,W.jsxs)(`section`,{"aria-label":d(`runs.implementation`),className:`space-y-2`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[z&&(0,W.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:z}),C?.historical&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`evidence.historical`)}),C?.status===`succeeded`&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`runs.reviewDelivery`)}),C?.canResume&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:d(`runs.preserveProgress`)}),C?.error&&(0,W.jsx)(`p`,{className:`text-destructive`,children:C.error}),C?.pendingApproval?.reason&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:C.pendingApproval.reason}),C?.pendingQuestion&&(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:d(`runs.question`)}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap`,children:C.pendingQuestion.question}),B&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`block space-y-1`,children:[d(`runs.answerLabel`),(0,W.jsx)(`textarea`,{className:`min-h-20 w-full rounded-md border border-input bg-background px-2 py-1 text-sm`,maxLength:2e4,placeholder:d(`runs.answerPlaceholder`),value:S.answers[C.runId]??``,onChange:e=>S.setAnswer(C.runId,e.target.value)})]}),(0,W.jsx)(L,{size:`sm`,disabled:H||!S.answers[C.runId]?.trim(),onClick:()=>void S.act(C,`answer`),children:d(`runs.answer`)})]})]}),C?.metrics&&(0,W.jsx)(Se,{metrics:C.metrics}),C&&(0,W.jsx)(ie,{projectId:i,runId:C.runId,summary:C.efficiencySummary,historical:C.historical}),C&&(0,W.jsx)(ue,{projectId:i,run:C,onAccepted:S.refresh})]})]})]})}function G({label:e,value:t,valueClass:n,naCaption:r,naTooltip:i}){return(0,W.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-2.5 py-1.5`,title:t==null?i:void 0,children:[(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,W.jsx)(`p`,{className:P(`text-sm font-semibold tabular-nums`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&r&&(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/40`,children:r})]})}function dt(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 ft=new Set;function pt({ticketId:e,onOpen:t,children:n}){let{t:r}=o(`agent`),i=r(`refs.openTicket`,{id:e});return(0,W.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 mt(e){if(!e.includes(`#`))return null;let t=ye(e,ft);return t.some(e=>e.kind===`ticket`)?t:null}function ht(e,t){let n=mt(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,W.jsx)(pt,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,W.jsx)(U.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var gt=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function _t(e){return e.kind===`ticket`?{type:`link`,url:ve({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function vt(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!gt.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=ye(n.value,ft);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(_t))}else vt(n)}}function yt(){return e=>vt(e)}function bt(e){let{activeProjectId:t}=l(),{openRef:n}=_e(),r=e??t??void 0;return(0,U.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function xt(e,t){let n=`${e.id??t}`,i=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:i}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:i}:dt(t)?{id:n,content:t,type:`assistant`,timestamp:i}:{id:n,content:t,type:`plain`,timestamp:i}: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),a=[];return t.duration_ms&&a.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&a.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&a.push(r.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${r.t(`jobs:logViewer.completed`)}${a.length?` — ${a.join(` · `)}`:``}`,type:`result`,timestamp:i}}catch{return null}return null}function St(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 Ct(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 wt(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 Tt({events:e,isLoading:t,projectId:n}){let{t:r,i18n:i}=o(`jobs`),[a,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!0),[d,f]=(0,U.useState)(new Set),p=(0,U.useRef)(null),m=(0,U.useRef)(null),h=bt(n),{processedLines:g,groups:_,totalLines:v}=(0,U.useMemo)(()=>{let t=St(Ct(e.map((e,t)=>xt(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:wt(t),totalLines:t.length}},[e,i.language]),y=(0,U.useMemo)(()=>{if(!a)return v;let e=a.toLowerCase();return g.filter(t=>t.content.toLowerCase().includes(e)).length},[a,g,v]),b=(0,U.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,U.useEffect)(()=>{c&&b()},[e.length,c,b]);function x(){let e=m.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<50;l(t)}function S(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):v===0?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,W.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,W.jsx)(T,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,W.jsx)(de,{placeholder:r(`logViewer.filterPlaceholder`),value:a,onChange:e=>s(e.target.value),className:`pl-7 h-7`})]}),(0,W.jsx)(L,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=g.map(e=>e.content).join(`
3
3
  `);navigator.clipboard.writeText(e).then(()=>{u.success(r(`logViewer.copySuccess`))}).catch(()=>{u.error(r(`logViewer.copyFailed`))})},children:(0,W.jsx)(z,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:y,total:v})})]}),(0,W.jsxs)(`div`,{ref:m,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:x,children:[_.map(e=>(0,W.jsx)(Et,{group:e,filter:a,collapsed:d.has(e.key),onToggle:()=>S(e.key),onOpenTicket:h},e.key)),(0,W.jsx)(`div`,{ref:p})]}),!c&&(0,W.jsxs)(L,{size:`sm`,variant:`secondary`,onClick:()=>{l(!0),b()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,W.jsx)(pe,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Et=(0,U.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:i}){let{t:a}=o(`jobs`),s=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return s.length===0?null:(0,W.jsx)(`div`,{children:s.map((e,t)=>(0,W.jsx)(At,{line:e,even:t%2==0,onOpenTicket:i},e.id))});let c=e.header.content;return(0,W.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:r,className:P(`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,W.jsx)(v,{className:P(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:c}),e.header.timestamp&&(0,W.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,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:s.length===0?(0,W.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):s.map((e,t)=>(0,W.jsx)(At,{line:e,even:t%2==0,onOpenTicket:i},e.id))})]})}),Dt=[Ae],Ot=[I],kt=[I,yt],At=(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?ht(e.content,n):e.content,[l,n,e.content]),d=r&&n?kt:Ot,f=(0,U.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=xe(e);return r?.kind===`ticket`?(0,W.jsx)(pt,{ticketId:r.ticketId,onOpen:n,children:t}):(0,W.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,W.jsxs)(`div`,{className:P(`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,W.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,W.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
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{a as i,c as a,l as o,m as s}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as c}from"./createLucideIcon-DtODIU64.js";import{a as l,s as u}from"./useDesktop-BjLT0_EE.js";import{ht as d,ut as f}from"./TicketDetailModalContext-Dkwo2cDs.js";import{a as p,c as m,i as h,l as g,n as ee,o as te,r as ne,s as re,t as ie,u as _}from"./InteractiveJobComposer-DDI6TdsS.js";import{t as v}from"./loader-circle-BqV9xYGf.js";import{t as y}from"./x-Bu7X_eR2.js";import{F as b,I as x,P as S}from"./dialog-DtdR05v1.js";import{t as ae}from"./formatDistanceToNow-NjPHBLfB.js";import{t as C}from"./button-4FS1ZDTp.js";import{G as oe,K as se,Y as ce}from"./index-IdGpV21X.js";import{n as le,t as ue}from"./job-time-BCL7wee9.js";var de=e(r(),1),w=e(t(),1),T=[1e3,2e3,4e3,8e3,16e3];function E(e,t){let[n,r]=(0,w.useState)(`connecting`),o=(0,w.useRef)(t);return o.current=t,(0,w.useEffect)(()=>{let t=!1,n=!1,s=null,c=0,l=null;async function u(){if(!(t||n||s)){n=!0;try{await a()}catch{}finally{n=!1}!t&&!s&&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||s)return;let n=i(),a;try{a=n?new WebSocket(e,[`specrails-desktop`,n]):new WebSocket(e)}catch{d();return}s=a,r(`connecting`),a.onopen=()=>{t||s!==a||(c=0,r(`connected`))},a.onmessage=e=>{if(!(t||s!==a))try{o.current(JSON.parse(e.data))}catch{}},a.onclose=()=>{t||s!==a||(s=null,d())}}let p=()=>{t||s||(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=s;if(s=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 O({jobId:e,onClose:t,projectId:n}){let[r,i]=(0,w.useState)(e);(0,w.useEffect)(()=>{i(e)},[e]);let{t:a}=c(`jobs`),{t:T}=c(`narration`),O=(0,w.useCallback)(()=>n?`${o}/api/projects/${n}`:l(),[n]),[k,fe]=(0,w.useState)(p),pe=(0,w.useCallback)(e=>{fe(e),te(e)},[]),[A,j]=(0,w.useState)(null),[M,N]=(0,w.useState)(()=>h([])),P=(0,w.useMemo)(()=>ne(M,a(`logViewer.retainedTail`)),[M,a]),[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)(()=>{let e=!1;q.current={events:[],omitted:!1},J.current&&cancelAnimationFrame(J.current),J.current=null,N(h([])),j(null),B(!0),V(!1);async function t(){try{let t=await fetch(`${O()}/jobs/${r}`);if(e)return;if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(e)return;if(j(n.job),N(h(n.events)),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{e||V(!0)}finally{e||B(!1)}}return t(),()=>{e=!0}},[r,O]);let K=(0,w.useCallback)(()=>{fetch(`${O()}/jobs/${r}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&j(e.job)}).catch(()=>{})},[r,O]),q=(0,w.useRef)({events:[],omitted:!1}),J=(0,w.useRef)(null),Y=(0,w.useCallback)(()=>{J.current=null;let e=q.current;e.events.length!==0&&(q.current={events:[],omitted:!1},N(t=>h([...t.events,...e.events],t.omitted||e.omitted)))},[]),X=(0,w.useCallback)(e=>{if(!ee(e))return;let t=q.current;t.events.push(e),t.events.length>1e4&&(q.current=h(t.events,t.omitted)),J.current||=requestAnimationFrame(Y)},[Y]);(0,w.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),E(d,(0,w.useCallback)(e=>{let t=e;if(t.type===`event`&&t.jobId===r){let e={id:Date.now(),job_id:r,seq:0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};X(e)}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,...typeof t.attemptId==`string`&&t.attemptId.trim()&&t.attemptId.length<=256?{attemptId:t.attemptId}:{}}),timestamp:t.timestamp};X(e)}else if(t.type===`job.finalized`&&t.jobId===r||t.type===`runtime.continuation`&&t.jobId===r||t.type===`job.interactive`&&t.jobId===r||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===r)K();else if(t.type===`phase`){let e=t.phase,n=t.state;R(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===r);e&&A&&j(t=>t&&{...t,status:e.status})}},[r,A,X,K])),(0,w.useEffect)(()=>{function e(e){if(!(e.key!==`Escape`||e.defaultPrevented)){if(H){U(!1);return}t()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,H]);let Z=A?se(A):`job`,Q=Z===`loop-run`;async function he(){G(!0);try{let e=await oe({projectId:n??null,jobId:r,kind:Z});e.ok?(u.success(a(Q?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:a(Q?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):u.error(a(`modal.toast.cancelFailed`),{description:e.error})}finally{G(!1)}}let ge=A?.status===`running`,$=A?le(ue(A)):null,{panelRef:_e,panelStyle:ve,headerHandleProps:ye,resizeHandles:be,isFloating:xe,guardBackdrop:Se}=b();return(0,de.createPortal)((0,D.jsx)(ce,{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:[A&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:A.command}),(0,D.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:$?ae($,{addSuffix:!0,locale:s()}):`—`})]}),z&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`common:states.loading`)})]}),(0,D.jsx)(`button`,{onClick:t,className:`h-7 w-7 shrink-0 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`})})]}),A&&(0,D.jsx)(_,{onOpenRun:i,job:A,events:P,phases:L,phaseDefinitions:F,projectId:n,variant:`glass`,actions:ge?(0,D.jsxs)(C,{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}),a(Q?`dashboard:railControls.stop`:Z===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}):null}),M.omitted&&(0,D.jsx)(`p`,{role:`status`,className:`shrink-0 border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:a(`logViewer.retainedTail`)}),(0,D.jsx)(`div`,{className:`min-h-0 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:a(`modal.notFound`)})}):f&&A?(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 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:()=>pe(e),"aria-pressed":k===e,"data-testid":`modal-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${k===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface/60`}`,children:T(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:k===`narrated`?(0,D.jsx)(re,{events:P,settled:A.status!==`running`&&A.status!==`queued`,elapsedMs:A.duration_ms??null,variant:`glass`}):A.command.startsWith(`loop:`)?(0,D.jsx)(m,{events:P,jobStatus:A.status,isLoading:z,variant:`glass`,projectId:n,onOpenRun:i}):(0,D.jsx)(g,{events:P,isLoading:z,projectId:n})})]}):A?.command.startsWith(`loop:`)?(0,D.jsx)(m,{events:P,jobStatus:A.status,isLoading:z,variant:`glass`,projectId:n,onOpenRun:i}):(0,D.jsx)(g,{events:P,isLoading:z,projectId:n})}),!!A?.interactive&&A.status===`running`&&(0,D.jsx)(ie,{jobId:r,projectId:n,settleMode:A.interactiveSettleMode,initialAcceptingTurns:A.interactiveAcceptingTurns,pendingInterrupts:A.pendingInterrupts,kind:A.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,D.jsx)(S,{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:a(Q?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,D.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:a(Q?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,D.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,D.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:a(`modal.keepRunning`)}),(0,D.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),he()},children:a(Q?`modal.stopRun`:Z===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{O as JobDetailModal};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{a as i,c as a,l as o,m as s}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as c}from"./createLucideIcon-DtODIU64.js";import{a as l,s as u}from"./useDesktop-BjLT0_EE.js";import{ht as d,ut as f}from"./TicketDetailModalContext-Dkwo2cDs.js";import{a as p,c as m,i as h,l as g,n as ee,o as te,r as ne,s as re,t as ie,u as _}from"./InteractiveJobComposer-BO6ASN-2.js";import{t as v}from"./loader-circle-BqV9xYGf.js";import{t as y}from"./x-Bu7X_eR2.js";import{F as b,I as x,P as S}from"./dialog-DtdR05v1.js";import{t as ae}from"./formatDistanceToNow-NjPHBLfB.js";import{t as C}from"./button-4FS1ZDTp.js";import{G as oe,K as se,Y as ce}from"./index-Ce4yZtKf.js";import{n as le,t as ue}from"./job-time-BCL7wee9.js";var de=e(r(),1),w=e(t(),1),T=[1e3,2e3,4e3,8e3,16e3];function E(e,t){let[n,r]=(0,w.useState)(`connecting`),o=(0,w.useRef)(t);return o.current=t,(0,w.useEffect)(()=>{let t=!1,n=!1,s=null,c=0,l=null;async function u(){if(!(t||n||s)){n=!0;try{await a()}catch{}finally{n=!1}!t&&!s&&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||s)return;let n=i(),a;try{a=n?new WebSocket(e,[`specrails-desktop`,n]):new WebSocket(e)}catch{d();return}s=a,r(`connecting`),a.onopen=()=>{t||s!==a||(c=0,r(`connected`))},a.onmessage=e=>{if(!(t||s!==a))try{o.current(JSON.parse(e.data))}catch{}},a.onclose=()=>{t||s!==a||(s=null,d())}}let p=()=>{t||s||(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=s;if(s=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 O({jobId:e,onClose:t,projectId:n}){let[r,i]=(0,w.useState)(e);(0,w.useEffect)(()=>{i(e)},[e]);let{t:a}=c(`jobs`),{t:T}=c(`narration`),O=(0,w.useCallback)(()=>n?`${o}/api/projects/${n}`:l(),[n]),[k,fe]=(0,w.useState)(p),pe=(0,w.useCallback)(e=>{fe(e),te(e)},[]),[A,j]=(0,w.useState)(null),[M,N]=(0,w.useState)(()=>h([])),P=(0,w.useMemo)(()=>ne(M,a(`logViewer.retainedTail`)),[M,a]),[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)(()=>{let e=!1;q.current={events:[],omitted:!1},J.current&&cancelAnimationFrame(J.current),J.current=null,N(h([])),j(null),B(!0),V(!1);async function t(){try{let t=await fetch(`${O()}/jobs/${r}`);if(e)return;if(t.status===404){V(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(e)return;if(j(n.job),N(h(n.events)),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{e||V(!0)}finally{e||B(!1)}}return t(),()=>{e=!0}},[r,O]);let K=(0,w.useCallback)(()=>{fetch(`${O()}/jobs/${r}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&j(e.job)}).catch(()=>{})},[r,O]),q=(0,w.useRef)({events:[],omitted:!1}),J=(0,w.useRef)(null),Y=(0,w.useCallback)(()=>{J.current=null;let e=q.current;e.events.length!==0&&(q.current={events:[],omitted:!1},N(t=>h([...t.events,...e.events],t.omitted||e.omitted)))},[]),X=(0,w.useCallback)(e=>{if(!ee(e))return;let t=q.current;t.events.push(e),t.events.length>1e4&&(q.current=h(t.events,t.omitted)),J.current||=requestAnimationFrame(Y)},[Y]);(0,w.useEffect)(()=>()=>{J.current&&cancelAnimationFrame(J.current)},[]),E(d,(0,w.useCallback)(e=>{let t=e;if(t.type===`event`&&t.jobId===r){let e={id:Date.now(),job_id:r,seq:0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};X(e)}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,...typeof t.attemptId==`string`&&t.attemptId.trim()&&t.attemptId.length<=256?{attemptId:t.attemptId}:{}}),timestamp:t.timestamp};X(e)}else if(t.type===`job.finalized`&&t.jobId===r||t.type===`runtime.continuation`&&t.jobId===r||t.type===`job.interactive`&&t.jobId===r||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===r)K();else if(t.type===`phase`){let e=t.phase,n=t.state;R(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===r);e&&A&&j(t=>t&&{...t,status:e.status})}},[r,A,X,K])),(0,w.useEffect)(()=>{function e(e){if(!(e.key!==`Escape`||e.defaultPrevented)){if(H){U(!1);return}t()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,H]);let Z=A?se(A):`job`,Q=Z===`loop-run`;async function he(){G(!0);try{let e=await oe({projectId:n??null,jobId:r,kind:Z});e.ok?(u.success(a(Q?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:a(Q?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),K()):u.error(a(`modal.toast.cancelFailed`),{description:e.error})}finally{G(!1)}}let ge=A?.status===`running`,$=A?le(ue(A)):null,{panelRef:_e,panelStyle:ve,headerHandleProps:ye,resizeHandles:be,isFloating:xe,guardBackdrop:Se}=b();return(0,de.createPortal)((0,D.jsx)(ce,{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:[A&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:A.command}),(0,D.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:$?ae($,{addSuffix:!0,locale:s()}):`—`})]}),z&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`common:states.loading`)})]}),(0,D.jsx)(`button`,{onClick:t,className:`h-7 w-7 shrink-0 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`})})]}),A&&(0,D.jsx)(_,{onOpenRun:i,job:A,events:P,phases:L,phaseDefinitions:F,projectId:n,variant:`glass`,actions:ge?(0,D.jsxs)(C,{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}),a(Q?`dashboard:railControls.stop`:Z===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}):null}),M.omitted&&(0,D.jsx)(`p`,{role:`status`,className:`shrink-0 border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:a(`logViewer.retainedTail`)}),(0,D.jsx)(`div`,{className:`min-h-0 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:a(`modal.notFound`)})}):f&&A?(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 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:()=>pe(e),"aria-pressed":k===e,"data-testid":`modal-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${k===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface/60`}`,children:T(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:k===`narrated`?(0,D.jsx)(re,{events:P,settled:A.status!==`running`&&A.status!==`queued`,elapsedMs:A.duration_ms??null,variant:`glass`}):A.command.startsWith(`loop:`)?(0,D.jsx)(m,{events:P,jobStatus:A.status,isLoading:z,variant:`glass`,projectId:n,onOpenRun:i}):(0,D.jsx)(g,{events:P,isLoading:z,projectId:n})})]}):A?.command.startsWith(`loop:`)?(0,D.jsx)(m,{events:P,jobStatus:A.status,isLoading:z,variant:`glass`,projectId:n,onOpenRun:i}):(0,D.jsx)(g,{events:P,isLoading:z,projectId:n})}),!!A?.interactive&&A.status===`running`&&(0,D.jsx)(ie,{jobId:r,projectId:n,settleMode:A.interactiveSettleMode,initialAcceptingTurns:A.interactiveAcceptingTurns,pendingInterrupts:A.pendingInterrupts,kind:A.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:K})]}),(0,D.jsx)(S,{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:a(Q?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,D.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:a(Q?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,D.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,D.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>U(!1),children:a(`modal.keepRunning`)}),(0,D.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{U(!1),he()},children:a(Q?`modal.stopRun`:Z===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{O as JobDetailModal};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,n as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{m as o,r as ee}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as s}from"./createLucideIcon-DtODIU64.js";import{a as c,r as te,s as l}from"./useDesktop-BjLT0_EE.js";import{n as ne,ut as u}from"./TicketDetailModalContext-Dkwo2cDs.js";import{t as d}from"./chevron-up-6EFqEHBj.js";import{n as re}from"./file-text-C0blZHLh.js";import{a as ie,c as f,d as ae,i as p,l as m,n as oe,o as se,r as ce,s as le,t as ue,u as de}from"./InteractiveJobComposer-DDI6TdsS.js";import{t as fe}from"./download-C9wP_42h.js";import{t as pe}from"./rotate-ccw-DalJAQQX.js";import{t as h}from"./utils-BC4DHlz2.js";import{t as me}from"./formatDistanceToNow-NjPHBLfB.js";import{t as g}from"./button-4FS1ZDTp.js";import{G as he,J as _,Lt as v,X as y,Xt as b,q as x}from"./index-IdGpV21X.js";import{t as ge}from"./format-command-C0D9IPmV.js";var S=e(t(),1),C=n(),w=4;function _e({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,S.useState)(!1);if(e.length===0)return null;let a=e.length>=w&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,C.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,C.jsx)(T,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,C.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,C.jsx)(b,{className:`w-3 h-3`})]}),r&&e.length>=w&&(0,C.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,C.jsx)(d,{className:`w-3 h-3`})]})]})}function T({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,C.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,C.jsx)(`span`,{className:h(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,C.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,C.jsxs)(`span`,{className:h(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,C.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function E(){let{t:e}=s(`jobs`),{t}=s(`narration`),{id:n}=r(),{activeProjectId:d,projects:b}=te(),w=b.find(e=>e.id===d)?.provider,T=a(),{openTicketDetail:E}=ne(),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(()=>p([])),j=(0,S.useMemo)(()=>ce(k,e(`logViewer.retainedTail`)),[k,e]),[ve,M]=(0,S.useState)([]),[ye,N]=(0,S.useState)({}),[be,P]=(0,S.useState)([]),[xe,F]=(0,S.useState)(!0),[Se,I]=(0,S.useState)(!1),[L,Ce]=(0,S.useState)(ie),[we,R]=(0,S.useState)(null),Te=(0,S.useCallback)(e=>{Ce(e),se(e)},[]),z=D?.command??null;(0,S.useEffect)(()=>{if(!u||L!==`narrated`||!d||!z)return;let e=!1,t=`command=${encodeURIComponent(z)}`;try{Promise.resolve(fetch(`${c()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||R(t?.range??null)}).catch(()=>{e||R(null)})}catch{R(null)}return()=>{e=!0}},[d,z,L]);let[B,V]=(0,S.useState)(!1),H=(0,S.useRef)(!1),U=(0,S.useRef)(null);(0,S.useEffect)(()=>{H.current=!1,U.current=null,V(!1)},[n]),(0,S.useEffect)(()=>{if(!n)return;let e=new AbortController;K.current={events:[],omitted:!1},q.current&&cancelAnimationFrame(q.current),q.current=null,O(null),A(p([])),M([]),N({}),F(!0),I(!1);async function t(){try{let t=await fetch(`${c()}/jobs/${n}`,{signal:e.signal});if(t.status===404){I(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();if(e.signal.aborted)return;O(r.job),A(p(r.events))}catch(e){if(e.name===`AbortError`)return;I(!0)}finally{e.signal.aborted||F(!1)}}return t(),()=>e.abort()},[n,d]),(0,S.useEffect)(()=>{if(!D?.pipeline_id){P([]);return}let e=D.pipeline_id;fetch(`${c()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&P(e.jobs)}).catch(()=>{})},[D?.pipeline_id,D?.status]);let W=(0,S.useRef)(d);W.current=d;let G=(0,S.useRef)(null);G.current=D?.status??null;let K=(0,S.useRef)({events:[],omitted:!1}),q=(0,S.useRef)(null),J=(0,S.useCallback)(()=>{q.current=null;let e=K.current;e.events.length!==0&&(K.current={events:[],omitted:!1},A(t=>p([...t.events,...e.events],t.omitted||e.omitted)))},[]),Y=(0,S.useCallback)(e=>{if(!oe(e))return;let t=K.current;t.events.push(e),t.events.length>1e4&&(K.current=p(t.events,t.omitted)),q.current||=requestAnimationFrame(J)},[J]);(0,S.useEffect)(()=>()=>{q.current&&cancelAnimationFrame(q.current)},[]);let X=(0,S.useCallback)(e=>{let t=e;if(!(W.current&&t.projectId&&t.projectId!==W.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];M(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;N(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};Y(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,...typeof t.attemptId==`string`&&t.attemptId.trim()&&t.attemptId.length<=256?{attemptId:t.attemptId}:{}}),timestamp:t.timestamp};Y(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`runtime.continuation`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${c()}/jobs/${n}`).then(e=>e.json()).then(e=>O(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;N(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=G.current;O(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${c()}/jobs/${n}`).then(e=>e.json()).then(e=>O(e.job)).catch(()=>{})}}}},[n,Y]),{registerHandler:Z,unregisterHandler:Q}=ee();(0,S.useEffect)(()=>(Z(`job-detail-${n}`,X),()=>Q(`job-detail-${n}`)),[n,X,Z,Q]),(0,S.useEffect)(()=>{if(!n||!D||D.status!==`running`||D.hasTelemetry)return;let e=setInterval(()=>{fetch(`${c()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&O(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,D?.status,D?.hasTelemetry]);async function Ee(){if(!n)return;let t=await he({projectId:null,jobId:n});t.ok?l.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?l.error(e(`detail.toast.networkError`)):l.error(e(`detail.toast.failed`),{description:t.error})}async function De(){if(D)try{let t=await fetch(`${c()}/jobs/${D.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-${D.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){l.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Oe(){if(!(!D||H.current)){H.current=!0,V(!0),U.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${D.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${c()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":U.current},body:JSON.stringify({rerunOfJobId:D.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));U.current=null,l.success(e(`detail.toast.jobRequeued`)),T(`/jobs/${n.jobId}`)}catch(e){l.error(e.message)}finally{H.current=!1,V(!1)}}}if(xe)return(0,C.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,C.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,C.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(Se||!D)return(0,C.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,C.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,C.jsx)(g,{asChild:!0,variant:`outline`,size:`sm`,children:(0,C.jsxs)(i,{to:`/`,children:[(0,C.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let ke=D.status===`running`,Ae=D.status===`completed`||D.status===`failed`,je=!!D.interactive,Me=je&&ke,Ne=(D.tickets?.length??0)>0,$=D.command.startsWith(`loop:`),Pe=ae(be);return(0,C.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,C.jsxs)(`div`,{className:`px-4 pt-3 pb-2 space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,C.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,C.jsx)(v,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,C.jsx)(re,{className:`w-3 h-3`}),(0,C.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),Ne&&(0,C.jsx)(_e,{tickets:D.tickets??[],onTicketClick:E}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap min-w-0`,children:[(0,C.jsx)(`code`,{className:h(`font-mono text-foreground/90 truncate`,Ne?`text-xs text-muted-foreground`:`text-sm`),children:ge(D.command,w)}),(0,C.jsx)(`span`,{children:D.started_at?e(`detail.startedAgo`,{timeAgo:me(new Date(D.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),D.model&&(0,C.jsx)(`span`,{className:`text-muted-foreground/40`,children:D.model})]})]}),(0,C.jsx)(de,{onOpenRun:e=>T(`/jobs/${e}`),job:D,events:j,phases:ye,phaseDefinitions:ve,projectId:d,variant:`page`,pipelineTotals:Pe,actions:(0,C.jsxs)(C.Fragment,{children:[D.hasTelemetry&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,className:`h-7`,onClick:De,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,C.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,C.jsx)(_,{children:e(`detail.exportDiagnosticTooltip`)})]}),Ae&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,onClick:Oe,disabled:B,"aria-busy":B,className:`h-7`,children:[(0,C.jsx)(pe,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,C.jsx)(_,{children:e(`detail.reExecuteTooltip`)})]}),ke&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`sm`,onClick:Ee,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(je?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,C.jsx)(_,{children:e(`detail.cancelJobTooltip`)})]})]})}),k.omitted&&(0,C.jsx)(`p`,{role:`status`,className:`shrink-0 border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:e(`logViewer.retainedTail`)}),(0,C.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:u?(0,C.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,C.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>Te(e),"aria-pressed":L===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${L===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,C.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:L===`narrated`?(0,C.jsx)(le,{events:j,settled:D.status!==`running`&&D.status!==`queued`,durationRange:we,elapsedMs:D.duration_ms??null,variant:`page`}):$?(0,C.jsx)(f,{events:j,jobStatus:D.status,variant:`page`,onOpenRun:e=>T(`/jobs/${e}`)}):(0,C.jsx)(m,{events:j})})]}):$?(0,C.jsx)(f,{events:j,jobStatus:D.status,variant:`page`,onOpenRun:e=>T(`/jobs/${e}`)}):(0,C.jsx)(m,{events:j})}),Me&&(0,C.jsx)(ue,{jobId:D.id,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,pendingInterrupts:D.pendingInterrupts,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{E as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,n as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{m as o,r as ee}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as s}from"./createLucideIcon-DtODIU64.js";import{a as c,r as te,s as l}from"./useDesktop-BjLT0_EE.js";import{n as ne,ut as u}from"./TicketDetailModalContext-Dkwo2cDs.js";import{t as d}from"./chevron-up-6EFqEHBj.js";import{n as re}from"./file-text-C0blZHLh.js";import{a as ie,c as f,d as ae,i as p,l as m,n as oe,o as se,r as ce,s as le,t as ue,u as de}from"./InteractiveJobComposer-BO6ASN-2.js";import{t as fe}from"./download-C9wP_42h.js";import{t as pe}from"./rotate-ccw-DalJAQQX.js";import{t as h}from"./utils-BC4DHlz2.js";import{t as me}from"./formatDistanceToNow-NjPHBLfB.js";import{t as g}from"./button-4FS1ZDTp.js";import{G as he,J as _,Lt as v,X as y,Xt as b,q as x}from"./index-Ce4yZtKf.js";import{t as ge}from"./format-command-C0D9IPmV.js";var S=e(t(),1),C=n(),w=4;function _e({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,S.useState)(!1);if(e.length===0)return null;let a=e.length>=w&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,C.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,C.jsx)(T,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,C.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,C.jsx)(b,{className:`w-3 h-3`})]}),r&&e.length>=w&&(0,C.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,C.jsx)(d,{className:`w-3 h-3`})]})]})}function T({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,C.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,C.jsx)(`span`,{className:h(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,C.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,C.jsxs)(`span`,{className:h(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,C.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function E(){let{t:e}=s(`jobs`),{t}=s(`narration`),{id:n}=r(),{activeProjectId:d,projects:b}=te(),w=b.find(e=>e.id===d)?.provider,T=a(),{openTicketDetail:E}=ne(),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(()=>p([])),j=(0,S.useMemo)(()=>ce(k,e(`logViewer.retainedTail`)),[k,e]),[ve,M]=(0,S.useState)([]),[ye,N]=(0,S.useState)({}),[be,P]=(0,S.useState)([]),[xe,F]=(0,S.useState)(!0),[Se,I]=(0,S.useState)(!1),[L,Ce]=(0,S.useState)(ie),[we,R]=(0,S.useState)(null),Te=(0,S.useCallback)(e=>{Ce(e),se(e)},[]),z=D?.command??null;(0,S.useEffect)(()=>{if(!u||L!==`narrated`||!d||!z)return;let e=!1,t=`command=${encodeURIComponent(z)}`;try{Promise.resolve(fetch(`${c()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||R(t?.range??null)}).catch(()=>{e||R(null)})}catch{R(null)}return()=>{e=!0}},[d,z,L]);let[B,V]=(0,S.useState)(!1),H=(0,S.useRef)(!1),U=(0,S.useRef)(null);(0,S.useEffect)(()=>{H.current=!1,U.current=null,V(!1)},[n]),(0,S.useEffect)(()=>{if(!n)return;let e=new AbortController;K.current={events:[],omitted:!1},q.current&&cancelAnimationFrame(q.current),q.current=null,O(null),A(p([])),M([]),N({}),F(!0),I(!1);async function t(){try{let t=await fetch(`${c()}/jobs/${n}`,{signal:e.signal});if(t.status===404){I(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();if(e.signal.aborted)return;O(r.job),A(p(r.events))}catch(e){if(e.name===`AbortError`)return;I(!0)}finally{e.signal.aborted||F(!1)}}return t(),()=>e.abort()},[n,d]),(0,S.useEffect)(()=>{if(!D?.pipeline_id){P([]);return}let e=D.pipeline_id;fetch(`${c()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&P(e.jobs)}).catch(()=>{})},[D?.pipeline_id,D?.status]);let W=(0,S.useRef)(d);W.current=d;let G=(0,S.useRef)(null);G.current=D?.status??null;let K=(0,S.useRef)({events:[],omitted:!1}),q=(0,S.useRef)(null),J=(0,S.useCallback)(()=>{q.current=null;let e=K.current;e.events.length!==0&&(K.current={events:[],omitted:!1},A(t=>p([...t.events,...e.events],t.omitted||e.omitted)))},[]),Y=(0,S.useCallback)(e=>{if(!oe(e))return;let t=K.current;t.events.push(e),t.events.length>1e4&&(K.current=p(t.events,t.omitted)),q.current||=requestAnimationFrame(J)},[J]);(0,S.useEffect)(()=>()=>{q.current&&cancelAnimationFrame(q.current)},[]);let X=(0,S.useCallback)(e=>{let t=e;if(!(W.current&&t.projectId&&t.projectId!==W.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];M(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;N(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};Y(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,...typeof t.attemptId==`string`&&t.attemptId.trim()&&t.attemptId.length<=256?{attemptId:t.attemptId}:{}}),timestamp:t.timestamp};Y(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`runtime.continuation`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${c()}/jobs/${n}`).then(e=>e.json()).then(e=>O(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;N(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=G.current;O(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${c()}/jobs/${n}`).then(e=>e.json()).then(e=>O(e.job)).catch(()=>{})}}}},[n,Y]),{registerHandler:Z,unregisterHandler:Q}=ee();(0,S.useEffect)(()=>(Z(`job-detail-${n}`,X),()=>Q(`job-detail-${n}`)),[n,X,Z,Q]),(0,S.useEffect)(()=>{if(!n||!D||D.status!==`running`||D.hasTelemetry)return;let e=setInterval(()=>{fetch(`${c()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&O(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,D?.status,D?.hasTelemetry]);async function Ee(){if(!n)return;let t=await he({projectId:null,jobId:n});t.ok?l.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?l.error(e(`detail.toast.networkError`)):l.error(e(`detail.toast.failed`),{description:t.error})}async function De(){if(D)try{let t=await fetch(`${c()}/jobs/${D.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-${D.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){l.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Oe(){if(!(!D||H.current)){H.current=!0,V(!0),U.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${D.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${c()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":U.current},body:JSON.stringify({rerunOfJobId:D.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));U.current=null,l.success(e(`detail.toast.jobRequeued`)),T(`/jobs/${n.jobId}`)}catch(e){l.error(e.message)}finally{H.current=!1,V(!1)}}}if(xe)return(0,C.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,C.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,C.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(Se||!D)return(0,C.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,C.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,C.jsx)(g,{asChild:!0,variant:`outline`,size:`sm`,children:(0,C.jsxs)(i,{to:`/`,children:[(0,C.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let ke=D.status===`running`,Ae=D.status===`completed`||D.status===`failed`,je=!!D.interactive,Me=je&&ke,Ne=(D.tickets?.length??0)>0,$=D.command.startsWith(`loop:`),Pe=ae(be);return(0,C.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,C.jsxs)(`div`,{className:`px-4 pt-3 pb-2 space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,C.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,C.jsx)(v,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,C.jsx)(re,{className:`w-3 h-3`}),(0,C.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),Ne&&(0,C.jsx)(_e,{tickets:D.tickets??[],onTicketClick:E}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap min-w-0`,children:[(0,C.jsx)(`code`,{className:h(`font-mono text-foreground/90 truncate`,Ne?`text-xs text-muted-foreground`:`text-sm`),children:ge(D.command,w)}),(0,C.jsx)(`span`,{children:D.started_at?e(`detail.startedAgo`,{timeAgo:me(new Date(D.started_at),{addSuffix:!0,locale:o()})}):e(`detail.queuedWaiting`)}),D.model&&(0,C.jsx)(`span`,{className:`text-muted-foreground/40`,children:D.model})]})]}),(0,C.jsx)(de,{onOpenRun:e=>T(`/jobs/${e}`),job:D,events:j,phases:ye,phaseDefinitions:ve,projectId:d,variant:`page`,pipelineTotals:Pe,actions:(0,C.jsxs)(C.Fragment,{children:[D.hasTelemetry&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,className:`h-7`,onClick:De,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,C.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,C.jsx)(_,{children:e(`detail.exportDiagnosticTooltip`)})]}),Ae&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,onClick:Oe,disabled:B,"aria-busy":B,className:`h-7`,children:[(0,C.jsx)(pe,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,C.jsx)(_,{children:e(`detail.reExecuteTooltip`)})]}),ke&&(0,C.jsxs)(x,{children:[(0,C.jsx)(y,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`sm`,onClick:Ee,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(je?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,C.jsx)(_,{children:e(`detail.cancelJobTooltip`)})]})]})}),k.omitted&&(0,C.jsx)(`p`,{role:`status`,className:`shrink-0 border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:e(`logViewer.retainedTail`)}),(0,C.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:u?(0,C.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,C.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>Te(e),"aria-pressed":L===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${L===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,C.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:L===`narrated`?(0,C.jsx)(le,{events:j,settled:D.status!==`running`&&D.status!==`queued`,durationRange:we,elapsedMs:D.duration_ms??null,variant:`page`}):$?(0,C.jsx)(f,{events:j,jobStatus:D.status,variant:`page`,onOpenRun:e=>T(`/jobs/${e}`)}):(0,C.jsx)(m,{events:j})})]}):$?(0,C.jsx)(f,{events:j,jobStatus:D.status,variant:`page`,onOpenRun:e=>T(`/jobs/${e}`)}):(0,C.jsx)(m,{events:j})}),Me&&(0,C.jsx)(ue,{jobId:D.id,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,pendingInterrupts:D.pendingInterrupts,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{E as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{u as r}from"./chunk-OB3PAWPO-B1EMk45A.js";import{l as i,m as a,r as o}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as s,t as c}from"./createLucideIcon-DtODIU64.js";import{a as l,i as u,r as d,s as f}from"./useDesktop-BjLT0_EE.js";import{t as p}from"./circle-x-D2ttKotB.js";import{t as m}from"./trash-D8zYUmTg.js";import{t as h}from"./triangle-alert-Cxpn8bqr.js";import{t as g}from"./x-Bu7X_eR2.js";import{F as _,P as v,a as y,i as b,l as x,o as ee,r as te,t as ne}from"./dialog-DtdR05v1.js";import{n as re,t as ie}from"./lib-DWJfei6y.js";import{t as S}from"./formatDistanceToNow-NjPHBLfB.js";import{t as C}from"./button-4FS1ZDTp.js";import{A as ae,C as w,Ft as oe,J as T,Jt as E,X as D,q as O,qt as k,t as A}from"./index-IdGpV21X.js";import{t as j}from"./format-command-C0D9IPmV.js";import{t as M}from"./ExportDropdown-Bb1lHx3r.js";import{n as N,t as P}from"./job-time-BCL7wee9.js";var F={name:`git-compare-arrows`,size:24,node:[[`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`}]]};F.node;var I=c(F),L=e(t(),1),R=n();function z(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 B(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function V(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function H({label:e,a:t,b:n,highlight:r}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,R.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function U(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=s(`jobs`),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(!0),[c,u]=(0,L.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:m,resizeHandles:h,isFloating:y,guardBackdrop:b}=_();(0,L.useEffect)(()=>{let t=new AbortController;return fetch(`${l()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),o(!1))}),()=>t.abort()},[e]);function x(e,t){return(0,R.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,R.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,R.jsx)(E,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,R.jsx)(p,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,R.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:b(t),children:[(0,R.jsxs)(`div`,{ref:d,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:f,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between ${y?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,R.jsx)(g,{className:`w-4 h-4`})})]}),a&&(0,R.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,R.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),c&&(0,R.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:c})}),r&&(()=>{let[e,t]=r.jobs,i=U(e.durationMs,t.durationMs,!0),a=U(e.totalCostUsd,t.totalCostUsd,!0),o=U(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,R.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,R.jsx)(H,{label:n(`comparison.duration`),a:z(e.durationMs),b:z(t.durationMs),highlight:i}),(0,R.jsx)(H,{label:n(`comparison.cost`),a:B(e.totalCostUsd),b:B(t.totalCostUsd),highlight:a}),(0,R.jsx)(H,{label:n(`comparison.tokensOut`),a:V(e.tokensOut),b:V(t.tokensOut),highlight:o}),(0,R.jsx)(H,{label:n(`comparison.tokensIn`),a:V(e.tokensIn),b:V(t.tokensIn),highlight:null}),(0,R.jsx)(H,{label:n(`comparison.cacheRead`),a:V(e.tokensCacheRead),b:V(t.tokensCacheRead),highlight:null}),(0,R.jsx)(H,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,R.jsx)(H,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,R.jsx)(v,{handles:h})]})}var ce={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],ue={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=N(e),r=N(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=N(e);return t?S(t,{addSuffix:!0,locale:a()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=N(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var W=10;function G({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:o,onProposalDelete:c}){let{t:u}=s(`jobs`),p=r(),{activeProjectId:g,projects:re}=d(),ie=re.find(e=>e.id===g)?.provider,[S,w]=(0,L.useState)(null),[E,A]=(0,L.useState)(``),[M,N]=(0,L.useState)(``),[F,z]=(0,L.useState)(!1),[B,V]=(0,L.useState)(``),[H,U]=(0,L.useState)(``),[G,K]=(0,L.useState)(!1),[q,J]=(0,L.useState)(null),[Y,ve]=(0,L.useState)(W),[X,ye]=(0,L.useState)(!1),[Z,Q]=(0,L.useState)([]),[be,$]=(0,L.useState)(null),{panelRef:xe,panelStyle:Se,headerHandleProps:Ce,resizeHandles:we,isFloating:Te,guardBackdrop:Ee}=_();(0,L.useEffect)(()=>{ve(W)},[e.length]);function De(){ye(e=>!e),Q([])}function Oe(e){Q(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&&$(n),n})}let ke=e.filter(e=>S&&e.status!==S?!1:_e(P(e),E,M)),Ae=e.filter(e=>_e(P(e),B,H)).length;async function je(e){K(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),H&&(t.to=new Date(ge(H)).toISOString()));let n=await fetch(`${l()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();f.success(u(`recent.toast.cleared`,{count:e.deleted})),z(!1),V(``),U(``),a?.()}else f.error(u(`recent.toast.clearFailed`))}catch{f.error(u(`recent.toast.networkError`))}finally{K(!1)}}let Me=n?(0,R.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,R.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{className:`flex-1`,children:u(`recent.loadFailed`)}),i&&(0,R.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:u(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,R.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,R.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,R.jsx)(k,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,R.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:u(`recent.emptyTitle`)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:u(`recent.emptyDescription`)})]}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${S===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,R.jsx)(`button`,{type:`button`,onClick:()=>w(S===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${S===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterStatus`,{status:u(`statusName.${t}`),count:n})},t)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`date`,value:E,onChange:e=>A(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.fromDate`)}),(0,R.jsx)(`input`,{type:`date`,value:M,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.toDate`)}),(E||M)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{A(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:u(`recent.clear`)}),(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${X?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:De,children:(0,R.jsx)(I,{className:`w-3.5 h-3.5`})})}),(0,R.jsx)(T,{children:u(X?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,R.jsx)(m,{className:`w-3.5 h-3.5`})})}),(0,R.jsx)(T,{children:u(`recent.clearJobs`)})]})]})]}),X&&(0,R.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,R.jsxs)(`span`,{children:[Z.length===0&&u(`recent.selectTwoToCompare`),Z.length===1&&u(`recent.selectOneMore`),Z.length===2&&u(`recent.readyToCompare`)]}),Z.length===2&&(0,R.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>$(Z),children:u(`recent.compareAction`)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,R.jsx)(`span`,{className:`w-14`,children:u(`recent.colStatus`)}),(0,R.jsx)(`span`,{className:`flex-1 min-w-0`,children:u(`recent.colCommand`)}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,R.jsx)(`span`,{className:`w-14 text-right`,children:u(`recent.colDuration`)}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colTokens`)}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colCost`)}),(0,R.jsx)(`span`,{className:`w-20 text-right`,children:u(`recent.colStarted`)})]})]}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:ke.slice(0,Y).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),s=a?e.id.replace(`proposal:`,``):null,c=Z.includes(e.id),l=X&&!a&&Z.length===2&&!c,d=()=>{if(X&&!a){Oe(e.id);return}a&&s?o?.(s):p(`/jobs/${e.id}`)};return(0,R.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:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(`div`,{children:(0,R.jsx)(ae,{variant:t.variant,children:u(t.labelKey)})})}),(0,R.jsx)(T,{children:u(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,R.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:u(ue[e.priority].labelKey)}),e.profile_name&&(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.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,R.jsx)(T,{children:u(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(oe,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,R.jsxs)(T,{children:[u(`recent.pipelinePart`),e.depends_on_job_id&&` ${u(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,R.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:j(e.command,ie)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,R.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,R.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&s&&(0,R.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(),J(s)},title:u(`recent.deleteProposal`),children:(0,R.jsx)(m,{className:`w-3 h-3`})})]})]},e.id)})}),ke.length>Y&&(0,R.jsx)(`div`,{className:`pt-1 text-center`,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>ve(e=>e+W),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:u(`recent.loadMore`,{count:ke.length-Y})})}),F&&(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:Ee(()=>z(!1)),children:[(0,R.jsxs)(`div`,{ref:xe,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Se,children:[(0,R.jsxs)(`div`,{...Ce,className:Te?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold`,children:u(`recent.clearModal.title`)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:u(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,R.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:u(`recent.clearModal.clearAll`,{count:e.length})}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`recent.clearModal.orByRange`)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{type:`date`,value:B,onChange:e=>V(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.fromPlaceholder`)}),(0,R.jsx)(`input`,{type:`date`,value:H,onChange:e=>U(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.toPlaceholder`)})]}),(0,R.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!H,onClick:()=>je(`range`),children:B||H?u(`recent.clearModal.clearInRange`,{count:Ae}):u(`recent.clearModal.clearRange`)})]}),(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:u(`common:actions.cancel`)})]}),(0,R.jsx)(v,{handles:we})]}),(0,R.jsx)(ne,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,R.jsxs)(te,{className:`max-w-sm`,children:[(0,R.jsxs)(ee,{children:[(0,R.jsx)(x,{children:u(`recent.deleteProposalConfirm.title`)}),(0,R.jsx)(b,{children:u(`recent.deleteProposalConfirm.description`)})]}),(0,R.jsxs)(y,{children:[(0,R.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>J(null),children:u(`common:actions.cancel`)}),(0,R.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{q&&c?.(q),J(null)},children:u(`common:actions.delete`)})]})]})}),be&&(0,R.jsx)(se,{jobIds:be,onClose:()=>{$(null),Q([]),ye(!1)}})]})}var K={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 q(e){return`${i}/api/projects/${encodeURIComponent(e)}`}function J(){let[e,t]=(0,L.useState)(!1),{registerHandler:n,unregisterHandler:r}=o(),{t:i}=s(`jobs`),{activeProjectId:a}=d(),{recentJobs:c}=A(a),{data:p,isFirstLoad:m,isLoading:h,error:g,refresh:_}=u({namespace:`jobs`,projectId:a,initialValue:c,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${q(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4});(0,L.useEffect)(()=>(n(`jobs-runtime-continuation`,e=>{let t=e;t.type===`runtime.continuation`&&t.projectId===a&&_()}),()=>r(`jobs-runtime-continuation`)),[a,_,n,r]);let{data:v,isFirstLoad:b,isLoading:S,error:oe,refresh:T}=u({namespace:`proposals`,projectId:a,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${q(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),E={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},D=v.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:E[e.status]??`queued`})),O=[...p,...D].sort((e,t)=>(N(P(t))?.getTime()??0)-(N(P(e))?.getTime()??0)),[k,j]=(0,L.useState)(null),F=(0,L.useCallback)(async e=>{try{let t=await fetch(`${l()}/propose/${e}`);if(!t.ok)return;let n=await t.json();j(n.proposal)}catch{}},[]),I=(0,L.useCallback)(async e=>{try{(await fetch(`${l()}/propose/${e}`,{method:`DELETE`})).ok&&(f.success(i(`page.proposalDeleted`)),await T())}catch{}},[T,i]);return(0,R.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold`,children:i(`page.title`)}),(0,R.jsx)(M,{baseUrl:`${l()}/jobs/export`,label:i(`page.exportJobs`)})]}),a&&(0,R.jsxs)(`details`,{className:`mb-4 rounded-lg border border-border`,onToggle:e=>t(e.currentTarget.open),children:[(0,R.jsx)(`summary`,{className:`cursor-pointer p-3 text-sm`,children:i(`agentRuntime:runs.title`)}),e&&(0,R.jsx)(w,{projectId:a})]}),(0,R.jsx)(G,{jobs:O,isLoading:m||b||h||S,error:g??oe,onRetry:()=>{Promise.all([_(),T()])},onJobsCleared:_,onProposalClick:F,onProposalDelete:I}),(0,R.jsx)(ne,{open:k!==null,onOpenChange:e=>!e&&j(null),children:(0,R.jsx)(te,{className:`max-w-3xl glass-card`,children:k&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ee,{children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(x,{className:`flex-1 min-w-0`,children:i(`page.proposal.title`)}),(0,R.jsx)(ae,{variant:k.status===`created`?`success`:k.status===`cancelled`?`destructive`:`secondary`,children:i(K[k.status]??`page.proposal.status.unknown`,{status:k.status})})]})}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:k.idea}),k.result_markdown?(0,R.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,R.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,R.jsx)(re,{remarkPlugins:[ie],children:k.result_markdown})})}):(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:i(`page.proposal.noContent`)}),k.issue_url&&(0,R.jsxs)(`div`,{className:`text-xs`,children:[i(`page.proposal.githubIssue`),` `,(0,R.jsx)(`a`,{href:k.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:k.issue_url})]}),(0,R.jsxs)(y,{children:[(0,R.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{I(k.id),j(null)},children:i(`common:actions.delete`)}),(0,R.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>j(null),children:i(`common:actions.close`)})]})]})})})]})}export{J as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{u as r}from"./chunk-OB3PAWPO-B1EMk45A.js";import{l as i,m as a,r as o}from"./useSharedWebSocket-Bj4LMp7b.js";import{n as s,t as c}from"./createLucideIcon-DtODIU64.js";import{a as l,i as u,r as d,s as f}from"./useDesktop-BjLT0_EE.js";import{t as p}from"./circle-x-D2ttKotB.js";import{t as m}from"./trash-D8zYUmTg.js";import{t as h}from"./triangle-alert-Cxpn8bqr.js";import{t as g}from"./x-Bu7X_eR2.js";import{F as _,P as v,a as y,i as b,l as x,o as ee,r as te,t as ne}from"./dialog-DtdR05v1.js";import{n as re,t as ie}from"./lib-DWJfei6y.js";import{t as S}from"./formatDistanceToNow-NjPHBLfB.js";import{t as C}from"./button-4FS1ZDTp.js";import{A as ae,C as w,Ft as oe,J as T,Jt as E,X as D,q as O,qt as k,t as A}from"./index-Ce4yZtKf.js";import{t as j}from"./format-command-C0D9IPmV.js";import{t as M}from"./ExportDropdown-Bb1lHx3r.js";import{n as N,t as P}from"./job-time-BCL7wee9.js";var F={name:`git-compare-arrows`,size:24,node:[[`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`}]]};F.node;var I=c(F),L=e(t(),1),R=n();function z(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 B(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function V(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function H({label:e,a:t,b:n,highlight:r}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,R.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function U(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=s(`jobs`),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(!0),[c,u]=(0,L.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:m,resizeHandles:h,isFloating:y,guardBackdrop:b}=_();(0,L.useEffect)(()=>{let t=new AbortController;return fetch(`${l()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),o(!1))}),()=>t.abort()},[e]);function x(e,t){return(0,R.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,R.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,R.jsx)(E,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,R.jsx)(p,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,R.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:b(t),children:[(0,R.jsxs)(`div`,{ref:d,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:f,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between ${y?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,R.jsx)(g,{className:`w-4 h-4`})})]}),a&&(0,R.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,R.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),c&&(0,R.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:c})}),r&&(()=>{let[e,t]=r.jobs,i=U(e.durationMs,t.durationMs,!0),a=U(e.totalCostUsd,t.totalCostUsd,!0),o=U(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,R.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,R.jsx)(H,{label:n(`comparison.duration`),a:z(e.durationMs),b:z(t.durationMs),highlight:i}),(0,R.jsx)(H,{label:n(`comparison.cost`),a:B(e.totalCostUsd),b:B(t.totalCostUsd),highlight:a}),(0,R.jsx)(H,{label:n(`comparison.tokensOut`),a:V(e.tokensOut),b:V(t.tokensOut),highlight:o}),(0,R.jsx)(H,{label:n(`comparison.tokensIn`),a:V(e.tokensIn),b:V(t.tokensIn),highlight:null}),(0,R.jsx)(H,{label:n(`comparison.cacheRead`),a:V(e.tokensCacheRead),b:V(t.tokensCacheRead),highlight:null}),(0,R.jsx)(H,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,R.jsx)(H,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,R.jsx)(v,{handles:h})]})}var ce={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],ue={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=N(e),r=N(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=N(e);return t?S(t,{addSuffix:!0,locale:a()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=N(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var W=10;function G({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:o,onProposalDelete:c}){let{t:u}=s(`jobs`),p=r(),{activeProjectId:g,projects:re}=d(),ie=re.find(e=>e.id===g)?.provider,[S,w]=(0,L.useState)(null),[E,A]=(0,L.useState)(``),[M,N]=(0,L.useState)(``),[F,z]=(0,L.useState)(!1),[B,V]=(0,L.useState)(``),[H,U]=(0,L.useState)(``),[G,K]=(0,L.useState)(!1),[q,J]=(0,L.useState)(null),[Y,ve]=(0,L.useState)(W),[X,ye]=(0,L.useState)(!1),[Z,Q]=(0,L.useState)([]),[be,$]=(0,L.useState)(null),{panelRef:xe,panelStyle:Se,headerHandleProps:Ce,resizeHandles:we,isFloating:Te,guardBackdrop:Ee}=_();(0,L.useEffect)(()=>{ve(W)},[e.length]);function De(){ye(e=>!e),Q([])}function Oe(e){Q(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&&$(n),n})}let ke=e.filter(e=>S&&e.status!==S?!1:_e(P(e),E,M)),Ae=e.filter(e=>_e(P(e),B,H)).length;async function je(e){K(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),H&&(t.to=new Date(ge(H)).toISOString()));let n=await fetch(`${l()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();f.success(u(`recent.toast.cleared`,{count:e.deleted})),z(!1),V(``),U(``),a?.()}else f.error(u(`recent.toast.clearFailed`))}catch{f.error(u(`recent.toast.networkError`))}finally{K(!1)}}let Me=n?(0,R.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,R.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,R.jsx)(`span`,{className:`flex-1`,children:u(`recent.loadFailed`)}),i&&(0,R.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:u(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,R.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,R.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,R.jsx)(k,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,R.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:u(`recent.emptyTitle`)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:u(`recent.emptyDescription`)})]}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${S===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,R.jsx)(`button`,{type:`button`,onClick:()=>w(S===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${S===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterStatus`,{status:u(`statusName.${t}`),count:n})},t)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`date`,value:E,onChange:e=>A(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.fromDate`)}),(0,R.jsx)(`input`,{type:`date`,value:M,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.toDate`)}),(E||M)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{A(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:u(`recent.clear`)}),(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${X?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:De,children:(0,R.jsx)(I,{className:`w-3.5 h-3.5`})})}),(0,R.jsx)(T,{children:u(X?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,R.jsx)(m,{className:`w-3.5 h-3.5`})})}),(0,R.jsx)(T,{children:u(`recent.clearJobs`)})]})]})]}),X&&(0,R.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,R.jsxs)(`span`,{children:[Z.length===0&&u(`recent.selectTwoToCompare`),Z.length===1&&u(`recent.selectOneMore`),Z.length===2&&u(`recent.readyToCompare`)]}),Z.length===2&&(0,R.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>$(Z),children:u(`recent.compareAction`)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,R.jsx)(`span`,{className:`w-14`,children:u(`recent.colStatus`)}),(0,R.jsx)(`span`,{className:`flex-1 min-w-0`,children:u(`recent.colCommand`)}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,R.jsx)(`span`,{className:`w-14 text-right`,children:u(`recent.colDuration`)}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colTokens`)}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colCost`)}),(0,R.jsx)(`span`,{className:`w-20 text-right`,children:u(`recent.colStarted`)})]})]}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:ke.slice(0,Y).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),s=a?e.id.replace(`proposal:`,``):null,c=Z.includes(e.id),l=X&&!a&&Z.length===2&&!c,d=()=>{if(X&&!a){Oe(e.id);return}a&&s?o?.(s):p(`/jobs/${e.id}`)};return(0,R.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:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(`div`,{children:(0,R.jsx)(ae,{variant:t.variant,children:u(t.labelKey)})})}),(0,R.jsx)(T,{children:u(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,R.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:u(ue[e.priority].labelKey)}),e.profile_name&&(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.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,R.jsx)(T,{children:u(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,R.jsxs)(O,{children:[(0,R.jsx)(D,{asChild:!0,children:(0,R.jsx)(oe,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,R.jsxs)(T,{children:[u(`recent.pipelinePart`),e.depends_on_job_id&&` ${u(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,R.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:j(e.command,ie)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,R.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,R.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,R.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&s&&(0,R.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(),J(s)},title:u(`recent.deleteProposal`),children:(0,R.jsx)(m,{className:`w-3 h-3`})})]})]},e.id)})}),ke.length>Y&&(0,R.jsx)(`div`,{className:`pt-1 text-center`,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>ve(e=>e+W),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:u(`recent.loadMore`,{count:ke.length-Y})})}),F&&(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:Ee(()=>z(!1)),children:[(0,R.jsxs)(`div`,{ref:xe,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Se,children:[(0,R.jsxs)(`div`,{...Ce,className:Te?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold`,children:u(`recent.clearModal.title`)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:u(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,R.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:u(`recent.clearModal.clearAll`,{count:e.length})}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`recent.clearModal.orByRange`)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{type:`date`,value:B,onChange:e=>V(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.fromPlaceholder`)}),(0,R.jsx)(`input`,{type:`date`,value:H,onChange:e=>U(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.toPlaceholder`)})]}),(0,R.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!H,onClick:()=>je(`range`),children:B||H?u(`recent.clearModal.clearInRange`,{count:Ae}):u(`recent.clearModal.clearRange`)})]}),(0,R.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:u(`common:actions.cancel`)})]}),(0,R.jsx)(v,{handles:we})]}),(0,R.jsx)(ne,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,R.jsxs)(te,{className:`max-w-sm`,children:[(0,R.jsxs)(ee,{children:[(0,R.jsx)(x,{children:u(`recent.deleteProposalConfirm.title`)}),(0,R.jsx)(b,{children:u(`recent.deleteProposalConfirm.description`)})]}),(0,R.jsxs)(y,{children:[(0,R.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>J(null),children:u(`common:actions.cancel`)}),(0,R.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{q&&c?.(q),J(null)},children:u(`common:actions.delete`)})]})]})}),be&&(0,R.jsx)(se,{jobIds:be,onClose:()=>{$(null),Q([]),ye(!1)}})]})}var K={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 q(e){return`${i}/api/projects/${encodeURIComponent(e)}`}function J(){let[e,t]=(0,L.useState)(!1),{registerHandler:n,unregisterHandler:r}=o(),{t:i}=s(`jobs`),{activeProjectId:a}=d(),{recentJobs:c}=A(a),{data:p,isFirstLoad:m,isLoading:h,error:g,refresh:_}=u({namespace:`jobs`,projectId:a,initialValue:c,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${q(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4});(0,L.useEffect)(()=>(n(`jobs-runtime-continuation`,e=>{let t=e;t.type===`runtime.continuation`&&t.projectId===a&&_()}),()=>r(`jobs-runtime-continuation`)),[a,_,n,r]);let{data:v,isFirstLoad:b,isLoading:S,error:oe,refresh:T}=u({namespace:`proposals`,projectId:a,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${q(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),E={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},D=v.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:E[e.status]??`queued`})),O=[...p,...D].sort((e,t)=>(N(P(t))?.getTime()??0)-(N(P(e))?.getTime()??0)),[k,j]=(0,L.useState)(null),F=(0,L.useCallback)(async e=>{try{let t=await fetch(`${l()}/propose/${e}`);if(!t.ok)return;let n=await t.json();j(n.proposal)}catch{}},[]),I=(0,L.useCallback)(async e=>{try{(await fetch(`${l()}/propose/${e}`,{method:`DELETE`})).ok&&(f.success(i(`page.proposalDeleted`)),await T())}catch{}},[T,i]);return(0,R.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold`,children:i(`page.title`)}),(0,R.jsx)(M,{baseUrl:`${l()}/jobs/export`,label:i(`page.exportJobs`)})]}),a&&(0,R.jsxs)(`details`,{className:`mb-4 rounded-lg border border-border`,onToggle:e=>t(e.currentTarget.open),children:[(0,R.jsx)(`summary`,{className:`cursor-pointer p-3 text-sm`,children:i(`agentRuntime:runs.title`)}),e&&(0,R.jsx)(w,{projectId:a})]}),(0,R.jsx)(G,{jobs:O,isLoading:m||b||h||S,error:g??oe,onRetry:()=>{Promise.all([_(),T()])},onJobsCleared:_,onProposalClick:F,onProposalDelete:I}),(0,R.jsx)(ne,{open:k!==null,onOpenChange:e=>!e&&j(null),children:(0,R.jsx)(te,{className:`max-w-3xl glass-card`,children:k&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ee,{children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(x,{className:`flex-1 min-w-0`,children:i(`page.proposal.title`)}),(0,R.jsx)(ae,{variant:k.status===`created`?`success`:k.status===`cancelled`?`destructive`:`secondary`,children:i(K[k.status]??`page.proposal.status.unknown`,{status:k.status})})]})}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:k.idea}),k.result_markdown?(0,R.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,R.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,R.jsx)(re,{remarkPlugins:[ie],children:k.result_markdown})})}):(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:i(`page.proposal.noContent`)}),k.issue_url&&(0,R.jsxs)(`div`,{className:`text-xs`,children:[i(`page.proposal.githubIssue`),` `,(0,R.jsx)(`a`,{href:k.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:k.issue_url})]}),(0,R.jsxs)(y,{children:[(0,R.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{I(k.id),j(null)},children:i(`common:actions.delete`)}),(0,R.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>j(null),children:i(`common:actions.close`)})]})]})})})]})}export{J as default};