specrails-desktop 2.13.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-D0-P3PsD.js → ActivityFeedPage-BBGvhMX5.js} +1 -1
- package/client/dist/assets/AgentsPage-CSrs9kuV.js +86 -0
- package/client/dist/assets/{AnalyticsPage-CgaEg-lx.js → AnalyticsPage-B011XilA.js} +1 -1
- package/client/dist/assets/{BarChart-D9vfeilz.js → BarChart-zCFHhnbZ.js} +2 -2
- package/client/dist/assets/CodePage-MB0JiLis.js +2 -0
- package/client/dist/assets/{DesktopAnalyticsPage-C6Qccm5E.js → DesktopAnalyticsPage-DlrcBWPo.js} +1 -1
- package/client/dist/assets/{DocsDialog-BAmtk9Jc.js → DocsDialog-B8mSbQhA.js} +2 -2
- package/client/dist/assets/DocsPage-D7t2Bc-K.js +11 -0
- package/client/dist/assets/{ExportDropdown-DMJ__Yui.js → ExportDropdown-ClTut9WA.js} +1 -1
- package/client/dist/assets/{IntegrationsPage-CP2VcOpr.js → IntegrationsPage-CgJf4uLW.js} +3 -3
- package/client/dist/assets/JobDetailPage-DlyLLI4l.js +16 -0
- package/client/dist/assets/JobsPage-mbez97dP.js +1 -0
- package/client/dist/assets/LoopBuilderPage-CScd8wyY.js +7 -0
- package/client/dist/assets/LoopsPage-mBDRcEzq.js +1 -0
- package/client/dist/assets/{dist-js-_oLAsZQ4.js → dist-js-BHJ5LpTw.js} +1 -1
- package/client/dist/assets/{dist-js-o4iwbCuN.js → dist-js-Ca7dsMhN.js} +1 -1
- package/client/dist/assets/{index-DrFJinsI.css → index-ByhYcYLV.css} +1 -1
- package/client/dist/assets/{index-QEeqwz4v.js → index-CEunZ8kJ.js} +12 -11
- package/client/dist/assets/{lib-CVrpo1ac.js → lib-3_pPhUqA.js} +1 -1
- package/client/dist/assets/loops-BYNUJVyD.js +1 -0
- package/client/dist/assets/loops-B_gS4Pqu.js +1 -0
- package/client/dist/assets/loops-B_w7STrw.js +1 -0
- package/client/dist/assets/loops-DE-2cmLw.js +1 -0
- package/client/dist/assets/loops-D_ZxkD4l.js +1 -0
- package/client/dist/assets/loops-DfGadne0.js +1 -0
- package/client/dist/assets/loops-Fv4Bs-9A.js +1 -0
- package/client/dist/assets/loops-mcoeFMat.js +1 -0
- package/client/dist/assets/{upload-Dn9N1ESQ.js → upload-DsygVwLQ.js} +1 -1
- package/client/dist/assets/{value-Bd3Cf9Sr.js → value-B5mYukkD.js} +1 -1
- package/client/dist/index.html +3 -3
- package/package.json +1 -1
- package/server/dist/loop-command-catalog.js +87 -0
- package/server/dist/loop-constants.js +15 -1
- package/server/dist/loop-graph.js +21 -0
- package/server/dist/loop-templates-ported.js +671 -0
- package/server/dist/loop-templates.js +36 -1
- package/server/dist/loops-router.js +1 -0
- package/server/dist/project-router-loop-runs.js +15 -2
- package/server/dist/rails-router.js +9 -0
- package/client/dist/assets/AgentsPage-BZa3lhQM.js +0 -86
- package/client/dist/assets/CodePage-2GUsF_JS.js +0 -2
- package/client/dist/assets/DocsPage-CJwnpB57.js +0 -11
- package/client/dist/assets/JobDetailPage-Bk6tQTew.js +0 -16
- package/client/dist/assets/JobsPage-BvbeqWjS.js +0 -1
- package/client/dist/assets/LoopBuilderPage-BS3enu9N.js +0 -7
- package/client/dist/assets/LoopsPage-B0pgvoky.js +0 -2
- package/client/dist/assets/loops-B1ZQCKEk.js +0 -1
- package/client/dist/assets/loops-Bp5yTSic.js +0 -1
- package/client/dist/assets/loops-BvoL_LAc.js +0 -1
- package/client/dist/assets/loops-BwgehdXY.js +0 -1
- package/client/dist/assets/loops-CMLUqUpc.js +0 -1
- package/client/dist/assets/loops-CW69VvTI.js +0 -1
- package/client/dist/assets/loops-DkV2RhEb.js +0 -1
- package/client/dist/assets/loops-arQ602Zm.js +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{Bt as t,C as n,Ct as r,Dt as i,E as a,Et as o,It as s,L as c,Ot as l,Qt as u,R as d,Rt as f,St as p,Vt as m,X as h,Xt as g,Z as _,Zt as v,_ as y,_n as b,bn as x,bt as S,ct as C,dn as w,et as ee,fn as T,g as E,gn as te,hn as ne,l as D,o as O,u as k,w as A,wt as j,yt as re,z as M}from"./index-CEunZ8kJ.js";import{t as N}from"./lib-3_pPhUqA.js";import{t as ie}from"./format-command-CMsBTOPN.js";var P=s(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),F=s(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),I=e(x(),1),L=v();function ae({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,L.jsx)(`div`,{className:`flex items-center`,children:t.map((r,i)=>{let o=e[r.key]??`idle`,s=i<t.length-1?e[t[i+1].key]??`idle`:null;return(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,L.jsx)(R,{state:o}),(0,L.jsx)(`span`,{className:M(`text-xs font-medium transition-colors`,o===`running`?`text-blue-400 aurora-light:text-accent-info`:o===`done`?`text-emerald-400 aurora-light:text-accent-success`:o===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:r.label})]})}),(0,L.jsxs)(A,{side:`bottom`,className:`max-w-[200px]`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,L.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),s!==null&&(0,L.jsx)(`div`,{className:M(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,s===`done`||o===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:s===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},r.key)})})}function R({state:e}){return(0,L.jsxs)(`div`,{className:M(`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,L.jsx)(C,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,L.jsx)(j,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,L.jsx)(r,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,L.jsx)(p,{className:`w-6 h-6 text-muted-foreground/20`})]})}function oe(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function se(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 ce=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function z(e){return e.length>40?`${e.slice(0,39)}…`:e}function B(e){return typeof e!=`string`||e.length===0?``:z(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function V(e){return typeof e!=`string`||e.length===0?``:z(e.trim().split(/\s+/)[0]??``)}function H(e){if(typeof e!=`string`)return``;try{let t=JSON.parse(e)?.command;if(Array.isArray(t))return V(t.filter(e=>typeof e==`string`).join(` `));if(typeof t==`string`)return V(t)}catch{}return``}function U(e,t){let n=t??{},r=B(n.file_path??n.path);switch(e){case`Edit`:case`MultiEdit`:case`NotebookEdit`:case`Update`:return{step:!0,actionKey:`editing`,actionArg:r};case`Write`:case`create`:return{step:!0,actionKey:`writing`,actionArg:r};case`Read`:return{step:!0,actionKey:`reading`,actionArg:r};case`Grep`:case`Glob`:case`search`:return{step:!0,actionKey:`searching`,actionArg:z(String(n.pattern??n.query??``))};case`Bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:V(n.command)};default:return{step:!0,actionKey:`working`}}}function W(e){let t=e.event_type,n={};try{let t=JSON.parse(e.payload);t&&typeof t==`object`&&!Array.isArray(t)&&(n=t)}catch{}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=e.filter(e=>e?.type===`tool_use`);if(t.length>0){let e=t[t.length-1];return{...U(e.name,e.input),stepCount:t.length}}if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}return{step:!0}}if(t===`tool_use`)return U(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:V(e?.command)||H(e?.arguments)||(typeof e?.name==`string`?z(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}var G={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function K(e,t){if(t.type===`reset`)return G;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=W(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function le({job:e,events:t,defaultOpen:n=!0,pipelineTotals:i,phases:a,phaseDefinitions:o}){let{t:s}=T(`jobs`),[c,u]=(0,I.useState)(n),d=(0,I.useMemo)(()=>se(t),[t]),f=e.status===`running`,p=e.status===`completed`,[m,h]=(0,I.useState)(()=>Date.now());(0,I.useEffect)(()=>{if(!f)return;let e=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(e)},[f]);let[g,_]=(0,I.useReducer)(K,G),v=(0,I.useRef)(e.id);(0,I.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:t})},[e.id,t]);let[y,b]=(0,I.useState)(!0);(0,I.useEffect)(()=>{if(!f)return;b(!0);let e=window.setTimeout(()=>b(!1),8e3);return()=>window.clearTimeout(e)},[f,e.id]);let x=e.finished_at?oe(e.started_at,e.finished_at):f?oe(e.started_at,m):`—`,S=!!e.total_cost_usd_estimated,w=e.total_cost_usd==null?null:`${S?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ee=e.num_turns==null?null:String(e.num_turns),E=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),te=E==null?null:`${(E/1e3).toFixed(1)}k`,ne=(0,I.useMemo)(()=>!a||!o?null:o.find(e=>a[e.key]===`running`)?.label??null,[a,o]),D=f&&g.steps===0?`connecting`:g.actionKey||`thinking`,O=ce.has(D)&&g.actionArg!==``,k=ce.has(D)&&!O?`working`:D,A=O?s(`statusPanel.activity.${k}`,{arg:g.actionArg}):s(`statusPanel.activity.${k}`),re=ne??(f&&g.steps===0?s(`statusPanel.activity.starting`):null),N=g.steps>0?s(`statusPanel.steps`,{count:g.steps}):null,ie=s(f?`statusPanel.inProgress`:p?`statusPanel.completed`:`statusPanel.failed`),P=f?`border-accent-info/20 bg-accent-info/5`:p?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,F=f?C:p?j:r,ae=f?`w-4 h-4 text-accent-info shrink-0 animate-spin`:p?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,L.jsxs)(`div`,{className:M(`mx-4 my-2 rounded-xl border transition-colors duration-500`,P),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>u(!c),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,L.jsx)(F,{className:ae,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:ie}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`tabular-nums`,children:x}),f?N&&(0,L.jsx)(`span`,{className:`tabular-nums`,children:N}):(0,L.jsxs)(L.Fragment,{children:[w&&(0,L.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:w}),d.length>0&&(0,L.jsx)(`span`,{children:s(`statusPanel.filesCount`,{count:d.length})})]})]}),(0,L.jsx)(l,{className:M(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,c&&`rotate-180`)})]}),c&&(0,L.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:f?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:s(`statusPanel.zoneInProgress`)}),(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[s(`statusPanel.duration`),(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:s(`statusPanel.liveTooltip`),"aria-label":s(`statusPanel.liveTooltip`)})]}),(0,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:x})]}),(0,L.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,L.jsx)(C,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),re&&(0,L.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:re}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:A}),N&&(0,L.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,N]})]})]}),y&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:s(`statusPanel.explainer`)}),(0,L.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:s(`statusPanel.zoneFinalPending`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,L.jsx)(Y,{label:s(`statusPanel.cost`),caption:s(`statusPanel.pendingCaption`),tooltip:s(`statusPanel.costTooltip`)}),(0,L.jsx)(Y,{label:s(`statusPanel.turns`),caption:s(`statusPanel.pendingCaption`),tooltip:s(`statusPanel.pendingTooltip`)}),(0,L.jsx)(Y,{label:s(`statusPanel.tokens`),caption:s(`statusPanel.pendingCaption`),tooltip:s(`statusPanel.pendingTooltip`)})]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:s(`statusPanel.zoneFinal`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,L.jsx)(q,{label:s(`statusPanel.duration`),value:x}),(0,L.jsx)(J,{label:s(`statusPanel.cost`),value:w,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:s(`statusPanel.notAvailable`)}),(0,L.jsx)(J,{label:s(`statusPanel.turns`),value:ee,naCaption:s(`statusPanel.notAvailable`)}),(0,L.jsx)(J,{label:s(`statusPanel.tokens`),value:te,naCaption:s(`statusPanel.notAvailable`)})]}),i&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:s(`statusPanel.pipelineTotal`,{count:i.jobCount})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(q,{label:s(`statusPanel.totalCost`),value:`$${i.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,L.jsx)(q,{label:s(`statusPanel.totalTokens`),value:`${((i.totalTokensIn+i.totalTokensOut+i.totalTokensCacheRead+i.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),d.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:s(`statusPanel.filesModified`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,L.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function q({label:e,value:t,valueClass:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:M(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function J({label:e,value:t,valueClass:n,naCaption:r}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,L.jsx)(`p`,{className:M(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function Y({label:e,caption:t,tooltip:n}){return(0,L.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,L.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,L.jsx)(P,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,L.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var X=4;function ue({tickets:e,onTicketClick:t}){let{t:n}=T(`jobs`),[r,i]=(0,I.useState)(!1);if(e.length===0)return null;let a=e.length>=X&&!r?e.slice(0,1):e,s=e.length-a.length;return(0,L.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,L.jsx)(Z,{ticket:e,onClick:()=>t(e.id)},e.id)),s>0&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:s}),(0,L.jsx)(l,{className:`w-3 h-3`})]}),r&&e.length>=X&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,L.jsx)(o,{className:`w-3 h-3`})]})]})}function Z({ticket:e,onClick:t}){let{t:n}=T(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,L.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,L.jsx)(`span`,{className:M(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,L.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,L.jsxs)(`span`,{className:M(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,L.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function Q(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function de(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:Q(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(m.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${m.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function $(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 fe(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 pe({events:e,isLoading:t}){let{t:n,i18n:r}=T(`jobs`),[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)(!0),[c,u]=(0,I.useState)(new Set),f=(0,I.useRef)(null),p=(0,I.useRef)(null),{processedLines:m,groups:h,totalLines:g}=(0,I.useMemo)(()=>{let t=e.map((e,t)=>de(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
|
|
2
|
+
`+e.content:n.push({...e})}let r=$(n);return{processedLines:r,groups:fe(r),totalLines:r.length}},[e,r.language]),v=(0,I.useMemo)(()=>{if(!i)return g;let e=i.toLowerCase();return m.filter(t=>t.content.toLowerCase().includes(e)).length},[i,m,g]),y=(0,I.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,I.useEffect)(()=>{o&&y()},[e.length,o,y]);function b(){let e=p.current;e&&s(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function x(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.loading`)})}):g===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.empty`)})}):(0,L.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,L.jsx)(_,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,L.jsx)(O,{placeholder:n(`logViewer.filterPlaceholder`),value:i,onChange:e=>a(e.target.value),className:`pl-7 h-7`})]}),(0,L.jsx)(d,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=m.map(e=>e.content).join(`
|
|
3
|
+
`);navigator.clipboard.writeText(e).then(()=>{w.success(n(`logViewer.copySuccess`))}).catch(()=>{w.error(n(`logViewer.copyFailed`))})},children:(0,L.jsx)(S,{className:`w-3.5 h-3.5`})}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`logViewer.lineCount`,{filtered:v,total:g})})]}),(0,L.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:b,children:[h.map(e=>(0,L.jsx)(me,{group:e,filter:i,collapsed:c.has(e.key),onToggle:()=>x(e.key)},e.key)),(0,L.jsx)(`div`,{ref:f})]}),!o&&(0,L.jsxs)(d,{size:`sm`,variant:`secondary`,onClick:()=>{s(!0),y()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,L.jsx)(l,{className:`w-3 h-3`}),n(`logViewer.jumpToBottom`)]})]})}var me=(0,I.memo)(function({group:e,filter:t,collapsed:n,onToggle:r}){let{t:a}=T(`jobs`),o=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,L.jsx)(`div`,{children:o.map((e,t)=>(0,L.jsx)(ge,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,L.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:r,className:M(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,L.jsx)(i,{className:M(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,L.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,L.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,L.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,L.jsx)(ge,{line:e,even:t%2==0},e.id))})]})}),he=[N],ge=(0,I.memo)(function({line:e,even:t}){let n=e.type===`assistant`,r=e.type===`diff-add`,i=e.type===`diff-remove`,a=e.type===`diff-meta`,o=e.type===`diff-hunk`;return(0,L.jsxs)(`div`,{className:M(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(r||i||a||o)&&(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`,r&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,i&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,a&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,o&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),n?(0,L.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
|
+
prose-p:my-1 prose-p:leading-relaxed
|
|
5
|
+
prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
|
|
6
|
+
prose-ul:my-1 prose-ol:my-1 prose-li:my-0
|
|
7
|
+
prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
|
|
8
|
+
prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
|
|
9
|
+
prose-strong:text-foreground prose-em:text-foreground/70
|
|
10
|
+
prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
|
|
11
|
+
prose-table:my-2 prose-table:text-[11px]
|
|
12
|
+
prose-thead:border-border prose-thead:bg-muted/30
|
|
13
|
+
prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
|
|
14
|
+
prose-td:px-3 prose-td:py-1.5 prose-td:border-border
|
|
15
|
+
prose-tr:border-border
|
|
16
|
+
text-foreground/80`,children:(0,L.jsx)(y,{remarkPlugins:[E],rehypePlugins:he,children:e.content})}):(0,L.jsx)(`span`,{className:M(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 aurora-light:text-accent-info text-[11px]`,e.type===`stderr`&&`text-orange-400 aurora-light:text-accent-warning`,e.type===`result`&&`text-emerald-400 aurora-light:text-accent-success font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,r&&`text-emerald-400 aurora-light:text-accent-success`,i&&`text-red-400 aurora-light:text-destructive`,a&&`text-accent-primary/80`,o&&`text-accent-info/80`),children:e.content})]})}),_e={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function ve(){let{t:e}=T(`jobs`),{id:r}=b(),{activeProjectId:o,projects:s}=f(),l=s.find(e=>e.id===o)?.provider,p=te(),{openTicketDetail:m}=D(),[_,v]=(0,I.useState)(null),[y,x]=(0,I.useState)([]),[S,E]=(0,I.useState)([]),[O,N]=(0,I.useState)({}),[P,R]=(0,I.useState)([]),[oe,se]=(0,I.useState)(!0),[ce,z]=(0,I.useState)(!1),[B,V]=(0,I.useState)(null),[H,U]=(0,I.useState)(!1),[W,G]=(0,I.useState)(``),[K,q]=(0,I.useState)(!1),[J,Y]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!r)return;let e=new AbortController;v(null),x([]),E([]),N({}),se(!0),z(!1);async function t(){try{let t=await fetch(`${u()}/jobs/${r}`,{signal:e.signal});if(t.status===404){z(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();v(n.job),x(n.events)}catch(e){if(e.name===`AbortError`)return;z(!0)}finally{e.signal.aborted||se(!1)}}return t(),()=>e.abort()},[r,o]),(0,I.useEffect)(()=>{if(!_?.pipeline_id){R([]);return}let e=_.pipeline_id;fetch(`${u()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&R(e.jobs)}).catch(()=>{})},[_?.pipeline_id,_?.status]);let X=(0,I.useRef)(o);X.current=o;let Z=(0,I.useRef)([]),Q=(0,I.useRef)(null),de=(0,I.useCallback)(()=>{Q.current=null;let e=Z.current;e.length!==0&&(Z.current=[],x(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),$=(0,I.useCallback)(e=>{let t=Z.current;t.push(e),t.length>1e4&&(Z.current=t.slice(-8e3)),Q.current||=requestAnimationFrame(de)},[de]);(0,I.useEffect)(()=>()=>{Q.current&&cancelAnimationFrame(Q.current)},[]);let fe=(0,I.useCallback)(e=>{let t=e;if(!(X.current&&t.projectId&&t.projectId!==X.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];E(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===r)$({id:Date.now(),job_id:r??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===r)$({id:Date.now(),job_id:r??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.turn_user`&&t.jobId===r)U(!0);else if(t.type===`job.turn_done`&&t.jobId===r)V(t.totals),U(!1);else if(t.type===`job.finalized`&&t.jobId===r){U(!1),q(!1);let e=t.totals;e&&V(e),fetch(`${u()}/jobs/${r}`).then(e=>e.json()).then(e=>v(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===r);if(e){let t=e.status;v(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${u()}/jobs/${r}`).then(e=>e.json()).then(e=>v(e.job)).catch(()=>{})}}}},[r,$]),{registerHandler:me,unregisterHandler:he}=g();(0,I.useEffect)(()=>(me(`job-detail-${r}`,fe),()=>he(`job-detail-${r}`)),[r,fe,me,he]),(0,I.useEffect)(()=>{if(!r||!_||_.status!==`running`||_.hasTelemetry)return;let e=setInterval(()=>{fetch(`${u()}/jobs/${r}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&v(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[r,_?.status,_?.hasTelemetry]);async function ge(){if(r)try{let t=await fetch(`${u()}/jobs/${r}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(w.success(e(`detail.toast.jobDeleted`)),p(`/jobs`)):w.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();w.error(e(`detail.toast.failed`),{description:n.error})}}catch{w.error(e(`detail.toast.networkError`))}}async function ve(){if(!(!r||K)){q(!0);try{let t=await fetch(`${u()}/jobs/${r}/finalize`,{method:`POST`});if(t.ok)w.success(e(`detail.toast.finalizeScheduled`));else{let n=await t.json().catch(()=>({}));w.error(e(`detail.toast.finalizeFailed`),{description:n.error}),q(!1)}}catch{w.error(e(`detail.toast.networkError`)),q(!1)}}}async function ye(){let t=W.trim();if(!(!r||!t||J)){Y(!0);try{let n=await fetch(`${u()}/jobs/${r}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)G(``);else{let t=await n.json().catch(()=>({}));w.error(e(`detail.toast.sendFailed`),{description:t.error})}}catch{w.error(e(`detail.toast.networkError`))}finally{Y(!1)}}}async function be(){if(_)try{let t=await fetch(`${u()}/jobs/${_.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-${_.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){w.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function xe(){if(_)try{let t=await fetch(`${u()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:_.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));w.success(e(`detail.toast.jobRequeued`)),p(`/jobs/${n.jobId}`)}catch(e){w.error(e.message)}}if(oe)return(0,L.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,L.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,L.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(ce||!_)return(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,L.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:r})}),(0,L.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsxs)(ne,{to:`/`,children:[(0,L.jsx)(F,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let Se=_e[_.status]??_e.queued,Ce=_.status===`running`,we=_.status===`completed`||_.status===`failed`,Te=!!_.interactive,Ee=Te&&Ce,De=(_.tickets?.length??0)>0,Oe=P.length>1?{totalCostUsd:P.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:P.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:P.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:P.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:P.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:P.length}:null;return(0,L.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,L.jsxs)(ne,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,L.jsx)(F,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,L.jsx)(i,{className:`w-3 h-3`}),(0,L.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:r?.slice(0,8)})})]}),De&&(0,L.jsx)(ue,{tickets:_.tickets??[],onTicketClick:m}),(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(c,{variant:Se.variant,children:e(Se.labelKey)})})}),(0,L.jsx)(A,{children:e(Se.tooltipKey)})]}),(0,L.jsx)(`code`,{className:M(`font-mono text-foreground/90 truncate`,De?`text-xs text-muted-foreground`:`text-sm`),children:ie(_.command,l)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,L.jsx)(`span`,{children:_.started_at?e(`detail.startedAgo`,{timeAgo:k(new Date(_.started_at),{addSuffix:!0,locale:t()})}):e(`detail.queuedWaiting`)}),_.model&&(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,children:_.model})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[_.hasTelemetry&&(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsxs)(d,{variant:`outline`,size:`sm`,className:`h-7`,onClick:be,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,L.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,L.jsx)(A,{children:e(`detail.exportDiagnosticTooltip`)})]}),we&&(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsxs)(d,{variant:`outline`,size:`sm`,onClick:xe,className:`h-7`,children:[(0,L.jsx)(ee,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,L.jsx)(A,{children:e(`detail.reExecuteTooltip`)})]}),Ee&&(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsxs)(d,{variant:`outline`,size:`sm`,onClick:ve,disabled:K,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,L.jsx)(j,{className:`w-3.5 h-3.5 mr-1.5`}),e(K?`detail.finalizing`:`detail.finalizeJob`)]})}),(0,L.jsx)(A,{children:e(`detail.finalizeJobTooltip`)})]}),Ce&&(0,L.jsxs)(n,{children:[(0,L.jsx)(a,{asChild:!0,children:(0,L.jsx)(d,{variant:`outline`,size:`sm`,onClick:ge,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Te?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,L.jsx)(A,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,L.jsx)(ae,{phases:O,phaseDefinitions:S})]}),(_.status===`running`||_.status===`completed`||_.status===`failed`)&&(0,L.jsx)(le,{job:_,events:y,defaultOpen:_.status===`completed`||_.status===`running`,pipelineTotals:Oe??void 0,phases:O,phaseDefinitions:S}),(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,L.jsx)(pe,{events:y})}),Ee&&(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border/40 bg-surface/40 px-3 py-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[H&&(0,L.jsx)(C,{className:`w-3 h-3 animate-spin`}),e(H?`detail.interactive.working`:`detail.interactive.ready`)]}),B&&(0,L.jsx)(`span`,{className:`tabular-nums`,children:e(`detail.interactive.liveTotals`,{turns:B.num_turns,cost:B.total_cost_usd.toFixed(4)})})]}),(0,L.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,L.jsx)(`textarea`,{value:W,onChange:e=>G(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ye())},rows:2,placeholder:e(`detail.interactive.placeholder`),"aria-label":e(`detail.interactive.placeholder`),className:`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,L.jsxs)(d,{size:`sm`,onClick:()=>void ye(),disabled:J||!W.trim(),className:`h-9 shrink-0`,children:[(0,L.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.interactive.send`)]})]})]})]})}export{ve as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{A as t,Bt as n,C as r,Ct as i,E as a,It as o,L as s,M as c,N as l,P as u,Qt as d,R as f,Rt as p,V as m,W as h,Zt as g,_ as ee,bn as _,dn as v,fn as y,g as te,gn as b,j as x,k as S,lt as C,n as w,u as T,w as E,wt as D,xt as ne,zt as O}from"./index-CEunZ8kJ.js";import{t as k}from"./ExportDropdown-ClTut9WA.js";import{t as re}from"./format-command-CMsBTOPN.js";var ie=o(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),A=e(_(),1),j=g();function M(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function N(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function P(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function F({label:e,a:t,b:n,highlight:r}){return(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,j.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,j.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function I(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ae({jobIds:e,onClose:t}){let{t:n}=y(`jobs`),[r,a]=(0,A.useState)(null),[o,s]=(0,A.useState)(!0),[c,l]=(0,A.useState)(null);(0,A.useEffect)(()=>{let t=new AbortController;return fetch(`${d()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{a(e),s(!1)}).catch(e=>{e.name!==`AbortError`&&(l(e.message),s(!1))}),()=>t.abort()},[e]);function u(e,t){return(0,j.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,j.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,j.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,j.jsx)(D,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,j.jsx)(i,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,j.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,j.jsxs)(`div`,{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(),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,j.jsx)(m,{className:`w-4 h-4`})})]}),o&&(0,j.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,j.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),c&&(0,j.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=I(e.durationMs,t.durationMs,!0),a=I(e.totalCostUsd,t.totalCostUsd,!0),o=I(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,j.jsx)(`div`,{}),u(e,0),u(t,1)]}),(0,j.jsx)(F,{label:n(`comparison.duration`),a:M(e.durationMs),b:M(t.durationMs),highlight:i}),(0,j.jsx)(F,{label:n(`comparison.cost`),a:N(e.totalCostUsd),b:N(t.totalCostUsd),highlight:a}),(0,j.jsx)(F,{label:n(`comparison.tokensOut`),a:P(e.tokensOut),b:P(t.tokensOut),highlight:o}),(0,j.jsx)(F,{label:n(`comparison.tokensIn`),a:P(e.tokensIn),b:P(t.tokensIn),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.cacheRead`),a:P(e.tokensCacheRead),b:P(t.tokensCacheRead),highlight:null}),(0,j.jsx)(F,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,j.jsx)(F,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]})})}var oe={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`}},se=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],L={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function ce(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function le(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function ue(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function de(e){try{return T(new Date(e),{addSuffix:!0,locale:n()})}catch{return e}}var R=10;function z({jobs:e,isLoading:n,onJobsCleared:i,onProposalClick:o,onProposalDelete:m}){let{t:g}=y(`jobs`),ee=b(),{activeProjectId:_,projects:te}=p(),w=te.find(e=>e.id===_)?.provider,[T,D]=(0,A.useState)(null),[O,k]=(0,A.useState)(``),[M,N]=(0,A.useState)(``),[P,F]=(0,A.useState)(!1),[I,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(``),[H,U]=(0,A.useState)(!1),[W,G]=(0,A.useState)(null),[K,q]=(0,A.useState)(R),[J,Y]=(0,A.useState)(!1),[X,Z]=(0,A.useState)([]),[fe,Q]=(0,A.useState)(null);(0,A.useEffect)(()=>{q(R)},[e.length]);function pe(){Y(e=>!e),Z([])}function me(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(T&&e.status!==T||O&&e.started_at<O||M&&e.started_at>`${M}T23:59:59`)),he=e.filter(e=>!(I&&e.started_at<I||B&&e.started_at>`${B}T23:59:59`)).length;async function ge(e){U(!0);try{let t={};e===`range`&&(I&&(t.from=I),B&&(t.to=B));let n=await fetch(`${d()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();v.success(g(`recent.toast.cleared`,{count:e.deleted})),F(!1),z(``),V(``),i?.()}else v.error(g(`recent.toast.clearFailed`))}catch{v.error(g(`recent.toast.networkError`))}finally{U(!1)}}return n?(0,j.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,j.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,j.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,j.jsx)(ne,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:g(`recent.emptyTitle`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:g(`recent.emptyDescription`)})]}):(0,j.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>D(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${T===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:g(`recent.filterAll`,{count:e.length})}),se.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>D(T===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${T===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:g(`recent.filterStatus`,{status:g(`statusName.${t}`),count:n})},t)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:O,onChange:e=>k(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:g(`recent.fromDate`)}),(0,j.jsx)(`input`,{type:`date`,value:M,onChange:e=>N(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:g(`recent.toDate`)}),(O||M)&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>{k(``),N(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:g(`recent.clear`)}),(0,j.jsxs)(r,{children:[(0,j.jsx)(a,{asChild:!0,children:(0,j.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${J?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:pe,children:(0,j.jsx)(ie,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(E,{children:g(J?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,j.jsxs)(r,{children:[(0,j.jsx)(a,{asChild:!0,children:(0,j.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>F(!0),children:(0,j.jsx)(h,{className:`w-3.5 h-3.5`})})}),(0,j.jsx)(E,{children:g(`recent.clearJobs`)})]})]})]}),J&&(0,j.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{children:[X.length===0&&g(`recent.selectTwoToCompare`),X.length===1&&g(`recent.selectOneMore`),X.length===2&&g(`recent.readyToCompare`)]}),X.length===2&&(0,j.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:g(`recent.compareAction`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,j.jsx)(`span`,{className:`w-14`,children:g(`recent.colStatus`)}),(0,j.jsx)(`span`,{className:`flex-1 min-w-0`,children:g(`recent.colCommand`)}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:g(`recent.colDuration`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:g(`recent.colTokens`)}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:g(`recent.colCost`)}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:g(`recent.colStarted`)})]})]}),(0,j.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,K).map(e=>{let t=oe[e.status]??oe.queued,n=ce(e.total_cost_usd),i=le(e.started_at,e.finished_at),c=ue((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),l=e.id.startsWith(`proposal:`),u=l?e.id.replace(`proposal:`,``):null,d=X.includes(e.id),f=J&&!l&&X.length===2&&!d;return(0,j.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${d?`bg-accent/70 ring-1 ring-border`:f?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(J&&!l){me(e.id);return}l&&u?o?.(u):ee(`/jobs/${e.id}`)},children:[(0,j.jsxs)(r,{children:[(0,j.jsx)(a,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(s,{variant:t.variant,children:g(t.labelKey)})})}),(0,j.jsx)(E,{children:g(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,j.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${L[e.priority].className}`,children:g(L[e.priority].labelKey)}),e.profile_name&&(0,j.jsxs)(r,{children:[(0,j.jsx)(a,{asChild:!0,children:(0,j.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,j.jsx)(E,{children:g(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,j.jsxs)(r,{children:[(0,j.jsx)(a,{asChild:!0,children:(0,j.jsx)(C,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,j.jsxs)(E,{children:[g(`recent.pipelinePart`),e.depends_on_job_id&&` ${g(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,j.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:re(e.command,w)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,j.jsx)(`span`,{className:`w-14 text-right`,children:i??`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:c?`${c}`:`—`}),(0,j.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,j.jsx)(`span`,{className:`w-20 text-right`,children:de(e.started_at)}),l&&u&&(0,j.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),G(u)},title:g(`recent.deleteProposal`),children:(0,j.jsx)(h,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>K&&(0,j.jsx)(`div`,{className:`pt-1 text-center`,children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>q(e=>e+R),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:g(`recent.loadMore`,{count:$.length-K})})}),P&&(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>F(!1),children:(0,j.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold`,children:g(`recent.clearModal.title`)}),(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:g(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,j.jsx)(f,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:H,onClick:()=>ge(`all`),children:g(`recent.clearModal.clearAll`,{count:e.length})}),(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`recent.clearModal.orByRange`)}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(`input`,{type:`date`,value:I,onChange:e=>z(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:g(`recent.clearModal.fromPlaceholder`)}),(0,j.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:g(`recent.clearModal.toPlaceholder`)})]}),(0,j.jsx)(f,{variant:`outline`,size:`sm`,className:`w-full`,disabled:H||!I&&!B,onClick:()=>ge(`range`),children:I||B?g(`recent.clearModal.clearInRange`,{count:he}):g(`recent.clearModal.clearRange`)})]}),(0,j.jsx)(f,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>F(!1),children:g(`common:actions.cancel`)})]})}),(0,j.jsx)(S,{open:W!==null,onOpenChange:e=>!e&&G(null),children:(0,j.jsxs)(t,{className:`max-w-sm`,children:[(0,j.jsxs)(l,{children:[(0,j.jsx)(u,{children:g(`recent.deleteProposalConfirm.title`)}),(0,j.jsx)(x,{children:g(`recent.deleteProposalConfirm.description`)})]}),(0,j.jsxs)(c,{children:[(0,j.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>G(null),children:g(`common:actions.cancel`)}),(0,j.jsx)(f,{variant:`destructive`,size:`sm`,onClick:()=>{W&&m?.(W),G(null)},children:g(`common:actions.delete`)})]})]})}),fe&&(0,j.jsx)(ae,{jobIds:fe,onClose:()=>{Q(null),Z([]),Y(!1)}})]})}function B(){let{t:e}=y(`jobs`),{activeProjectId:n}=p(),{recentJobs:r}=w(n),{data:i,isFirstLoad:a,refresh:o}=O({namespace:`jobs`,projectId:n,initialValue:r,fetcher:async()=>{let e=await fetch(`${d()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:m}=O({namespace:`proposals`,projectId:n,initialValue:[],fetcher:async()=>{let e=await fetch(`${d()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),h={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},g=m.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:h[e.status]??`queued`})),_=[...i,...g].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[b,x]=(0,A.useState)(null),C=(0,A.useCallback)(async e=>{try{let t=await fetch(`${d()}/propose/${e}`);if(!t.ok)return;x((await t.json()).proposal)}catch{}},[]),T=(0,A.useCallback)(async t=>{try{(await fetch(`${d()}/propose/${t}`,{method:`DELETE`})).ok&&(v.success(e(`page.proposalDeleted`)),o())}catch{}},[o,e]);return(0,j.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,j.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,j.jsx)(k,{baseUrl:`${d()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,j.jsx)(z,{jobs:_,isLoading:a,onJobsCleared:o,onProposalClick:C,onProposalDelete:T}),(0,j.jsx)(S,{open:b!==null,onOpenChange:e=>!e&&x(null),children:(0,j.jsx)(t,{className:`max-w-3xl glass-card`,children:b&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(u,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,j.jsx)(s,{variant:b.status===`created`?`success`:b.status===`cancelled`?`destructive`:`secondary`,children:b.status})]})}),(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:b.idea}),b.result_markdown?(0,j.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,j.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,j.jsx)(ee,{remarkPlugins:[te],children:b.result_markdown})})}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),b.issue_url&&(0,j.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,j.jsx)(`a`,{href:b.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:b.issue_url})]}),(0,j.jsxs)(c,{children:[(0,j.jsx)(f,{variant:`destructive`,size:`sm`,onClick:()=>{T(b.id),x(null)},children:e(`common:actions.delete`)}),(0,j.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>x(null),children:e(`common:actions.close`)})]})]})})})]})}export{B as default};
|