specrails-desktop 2.28.0 → 2.29.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.
Files changed (73) hide show
  1. package/cli/dist/specrails-desktop.js +13 -3
  2. package/client/dist/assets/{ActivityFeedPage-DcMmDAP3.js → ActivityFeedPage-Be-6L0Ld.js} +1 -1
  3. package/client/dist/assets/AgentBrowserCapture-CpZ-dd8O.js +1 -0
  4. package/client/dist/assets/{AgentIntegrationsModal-DkqooCFn.js → AgentIntegrationsModal-DO1pN_Ez.js} +1 -1
  5. package/client/dist/assets/{AgentModeCodePane-CM77ljte.js → AgentModeCodePane-DLltTOqp.js} +2 -2
  6. package/client/dist/assets/{AgentModeJobsPane-DbZzogbi.js → AgentModeJobsPane-Dp5YvmW0.js} +1 -1
  7. package/client/dist/assets/AgentsPage-ehHuVUds.js +86 -0
  8. package/client/dist/assets/{AnalyticsPage-B4qflNxi.js → AnalyticsPage-C4Ik95FX.js} +1 -1
  9. package/client/dist/assets/{BarChart-Ckstq9fl.js → BarChart-DVZgrhJd.js} +1 -1
  10. package/client/dist/assets/CodePage-D4OCMfxL.js +2 -0
  11. package/client/dist/assets/{DesktopAnalyticsPage-DbgMa8OO.js → DesktopAnalyticsPage-2Xf-52x2.js} +1 -1
  12. package/client/dist/assets/{DocsDialog-BQc9Kwev.js → DocsDialog-CHihLjWd.js} +2 -2
  13. package/client/dist/assets/{DocsPage-OsV44ECy.js → DocsPage-1vEk7XbH.js} +2 -2
  14. package/client/dist/assets/{ExportDropdown-a43XHO3Y.js → ExportDropdown-DLHFQxVn.js} +1 -1
  15. package/client/dist/assets/IntegrationsPage-CCb2YuyJ.js +1 -0
  16. package/client/dist/assets/InteractiveJobComposer-CxJJEnjw.js +19 -0
  17. package/client/dist/assets/JobDetailModal-CJI7qRkm.js +1 -0
  18. package/client/dist/assets/JobDetailPage-DwA9bbwx.js +1 -0
  19. package/client/dist/assets/JobsPage-BDIyFfd5.js +1 -0
  20. package/client/dist/assets/LoopBuilderPage-CpBaW59t.js +7 -0
  21. package/client/dist/assets/{LoopPreviewModal-B2wmifF6.js → LoopPreviewModal-CwpKcv0Y.js} +1 -1
  22. package/client/dist/assets/LoopsPage-BO0Pa8oz.js +1 -0
  23. package/client/dist/assets/PluginsPage-BBGTBpGh.js +2 -0
  24. package/client/dist/assets/ProjectSettingsDialog-M9zGQo0l.js +1 -0
  25. package/client/dist/assets/{TemplatePreviewModal-CERf1IYB.js → TemplatePreviewModal-eBI0zL5P.js} +1 -1
  26. package/client/dist/assets/{agent-MaTxBlg5.js → agent-BEXYxDbs.js} +1 -1
  27. package/client/dist/assets/{agent-ostmMYNz2.js → agent-BoXSzaBk2.js} +1 -1
  28. package/client/dist/assets/{agent-BRJCESkc2.js → agent-C2-rROL52.js} +1 -1
  29. package/client/dist/assets/{agent-D4JAuEGN2.js → agent-CeRTdGT12.js} +1 -1
  30. package/client/dist/assets/{agent-CxnRzL6Z.js → agent-DZ8zTrQT.js} +1 -1
  31. package/client/dist/assets/{agent-DyzUH89R.js → agent-DqyzT33X.js} +1 -1
  32. package/client/dist/assets/{agent-DNQlI8EN.js → agent-fQI_6tsA.js} +1 -1
  33. package/client/dist/assets/{agent-BuYz6fJd.js → agent-tJdAobaM.js} +1 -1
  34. package/client/dist/assets/{brain-BPbhM1Jx.js → brain-DecvjjPU.js} +1 -1
  35. package/client/dist/assets/{dist-js-Dh-9lbLD.js → dist-js-BTAcxhPb.js} +1 -1
  36. package/client/dist/assets/{dist-js-Byjcju1W.js → dist-js-UjXbEWhN.js} +1 -1
  37. package/client/dist/assets/index-BVbgKXUu.css +2 -0
  38. package/client/dist/assets/index-OBDI7bHm.js +158 -0
  39. package/client/dist/assets/{lib-yKyTNJ1c.js → lib-C5ZxrPSR.js} +1 -1
  40. package/client/dist/assets/{upload-Qh1NE3xi.js → upload-lgjKJgrl.js} +1 -1
  41. package/client/dist/assets/{value-BMPeyInx.js → value-Bc0_jlJA.js} +1 -1
  42. package/client/dist/index.html +3 -3
  43. package/package.json +2 -2
  44. package/server/dist/agent-operator-prompt.js +33 -1
  45. package/server/dist/contract-refine-runner.js +30 -9
  46. package/server/dist/explore-cwd-manager.js +6 -3
  47. package/server/dist/headroom-manager.js +78 -13
  48. package/server/dist/loop-factory.js +15 -8
  49. package/server/dist/loop-graph.js +7 -0
  50. package/server/dist/loop-run-manager.js +115 -13
  51. package/server/dist/loop-runs-store.js +27 -8
  52. package/server/dist/loop-templates.js +10 -2
  53. package/server/dist/mcp/tools/jobs.js +3 -3
  54. package/server/dist/mcp/tools/rails.js +2 -1
  55. package/server/dist/project-registry.js +2 -0
  56. package/server/dist/project-router-jobs.js +15 -11
  57. package/server/dist/rails-router.js +1 -1
  58. package/server/dist/terminal-shell-integration.js +4 -1
  59. package/server/dist/worktree-manager.js +52 -4
  60. package/client/dist/assets/AgentBrowserCapture-CZ3oc1UL.js +0 -1
  61. package/client/dist/assets/AgentsPage-BZIml7eL.js +0 -86
  62. package/client/dist/assets/CodePage-DFZXLbI1.js +0 -2
  63. package/client/dist/assets/IntegrationsPage-C3E8hZhB.js +0 -1
  64. package/client/dist/assets/InteractiveJobComposer-zj8SrOAl.js +0 -19
  65. package/client/dist/assets/JobDetailModal-Cm6ZeVoh.js +0 -1
  66. package/client/dist/assets/JobDetailPage-DN67LsdX.js +0 -1
  67. package/client/dist/assets/JobsPage-DF9wKGbw.js +0 -1
  68. package/client/dist/assets/LoopBuilderPage-RJ6GGjli.js +0 -7
  69. package/client/dist/assets/LoopsPage-DdlvH-dJ.js +0 -1
  70. package/client/dist/assets/PluginsPage-9DI0a6jI.js +0 -2
  71. package/client/dist/assets/ProjectSettingsDialog-dgy5hqPd.js +0 -1
  72. package/client/dist/assets/index-89SuhD4Y.js +0 -158
  73. package/client/dist/assets/index-DOGzWJhO.css +0 -2
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-C9J2ikJK.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-C3B0tp2x.js","assets/editor-Br_kD0ds.css","assets/workers-U0UXyLUf.js","assets/monaco.contribution-Desq7oq4.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{Bn as n,Dn as r,En as i,Gn as a,Jn as o,M as s,Nt as c,Rn as l,Tn as u,Vt as d,X as f,Yn as p,Z as m,_ as h,at as g,b as _,cn as v,ct as y,dn as b,fn as x,gn as S,it as C,j as w,ln as T,lt as E,mn as D,nt as O,on as k,pn as A,qn as j,ut as M,wt as N,zn as P}from"./index-89SuhD4Y.js";var F=l(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),I=e(p(),1),L=e(o(),1);function R(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function z(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function ee(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var te=(e,t)=>Math.abs(e-t)<1.01,ne=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},B,V=()=>{if(B!==void 0)return B;if(typeof navigator>`u`)return B=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return B=!0;let e=navigator.maxTouchPoints;return B=navigator.platform===`MacIntel`&&e!==void 0&&e>0},H=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},U=e=>e,W=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},re=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(H(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(H(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},G={passive:!0},K=typeof window>`u`?!0:`onscrollend`in window,q=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&K,o=0,s=a?null:ne(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,G),a&&r.addEventListener(`scrollend`,u,G),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},ie=(e,t)=>q(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ae=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},oe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:U,rangeExtractor:W,onChange:()=>{},measureElement:J,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=z(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!V()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,G),e.addEventListener(`touchend`,n,G),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=z(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=z(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=R(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=z(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=z(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(V()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=z(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return ee(t[Y(0,t.length-1,r?e=>n[e*2]:e=>ee(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&te(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var ce=typeof document<`u`?I.useLayoutEffect:I.useEffect;function le({useFlushSync:e=!0,...t}){let n=I.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,L.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:re,observeElementOffset:ie,scrollToFn:ae,...e})}var X=E(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:a,filterTicketId:o}){let{t:s}=n(`code`),{activeProjectId:c}=C(),{openTicketDetail:l}=_(),{registerHandler:u,unregisterHandler:d}=y(),[f,p]=(0,I.useState)(()=>{if(!c)return`touched-by-ai`;try{let e=localStorage.getItem(Z(c));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,I.useEffect)(()=>{if(c)try{localStorage.setItem(Z(c),f)}catch{}},[f,c]);let[m,h]=(0,I.useState)(()=>{if(!c)return new Set;try{let e=localStorage.getItem(de(c));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,I.useEffect)(()=>{if(c)try{localStorage.setItem(de(c),JSON.stringify([...m]))}catch{}},[m,c]);let x=(0,I.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,I.useCallback)(()=>{h(new Set)},[]),{data:w,refresh:E,isFirstLoad:D}=g({namespace:`code-tree:${f}:${f===`touched-by-ai`?`${a??`all-jobs`}:${o??`all-specs`}`:`all`}`,projectId:c,initialValue:[],fetcher:(0,I.useCallback)(async()=>{let e=[],t=null;for(let n=0;n<100;n+=1){let n=new URLSearchParams({withProvenance:`1`,filter:f});f===`touched-by-ai`&&a&&n.set(`jobId`,a),f===`touched-by-ai`&&typeof o==`number`&&n.set(`ticketId`,String(o)),t&&n.set(`cursor`,t);let r=await fetch(`${M()}/code/tree?${n.toString()}`);if(!r.ok)break;let i=await r.json().catch(()=>({}));if(Array.isArray(i.entries)&&e.push(...i.entries),!i.nextCursor)break;t=i.nextCursor}return e},[f,a,o])}),A=(0,I.useRef)(c);(0,I.useEffect)(()=>{A.current=c},[c]),(0,I.useEffect)(()=>{if(!c)return;let e=`code-tree-${c}`;return u(e,e=>{let t=e;t.projectId===A.current&&t.type===`file.provenance_updated`&&E()}),()=>d(e)},[c,u,d,E]);let j=(0,I.useRef)(null),N=(0,I.useMemo)(()=>(w??[]).filter(e=>!ge(e.path,m)),[w,m]),P=(0,I.useCallback)(()=>{h(new Set((w??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[w]),F=ue({count:N.length,getScrollElement:()=>j.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),L=N.length===0,R=(0,I.useMemo)(()=>(w??[]).filter(e=>e.kind===`file`).length,[w]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`touched-by-ai`),className:O(`px-2 py-1 rounded-md transition-colors`,f===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":f===`touched-by-ai`,children:s(a?`tree.jobFiles`:o?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`all`),className:O(`px-2 py-1 rounded-md transition-colors`,f===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":f===`all`,children:s(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:P,title:s(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":s(`tree.collapseAll`),children:(0,X.jsx)(i,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:S,title:s(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":s(`tree.expandAll`),children:(0,X.jsx)(r,{className:`w-3.5 h-3.5`})})]}),f===`touched-by-ai`&&R>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:s(`tree.touchedCount`,{count:R})})})]}),L&&D?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:s(`tree.loadingFiles`)})}):L&&f===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:s(`tree.showAllFiles`)})]}):L?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:s(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:j,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:F.getTotalSize(),position:`relative`,width:`100%`},children:F.getVirtualItems().map(n=>{let a=N[n.index],o=fe(a.path)*12,c=a.kind===`file`&&a.path===t,u=a.provenance?.createdByTicketId,d=a.provenance?.modifiedByTicketIds??[],f=a.provenance?.latest??null,p=me(f?.jobId),h=he(f?.kind),g=a.kind===`dir`,_=g&&m.has(a.path),y=a.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:O(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,c&&`bg-muted text-foreground`),onClick:()=>{g?x(a.path):e(a.path)},role:`button`,tabIndex:0,"aria-expanded":g?!_:void 0,"data-testid":`file-tree-row-${a.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:o},className:`flex items-center gap-1 min-w-0 flex-1`,children:[g?(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(i,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(r,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),_?(0,X.jsx)(v,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(T,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(b,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(a.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[g&&y>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:s(`tree.folderTouched`,{count:y}),children:y}),!g&&h&&(0,X.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded`,f?.kind===`created`&&`bg-accent-success/15 text-accent-success`,f?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,f?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:f?.kind===`created`?s(`tree.latestTitleCreated`):f?.kind===`deleted`?s(`tree.latestTitleDeleted`):s(`tree.latestTitleModified`),children:s(`action.${h}`)}),!g&&p&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:s(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,X.jsx)(k,{className:`h-3 w-3`}),p]}),!g&&typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(u)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${u}`,title:s(`tree.createdBySpec`,{id:u}),children:[`#`,u]}),!g&&d.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:s(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},a.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:r,readOnly:i,onChange:a}){let{t:o}=n(`code`),s=h(),c=(0,I.useRef)(null),l=(0,I.useRef)(null),u=(0,I.useRef)(null),[d,f]=(0,I.useState)(!1),p=(0,I.useRef)(e),m=(0,I.useRef)(r),g=(0,I.useRef)(s),_=(0,I.useRef)(i),v=(0,I.useRef)(a);return(0,I.useEffect)(()=>{p.current=e},[e]),(0,I.useEffect)(()=>{m.current=r},[r]),(0,I.useEffect)(()=>{g.current=s},[s]),(0,I.useEffect)(()=>{_.current=i},[i]),(0,I.useEffect)(()=>{v.current=a},[a]),(0,I.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!c.current)return;u.current=t;let n=Ee(t,g.current),r=t.editor.create(c.current,{value:p.current,language:m.current,readOnly:_.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{v.current?.(r.getValue())}),l.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||f(!0)}),()=>{e=!0,l.current?.dispose?.(),l.current=null}},[]),(0,I.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,I.useEffect)(()=>{l.current?.updateOptions?.({readOnly:i})},[i]),(0,I.useEffect)(()=>{let e=u.current,t=l.current;if(!e||!t)return;let n=t.getModel?.();n&&e.editor.setModelLanguage(n,r)},[r]),(0,I.useEffect)(()=>{let e=u.current;if(!e)return;let t=Ee(e,s);e.editor.setTheme(t)},[s]),d?(0,X.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,X.jsx)(`span`,{children:o(`monaco.loadFailed`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:o(`monaco.reload`)})]}):(0,X.jsx)(`div`,{ref:c,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,I.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:r=!0,onChange:i}){let{t:a}=n(`code`);return(0,X.jsx)(I.Suspense,{fallback:(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`monaco.loadingEditor`)}),children:(0,X.jsx)(ke,{content:e,language:t,readOnly:r,onChange:i})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:r,regenerating:i,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=n(`code`),{openTicketDetail:l}=_();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let d=je(t.generatedAt,c.language),f=t.triggeredBy?.ticketId,p=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),r&&(0,X.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:s(`summary.stale`)}),i&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof f==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(f),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,f]}),p.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),d&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:d})]})]}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(s,{remarkPlugins:[w],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?A:e===`deleted`?D:x}function Ie({relPath:e,height:t,onOpenTicket:r,onFilterJob:i}){let{t:a}=n(`code`),{activeProjectId:o}=C(),{registerHandler:s,unregisterHandler:c}=y(),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)({}),h=(0,I.useRef)(o);(0,I.useEffect)(()=>{h.current=o},[o]);let g=(0,I.useRef)(e);(0,I.useEffect)(()=>{g.current=e},[e]);let _=(0,I.useRef)(0),v=(0,I.useCallback)(async()=>{let t=++_.current;try{let n=await fetch(`${M()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==_.current)return;if(!n.ok){u([]),f(!0);return}let r=await n.json();if(t!==_.current)return;u(Array.isArray(r.story)?r.story:[]),f(!1)}catch{t===_.current&&(u([]),f(!0))}},[e,o]);(0,I.useEffect)(()=>{u(null),m({}),v()},[v]),(0,I.useEffect)(()=>{if(!o)return;let e=`code-story-${o}`;return s(e,e=>{let t=e;t.projectId===h.current&&t.path===g.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&v()}),()=>c(e)},[o,s,c,v]);let b=(0,I.useCallback)(async(t,n)=>{m(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${M()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),i=await r.json().catch(()=>({}));if(i.skipped===`budget`){m(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!i.ok){P.error(a(`story.explainFailed`)),m(e=>{let n={...e};return delete n[t.provenanceId],n});return}await v(),m(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{P.error(a(`story.explainFailed`)),m(e=>{let n={...e};return delete n[t.provenanceId],n})}},[v,e,a]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:l===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:a(`story.loading`)}):d?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:a(`story.loadFailed`)}):l.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:a(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:l.map(e=>(0,X.jsx)(Le,{entry:e,state:p[e.provenanceId],onOpenTicket:r,onFilterJob:i,onExplain:t=>{b(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:r,onFilterJob:i,onExplain:a}){let{t:o}=n(`code`),s=Fe(e.kind),l=e.ticket?.status??null,u=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:o(`story.spec`,{ticketId:e.ticketId}),d=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(s,{className:`h-3.5 w-3.5 shrink-0`}),o(`story.kindLabel.${e.kind}`)]}),u!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:o(`story.openSpec`,{ticketId:e.ticketId}),children:u}),u==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`story.unknownSpec`)}),l&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[l]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:l}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:o(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:o(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:o(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:o(`story.fallback.${d}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:o(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:o(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(c,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),o(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&i&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:o(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:i,onCopyPathActionChange:a}){let{t:o}=n(`code`),{activeProjectId:s}=C(),{openTicketDetail:c}=_(),{registerHandler:l,unregisterHandler:d}=y(),p=m({allowMove:!1}),h=(0,I.useRef)(null),[g,v]=(0,I.useState)(null),[b,x]=(0,I.useState)(!0),[S,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(!1),[D,O]=(0,I.useState)(()=>Xe(s)),[k,A]=(0,I.useState)(()=>Je(s)),[j,N]=(0,I.useState)(()=>Qe(s)),[F,L]=(0,I.useState)(()=>Ke(s)),R=(0,I.useRef)(s);(0,I.useEffect)(()=>{R.current=s},[s]);let z=(0,I.useRef)(e);(0,I.useEffect)(()=>{z.current=e},[e]),(0,I.useEffect)(()=>{let e=h.current?.clientHeight||window.innerHeight;O(Xe(s)),A(et(Je(s),e)),N(Qe(s)),L(Ke(s))},[s]);let ee=(0,I.useCallback)(e=>{let t=e.clientY,n=k,r=h.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){A(et(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),A(e=>{let t=et(e,r);return Ye(s,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[s,k]),te=(0,I.useCallback)(()=>{let e=et(ze,h.current?.clientHeight||window.innerHeight);A(e),Ye(s,e)},[s]),ne=(0,I.useCallback)(()=>{O(e=>{let t=!e;return Ze(s,t),t})},[s]),B=(0,I.useCallback)(()=>{N(e=>{let t=!e;return $e(s,t),t})},[s]),V=(0,I.useCallback)(e=>{L(e),qe(s,e)},[s]);(0,I.useEffect)(()=>{w(!1),E(!1),q(`preview`),J(!1)},[e]);let H=(0,I.useRef)(0),U=(0,I.useCallback)(async()=>{let t=++H.current;x(!0);try{let n=await fetch(`${M()}/code/file?path=${encodeURIComponent(e)}`);if(t!==H.current)return;if(!n.ok){v(null);return}let r=await n.json();if(t!==H.current)return;v(r)}catch{t===H.current&&v(null)}finally{t===H.current&&x(!1)}},[e,s]);(0,I.useEffect)(()=>{U()},[U]),(0,I.useEffect)(()=>{if(!s)return;let e=`code-file-${s}`;return l(e,e=>{let t=e;t.projectId===R.current&&(t.type===`file.summary_updated`&&t.path===z.current?(w(!1),U()):t.type===`file.summary_failed`&&t.path===z.current?(P.error(t.reason??o(`summary.generationFailed`)),w(!1)):t.type===`file.summary_skipped`&&t.path===z.current&&(t.reason&&P(o(`summary.skipped`,{reason:t.reason})),w(!1)))}),()=>d(e)},[s,l,d,U,o]);let W=(0,I.useCallback)(async t=>{w(!0);try{let n=await fetch(`${M()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){w(!1);let e=typeof r.skipped==`string`?r.skipped:null;P.error(e?o(`summary.skipped`,{reason:e}):o(`summary.generationFailed`));return}if(r.skipped===`budget`){w(!1),E(!0);return}if(r.skipped){w(!1),P(o(`summary.skipped`,{reason:r.skipped}));return}await U(),w(!1)}catch{w(!1),P.error(o(`summary.generationFailed`))}},[U,e,o]),re=(0,I.useCallback)(async()=>{let t=g?.absolutePath??e;try{await navigator.clipboard?.writeText(t),P.success(o(`viewer.pathCopied`))}catch{P.error(o(`viewer.copyPathFailed`))}},[g,e,o]),G=(0,I.useMemo)(()=>Re(e,g?.language),[e,g?.language]),[K,q]=(0,I.useState)(`preview`),[ie,J]=(0,I.useState)(!1),[ae,oe]=(0,I.useState)(``),[Y,se]=(0,I.useState)(!1),ce=g?.content!==void 0&&!g.binary&&!g.tooLarge&&g.reason!==`not-found`,le=(0,I.useCallback)(()=>{oe(g?.content??``),q(`raw`),J(!0)},[g]),ue=(0,I.useCallback)(async()=>{se(!0);try{let t=await fetch(`${M()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:ae})});if(!t.ok){let e=await t.json().catch(()=>({}));P.error(e.error??o(`viewer.saveFailed`));return}P.success(o(`viewer.saved`)),J(!1),U()}catch{P.error(o(`viewer.saveFailed`))}finally{se(!1)}},[e,ae,o,U]),Z=g?.summary??null,de=!!g?.summaryStale,fe=g?.provenance??[],pe=g?.reason===`not-found`,me=pe?o(`summary.reason.missing`):g?.binary?o(`summary.reason.binary`):g?.tooLarge?o(`summary.reason.tooLarge`):null;return(0,I.useEffect)(()=>{if(i){if(b&&!g){i(null);return}return i({hasSummary:!!Z,regenerating:S,disabledReason:me,onClick:()=>W(!1)}),()=>i(null)}},[g,W,b,i,S,Z,me]),(0,I.useEffect)(()=>{if(a){if(b&&!g){a(null);return}return a({onClick:re}),()=>a(null)}},[re,g,b,a]),b&&!g?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:o(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:h,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[D?(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:ne,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(r,{className:`h-3.5 w-3.5`}),o(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:S,generateDisabledReason:me,onCollapse:ne}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:G&&g?.content!==void 0&&!g.binary&&!g.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":o(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>q(`preview`),"aria-pressed":K===`preview`,className:K===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>q(`raw`),"aria-pressed":K===`raw`,className:K===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!ie&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.edit`)}),ie&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:o(`actions.cancel`,{ns:`common`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:o(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:o(`viewer.missingFile`)}):g?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:o(`viewer.binaryFile`)}):g?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:o(`viewer.tooLarge`,{size:Math.round((g.sizeBytes??0)/1024/1024)})}):g?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:o(`viewer.noContent`)}):ie?(0,X.jsx)(Ae,{content:ae,language:g.language??`plaintext`,readOnly:!1,onChange:oe}):G&&K===`preview`?(0,X.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(Ne,{content:g.content})}):(0,X.jsx)(Ae,{content:g.content,language:g.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":o(`history.resize`),onPointerDown:j?void 0:ee,onDoubleClick:j?void 0:te,className:j?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:j?void 0:o(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:o(F===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!j&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":o(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>V(`story`),"aria-pressed":F===`story`,className:F===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:o(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>V(`log`),"aria-pressed":F===`log`,className:F===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:o(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:B,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[j?(0,X.jsx)(u,{className:`h-3.5 w-3.5`}):(0,X.jsx)(r,{className:`h-3.5 w-3.5`}),o(j?`history.show`:`history.hide`)]})]})]}),!j&&(F===`story`?(0,X.jsx)(Ie,{relPath:e,height:k,onOpenTicket:c,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:c,onFilterJob:t,height:k}))]}),T&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:p.guardBackdrop(()=>E(!1)),children:[(0,X.jsxs)(`div`,{ref:p.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:p.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:o(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>E(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:o(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{E(!1),W(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:o(`common:actions.confirm`)})]})]}),(0,X.jsx)(f,{handles:p.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:r,height:i}){let{t:a}=n(`code`),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)({});if(e.length===0)return null;async function u(e,t){if(o===t){s(null);return}if(s(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${M()}/code/diff?${n.toString()}`);if(r.status===404){l(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();l(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{l(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:i},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,n)=>{let i=e.kind===`created`?A:e.kind===`deleted`?D:x,s=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),l=`${e.jobId??`job`}:${e.path}:${e.at}:${n}`,d=c[l];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(i,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(k,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&r?(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:s}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:s}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e,l),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:a(`history.diff`)}),typeof e.ticketId==`number`&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:a(`history.openSpec`,{ticketId:e.ticketId}),children:a(`history.specChip`,{ticketId:e.ticketId})})]}),(0,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),o===l&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):d===`missing`||!d?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,X.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[d.patch,d.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},l)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:r}={}){let{t:i}=n(`code`),{activeProjectId:o}=C(),[s]=j(),c=a(),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(e?t:s.get(`path`)),f=(0,I.useCallback)(e=>{d(e),r?.(e)},[r]),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(()=>st(o)),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),w=e?y:s.get(`jobId`),T=(0,I.useMemo)(()=>{if(e)return x;let t=s.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,x,s]),[E,D]=(0,I.useState)(T==null?``:String(T));(0,I.useEffect)(()=>{if(e)return;let t=s.get(`path`);t!==u&&d(t)},[s,e]),(0,I.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,I.useEffect)(()=>{let e=l.current?.clientWidth||window.innerWidth;v($(st(o),e))},[o]),(0,I.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&v(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,I.useCallback)(e=>{let t=e.clientX,n=_,r=l.current?.clientWidth||window.innerWidth,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){v($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),v(e=>{let t=$(e,r);return ct(o,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[o,_]),k=(0,I.useCallback)(()=>{let e=$(rt,l.current?.clientWidth||window.innerWidth);v(e),ct(o,e)},[o]),A=(0,I.useCallback)(t=>{if(f(t),e)return;let n=new URLSearchParams(s);n.set(`path`,t),c({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,c,s,f]),M=(0,I.useCallback)(t=>{if(e){b(t),S(null);return}let n=new URLSearchParams(s);n.set(`jobId`,t),n.delete(`ticketId`),c({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,c,s]),N=(0,I.useCallback)(()=>{if(e){b(null),S(null);return}let t=new URLSearchParams(s);t.delete(`jobId`),t.delete(`ticketId`),c({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,c,s]),P=(0,I.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){N();return}if(e){S(n),b(null);return}let r=new URLSearchParams(s);r.set(`ticketId`,String(n)),r.delete(`jobId`),c({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[N,e,c,s]);return(0,X.jsxs)(`div`,{ref:l,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:_},children:(0,X.jsx)(_e,{onOpenFile:A,selectedPath:u,filterJobId:w,filterTicketId:T},o??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:i(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:w,ticketId:T,ticketInput:E,onTicketInputChange:D,onApplyTicket:P,onClear:N,summaryAction:p,copyPathAction:h}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:A}),u?(0,X.jsx)(tt,{relPath:u,onFilterJob:M,onSummaryActionChange:m,onCopyPathActionChange:g}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:r,onTicketInputChange:i,onApplyTicket:a,onClear:o,summaryAction:s,copyPathAction:c}){let{t:l}=n(`code`),u=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:o,"aria-pressed":u===`all`,className:u===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.allAi`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(r),"aria-pressed":u===`spec`,className:u===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.spec`)}),(0,X.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a(r)},placeholder:l(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,X.jsx)(`div`,{className:`flex-1`}),c&&(0,X.jsx)(`button`,{type:`button`,onClick:c.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.copyFilePath`)}),s&&(0,X.jsxs)(`button`,{type:`button`,onClick:s.onClick,disabled:s.regenerating||!!s.disabledReason,"aria-label":s.hasSummary?l(`toolbar.regenerateSummary`):l(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:s.disabledReason?l(`toolbar.summaryUnavailable`,{reason:s.disabledReason}):void 0,children:[(0,X.jsx)(d,{className:s.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),s.hasSummary?s.regenerating?l(`toolbar.regenerating`):l(`toolbar.regenerateSummary`):s.regenerating?l(`toolbar.generating`):l(`toolbar.generateSummary`)]}),u===`job-context`&&(0,X.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:l(`toolbar.jobContext`)}),(e||t)&&(0,X.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(N,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:r}){let{t:i}=n(`code`),[a,o]=(0,I.useState)(null);(0,I.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${M()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||o(Array.isArray(e)?e:[])}).catch(()=>{n||o([])}),()=>{n=!0}},[e,t]);let s=(0,I.useMemo)(()=>{let e=a??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[a]),c=a?.length??0;return(0,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?i(`provenancePanel.jobTitle`,{jobId:e}):i(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:i(`provenancePanel.touchedFiles`,{count:c})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:i(`action.added`),rows:s.created,icon:`created`,onOpenFile:r}),(0,X.jsx)(ft,{label:i(`action.changed`),rows:s.modified,icon:`modified`,onOpenFile:r}),(0,X.jsx)(ft,{label:i(`action.deleted`),rows:s.deleted,icon:`deleted`,onOpenFile:r})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(S,{className:`h-3.5 w-3.5`}),i(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,X.jsx)(n===`created`?A:n===`deleted`?D:x,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{lt as default};
@@ -1 +0,0 @@
1
- import{Wn as e,lt as t}from"./index-89SuhD4Y.js";var n=t();function r(){return(0,n.jsx)(e,{to:`/plugins`,replace:!0})}export{r as default};
@@ -1,19 +0,0 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./brain-BPbhM1Jx.js";import{a as n}from"./auth-DpZq5p1e.js";import{B as r,Bn as i,Cn as a,Dn as o,En as s,M as c,On as l,Pn as u,Rn as d,Rt as f,Sn as p,U as m,Ut as h,V as g,Vt as _,Yn as v,a as y,ct as b,en as x,g as S,i as C,it as w,j as T,jt as E,kt as D,lt as O,nn as k,nt as A,o as j,qt as M,r as N,sn as P,st as F,tt as I,un as L,ut as R,vn as z,w as B,wt as V,xn as H,zn as U,zt as ee}from"./index-89SuhD4Y.js";import{t as te}from"./lib-yKyTNJ1c.js";var ne=d(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),re=d(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),ie=d(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]);function ae(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var oe=15e3;function se(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function ce(e){let{projectId:t,jobId:r,timeoutMs:i=oe}=e,a=t?`${n}/api/projects/${t}`:R(),o;try{o=await fetch(`${a}/jobs/${r}`,{method:`DELETE`,signal:se(i)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(i/1e3)}s`:t?.message||String(e),httpStatus:null}}if(o.ok){let e=`canceled`;try{let t=await o.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let s=typeof o.status==`number`?o.status:null,c=s==null?``:` (HTTP ${s})`,l=``;try{typeof o.text==`function`?l=await o.text():typeof o.json==`function`&&(l=JSON.stringify(await o.json()))}catch{}let u=l.slice(0,200).trim();try{let e=JSON.parse(l);e&&typeof e.error==`string`&&e.error&&(u=e.error)}catch{}let d=typeof o.statusText==`string`?o.statusText:``;return{ok:!1,error:u?`${u}${c}`:`HTTP ${s??`?`}${d?` ${d}`:``}`,httpStatus:s}}var W=O();function le({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,W.jsx)(`div`,{className:`flex items-center`,children:t.map((n,i)=>{let a=e[n.key]??`idle`,o=i<t.length-1?e[t[i+1].key]??`idle`:null;return(0,W.jsxs)(`div`,{className:`flex items-center`,children:[(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,W.jsx)(ue,{state:a}),(0,W.jsx)(`span`,{className:A(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400 aurora-light:text-accent-info`:a===`done`?`text-emerald-400 aurora-light:text-accent-success`:a===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:n.label})]})}),(0,W.jsxs)(g,{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})]})]}),o!==null&&(0,W.jsx)(`div`,{className:A(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:o===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},n.key)})})}function ue({state:e}){return(0,W.jsxs)(`div`,{className:A(`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)(a,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,W.jsx)(p,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,W.jsx)(H,{className:`w-6 h-6 text-muted-foreground/20`})]})}var G=e(v(),1);function de(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 fe=new Set;function K({ticketId:e,onOpen:t,children:n}){let{t:r}=i(`agent`),a=r(`refs.openTicket`,{id:e});return(0,W.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:a,"aria-label":a,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 pe(e){if(!e.includes(`#`))return null;let t=y(e,fe);return t.some(e=>e.kind===`ticket`)?t:null}function me(e,t){let n=pe(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,W.jsx)(K,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,W.jsx)(G.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var he=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function ge(e){return e.kind===`ticket`?{type:`link`,url:N({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function _e(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!he.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=y(n.value,fe);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(ge))}else _e(n)}}function ve(){return e=>_e(e)}function ye(e){let{activeProjectId:t}=w(),{openRef:n}=j(),r=e??t??void 0;return(0,G.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function be(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}:de(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(F.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${F.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function xe(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 Se(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
- `+n.content:t.push({...n})}return t}function Ce(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 we({events:e,isLoading:t,projectId:n}){let{t:r,i18n:a}=i(`jobs`),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!0),[d,f]=(0,G.useState)(new Set),p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=ye(n),{processedLines:g,groups:_,totalLines:v}=(0,G.useMemo)(()=>{let t=xe(Se(e.map((e,t)=>be(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:Ce(t),totalLines:t.length}},[e,a.language]),y=(0,G.useMemo)(()=>{if(!s)return v;let e=s.toLowerCase();return g.filter(t=>t.content.toLowerCase().includes(e)).length},[s,g,v]),b=(0,G.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,G.useEffect)(()=>{l&&b()},[e.length,l,b]);function x(){let e=m.current;e&&u(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function C(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)(ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,W.jsx)(S,{placeholder:r(`logViewer.filterPlaceholder`),value:s,onChange:e=>c(e.target.value),className:`pl-7 h-7`})]}),(0,W.jsx)(I,{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
- `);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)(Te,{group:e,filter:s,collapsed:d.has(e.key),onToggle:()=>C(e.key),onOpenTicket:h},e.key)),(0,W.jsx)(`div`,{ref:p})]}),!l&&(0,W.jsxs)(I,{size:`sm`,variant:`secondary`,onClick:()=>{u(!0),b()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,W.jsx)(o,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Te=(0,G.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:a}){let{t:o}=i(`jobs`),c=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return c.length===0?null:(0,W.jsx)(`div`,{children:c.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:a},e.id))});let l=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:A(`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)(s,{className:A(`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:l}),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:o(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:c.length===0?(0,W.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:o(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):c.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:a},e.id))})]})}),Ee=[te],De=[T],Oe=[T,ve],q=(0,G.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`,l=i||a||o||s,u=n!=null&&(e.type===`plain`||e.type===`log`),d=(0,G.useMemo)(()=>u&&n?me(e.content,n):e.content,[u,n,e.content]),f=r&&n?Oe:De,p=(0,G.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=C(e);return r?.kind===`ticket`?(0,W.jsx)(K,{ticketId:r.ticketId,onOpen:n,children:t}):(0,W.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,W.jsxs)(`div`,{className:A(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!l&&(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
- 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,W.jsx)(c,{remarkPlugins:f,rehypePlugins:Ee,components:p,children:e.content})}):(0,W.jsx)(`span`,{className:A(`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`,i&&`text-emerald-400 aurora-light:text-accent-success`,a&&`text-red-400 aurora-light:text-destructive`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:d})]})});function J(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}var ke=/^\s*━+\s*Step\s+\d+\s*·/,Ae=/\s*\(iteration\s+\d+\)\s*$/i;function Y(e){return e.replace(/^[\s\uFE0F\p{Extended_Pictographic}]+/u,``).trim()||e.trim()}function X(e){let t=Y(e.title);return e.iteration==null?t:t.replace(Ae,``)}function je(e){return e.meta.nodeId??`${e.meta.kind}::${Y(e.meta.title).replace(Ae,``)}`}function Me(e){let t=null,n=0,r=[[]],i=[];for(let a=0;a<e.length;a++){let o=e[a];if(o.event_type===`loop_graph`){let e=J(o.payload);e&&e.graph&&typeof e.graph==`object`&&!Array.isArray(e.graph)&&(t={graph:e.graph,loopId:typeof e.loopId==`string`?e.loopId:void 0,loopName:typeof e.loopName==`string`?e.loopName:void 0,provider:typeof e.provider==`string`?e.provider:void 0,model:typeof e.model==`string`?e.model:void 0,iterationLimit:typeof e.iterationLimit==`number`?e.iterationLimit:void 0});continue}if(o.event_type===`loop_step`){let e=J(o.payload);if(!e||typeof e.index!=`number`)continue;let t=typeof e.iteration==`number`?e.iteration:null;t!=null&&t>n&&(n=t),i.push({meta:{index:e.index,kind:typeof e.kind==`string`?e.kind:`ai-step`,title:typeof e.title==`string`?e.title:``,nodeId:typeof e.nodeId==`string`?e.nodeId:null,iteration:t,template:typeof e.template==`string`&&e.template?e.template:void 0,command:typeof e.command==`string`&&e.command?e.command:void 0},end:null,lastActivity:null}),r.push([]);continue}if(o.event_type===`loop_step_end`){let e=J(o.payload);if(!e||typeof e.index!=`number`)continue;for(let t=i.length-1;t>=0;t--)if(i[t].meta.index===e.index){i[t].end={index:e.index,nodeId:typeof e.nodeId==`string`?e.nodeId:null,status:e.status===`failed`?`failed`:`ok`,exitCode:typeof e.exitCode==`number`?e.exitCode:null,durationMs:typeof e.durationMs==`number`?e.durationMs:null,decision:e.decision===`continue`||e.decision===`stop`?e.decision:void 0};break}continue}let s=i.length>0,c=be(o,a);if(c&&!(s&&ke.test(c.content))&&r[r.length-1].push(c),s){let e=B(o);e.step&&e.actionKey&&(i[i.length-1].lastActivity={actionKey:e.actionKey,actionArg:e.actionArg})}}let a=e=>xe(Se(e)),o=a(r[0]),s=i.map((e,t)=>({key:`step-${t}-${e.meta.index}`,meta:e.meta,lines:a(r[t+1]),end:e.end,lastActivity:e.lastActivity})),c=o.length+s.reduce((e,t)=>e+t.lines.length,0);return{graphMeta:t,setup:o,segments:s,maxIteration:n,totalLines:c}}function Ne(e,t){return e.end?e.end.status:t.isLast?t.jobSettled?`interrupted`:`running`:`unknown`}function Pe(e){return e===`continue`?0:e===`stop`?2:1}function Fe(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Set,r=[],i=a=>{if(n.has(a))return;let o=t.get(a);if(!o)return;n.add(a),r.push(o);let s=e.edges.filter(e=>e.source===a).slice().sort((e,t)=>Pe(e.branch)-Pe(t.branch));for(let e of s)i(e.target)},a=e.nodes.find(e=>e.type===`start`);a&&i(a.id);for(let t of e.nodes)i(t.id);return r}function Z(e){let t=e.data?.label;return typeof t==`string`&&t.trim()?t.trim():null}function Ie(e,t){let n=e.segments.length-1,r=new Map,i=new Map;e.segments.forEach((e,t)=>{let n=je(e);r.set(n,{seg:e,idx:t}),e.meta.kind===`decider`&&e.end?.decision&&i.set(n,e.end.decision)});let a=e=>{let r=Ne(e.seg,{isLast:e.idx===n,jobSettled:t.jobSettled});return r===`unknown`?`ok`:r};if(e.graphMeta)return Fe(e.graphMeta.graph).map(e=>{if(e.type===`start`)return{key:e.id,kind:`start`,label:Z(e),state:`ok`,latestSegmentKey:null};if(e.type===`end`)return{key:e.id,kind:`end`,label:Z(e),state:t.jobSettled?t.jobFailed?`failed`:`ok`:`pending`,latestSegmentKey:null};let n=r.get(e.id);return n?{key:e.id,kind:e.type,label:Z(e)??X(n.seg.meta),state:a(n),decision:e.type===`decider`?i.get(e.id):void 0,latestSegmentKey:n.seg.key}:{key:e.id,kind:e.type,label:Z(e),state:`pending`,latestSegmentKey:null}});let o=[],s=new Map;return e.segments.forEach((e,t)=>{let n=je(e),r={seg:e,idx:t},c=s.get(n),l=e.meta.kind===`decider`?i.get(n):void 0;if(c!=null){let t=o[c];t.state=a(r),t.decision=l,t.latestSegmentKey=e.key}else s.set(n,o.length),o.push({key:n,kind:e.meta.kind,label:X(e.meta)||null,state:a(r),decision:l,latestSegmentKey:e.key})}),o}function Le(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Re={start:M,"ai-step":t,shell:D,decider:P,condition:P,end:L},ze=E,Be={start:`text-accent-success`,"ai-step":`text-accent-primary`,shell:`text-accent-warning`,decider:`text-accent-highlight`,condition:`text-accent-info`,end:`text-accent-secondary`},Ve={start:`border-accent-success/60`,"ai-step":`border-accent-primary/60`,shell:`border-accent-warning/60`,decider:`border-accent-highlight/60`,condition:`border-accent-info/60`,end:`border-accent-secondary/60`};function He(e){return Re[e]??ze}function Ue({chips:e,iteration:t,onChipClick:n,variant:r}){let{t:a}=i(`jobs`);return e.length===0&&!t?null:(0,W.jsxs)(`div`,{"data-testid":`loop-overview-strip`,role:`list`,"aria-label":a(`loopExplorer.stepMapAria`),className:A(`flex items-center gap-1 overflow-x-auto border-b border-border/30 bg-surface/20`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[e.map((e,t)=>{let r=He(e.kind),i=Be[e.kind]??`text-foreground`,o=Ve[e.kind]??`border-border/40`,c=e.label??a(`loops:builder.nodes.${e.kind}`,{defaultValue:e.kind}),d=e.latestSegmentKey!=null;return(0,W.jsxs)(G.Fragment,{children:[t>0&&(0,W.jsx)(s,{className:`w-3 h-3 text-muted-foreground/30 shrink-0`}),(0,W.jsxs)(`button`,{type:`button`,role:`listitem`,"data-testid":`loop-node-chip`,"data-state":e.state,"data-kind":e.kind,"data-decision":e.decision,"aria-label":`${c} — ${e.state}`,disabled:!d,onClick:()=>e.latestSegmentKey&&n(e.latestSegmentKey),className:A(`relative flex items-center gap-1.5 shrink-0 rounded-full border bg-surface/40 px-2.5 py-1 text-[11px] transition-colors`,o,e.state===`pending`&&`opacity-45 border-border/40`,e.state===`interrupted`&&`border-dashed border-accent-warning/50`,d?`cursor-pointer hover:bg-surface/70`:`cursor-default`),children:[e.state===`running`&&(0,W.jsx)(`span`,{"aria-hidden":!0,className:`absolute -inset-px rounded-full ring-2 ring-accent-primary/50 motion-safe:animate-pulse pointer-events-none`}),(0,W.jsx)(r,{className:A(`w-3 h-3 shrink-0`,i)}),(0,W.jsx)(`span`,{className:A(`max-w-[120px] truncate font-medium text-foreground/90`,e.state===`running`&&`title-shimmer`),children:c}),e.state===`ok`&&(0,W.jsx)(l,{className:`w-3 h-3 text-accent-success shrink-0`}),e.state===`failed`&&(0,W.jsx)(V,{className:`w-3 h-3 text-destructive shrink-0`}),e.decision===`continue`&&(0,W.jsx)(_,{className:`w-3 h-3 text-accent-highlight shrink-0`}),e.decision===`stop`&&(0,W.jsx)(u,{className:`w-3 h-3 text-accent-success shrink-0`})]})]},e.key)}),t&&(0,W.jsxs)(`span`,{"data-testid":`loop-iteration-chip`,className:`ml-auto flex items-center gap-1.5 shrink-0 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-2.5 py-1 text-[10px] font-medium text-accent-highlight tabular-nums`,children:[(0,W.jsx)(h,{className:`w-3 h-3`}),t.limit==null?a(`loopExplorer.iterationBadge`,{count:t.current}):a(`loopExplorer.iteration`,{current:t.current,limit:t.limit})]})]})}var We=(0,G.memo)(Ue);function Ge({className:e}){return(0,W.jsxs)(`span`,{className:A(`relative flex h-2 w-2 shrink-0`,e),children:[(0,W.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,W.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-accent-primary`})]})}function Ke(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.content.toLowerCase().includes(n))}function qe(e,t,n,r){return e.length===0?(0,W.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:n(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):e.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:r},e.id))}function Je({label:e,value:t,copyLabel:n}){let[r,i]=(0,G.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/50`,children:e}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void a(),"aria-label":`${n} — ${e}`,title:n,className:`p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors cursor-pointer`,children:r?(0,W.jsx)(l,{className:`w-2.5 h-2.5 text-accent-success`}):(0,W.jsx)(z,{className:`w-2.5 h-2.5`})})]}),(0,W.jsx)(`pre`,{className:`mt-0.5 text-[10px] font-mono leading-relaxed text-foreground/75 whitespace-pre-wrap break-words`,children:t})]})}function Ye({segment:e,status:t,collapsed:n,filter:r,onToggle:a,onCopy:o,setRef:c,onOpenTicket:u}){let{t:d}=i(`jobs`),{meta:f,lines:p,end:m,lastActivity:h}=e,g=He(f.kind),_=Be[f.kind]??`text-foreground`,v=Ke(p,r),y=t===`running`,b=!!(f.template||f.command),[x,S]=(0,G.useState)(!1);return(0,W.jsxs)(`div`,{ref:t=>c(e.key,t),"data-testid":`loop-step-section`,"data-status":t,"data-step-index":f.index,className:A(`mt-3 rounded-md overflow-hidden border animate-in fade-in duration-200`,t===`running`&&`border-accent-primary/40`,t===`failed`&&`border-destructive/30`,t===`interrupted`&&`border-dashed border-accent-warning/40`,(t===`ok`||t===`unknown`)&&`border-border/20`),children:[(0,W.jsxs)(`div`,{className:A(`flex items-stretch bg-primary/5 border-b`,t===`failed`?`border-destructive/20`:`border-primary/20`),children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(e.key),className:`flex items-center gap-2 flex-1 min-w-0 text-left px-3 py-2 hover:bg-primary/10 transition-colors duration-150 cursor-pointer`,children:[(0,W.jsx)(s,{className:A(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,W.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/60 shrink-0 w-5 text-right`,children:f.index}),(0,W.jsx)(g,{className:A(`w-3.5 h-3.5 shrink-0`,_)}),(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground leading-none truncate`,children:X(f)}),f.iteration!=null&&f.iteration>=1&&(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/60 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground tabular-nums`,children:d(`loopExplorer.iterationBadge`,{count:f.iteration})}),y&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 shrink-0 max-w-[40%]`,children:[(0,W.jsx)(Ge,{}),h&&(0,W.jsx)(`span`,{className:`title-shimmer text-[10px] truncate`,children:d(`statusPanel.activity.${h.actionKey}`,{arg:h.actionArg??``})})]}),t===`ok`&&(0,W.jsx)(l,{className:`w-3.5 h-3.5 text-accent-success shrink-0`}),t===`failed`&&(0,W.jsx)(V,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),t===`interrupted`&&(0,W.jsx)(`span`,{className:`shrink-0 rounded border border-dashed border-accent-warning/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-warning`,children:d(`loopExplorer.interrupted`)}),(0,W.jsx)(`span`,{className:`flex-1`}),m?.durationMs!=null&&(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums shrink-0`,children:Le(m.durationMs)}),t===`failed`&&m?.exitCode!=null&&m.exitCode!==0&&(0,W.jsx)(`span`,{className:`text-[10px] text-destructive/70 font-mono shrink-0`,children:d(`activeJob.exitCode`,{code:m.exitCode})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:d(`logViewer.phaseLines`,{count:p.length})})]}),b&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>S(e=>!e),"aria-label":d(`loopExplorer.stepDetail`),"aria-expanded":x,title:d(`loopExplorer.stepDetail`),className:A(`px-2 flex items-center transition-colors cursor-pointer`,x?`text-foreground bg-primary/10`:`text-muted-foreground/40 hover:text-foreground hover:bg-primary/10`),children:(0,W.jsx)(k,{className:`w-3 h-3`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-label":d(`loopExplorer.copyStep`),title:d(`loopExplorer.copyStep`),className:`px-2.5 flex items-center text-muted-foreground/40 hover:text-foreground hover:bg-primary/10 transition-colors cursor-pointer`,children:(0,W.jsx)(z,{className:`w-3 h-3`})})]}),x&&b&&(0,W.jsxs)(`div`,{"data-testid":`loop-step-detail`,className:A(`px-4 py-2.5 space-y-2.5 bg-muted/10 border-b animate-in fade-in duration-150`,t===`failed`?`border-destructive/20`:`border-primary/10`),children:[f.template&&(0,W.jsx)(Je,{label:d(`loopExplorer.stepDetailTemplate`),value:f.template,copyLabel:d(`loopExplorer.copyCommand`)}),f.command&&(0,W.jsx)(Je,{label:d(`loopExplorer.stepDetailCommand`),value:f.command,copyLabel:d(`loopExplorer.copyCommand`)})]}),!n&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:qe(v,r,d,u)})]})}var Xe=(0,G.memo)(Ye,(e,t)=>e.segment.key===t.segment.key&&e.segment.lines.length===t.segment.lines.length&&e.segment.lines[e.segment.lines.length-1]?.content===t.segment.lines[t.segment.lines.length-1]?.content&&e.segment.meta.template===t.segment.meta.template&&e.segment.meta.command===t.segment.meta.command&&e.segment.end?.status===t.segment.end?.status&&e.segment.end?.durationMs===t.segment.end?.durationMs&&e.segment.end?.decision===t.segment.end?.decision&&e.segment.end?.exitCode===t.segment.end?.exitCode&&e.segment.lastActivity?.actionKey===t.segment.lastActivity?.actionKey&&e.segment.lastActivity?.actionArg===t.segment.lastActivity?.actionArg&&e.status===t.status&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket),Q=`__setup__`;function Ze({lines:e,collapsed:t,filter:n,onToggle:r,setRef:a,onOpenTicket:o}){let{t:c}=i(`jobs`),l=Ke(e,n);return(0,W.jsxs)(`div`,{ref:e=>a(Q,e),"data-testid":`loop-setup-section`,className:`rounded-md overflow-hidden border border-border/20`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(Q),className:`flex items-center gap-2 w-full text-left px-3 py-2 bg-muted/10 border-b border-border/20 hover:bg-muted/20 transition-colors duration-150 cursor-pointer`,children:[(0,W.jsx)(s,{className:A(`w-3 h-3 text-muted-foreground/60 shrink-0 transition-transform duration-150`,!t&&`rotate-90`)}),(0,W.jsx)(M,{className:`w-3.5 h-3.5 text-accent-success/70 shrink-0`}),(0,W.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground leading-none uppercase tracking-wide`,children:c(`loopExplorer.setup`)}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:c(`logViewer.phaseLines`,{count:e.length})})]}),!t&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:qe(l,n,c,o)})]})}var Qe=(0,G.memo)(Ze,(e,t)=>e.lines.length===t.lines.length&&e.lines[e.lines.length-1]?.content===t.lines[t.lines.length-1]?.content&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket);function $(){return(0,W.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,W.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,W.jsx)(`span`,{className:`relative inline-flex rounded-full h-1.5 w-1.5 bg-accent-primary`})]})}function $e({events:e,jobStatus:t,isLoading:n,variant:r=`page`,projectId:a}){let{t:o,i18n:s}=i(`jobs`),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`follow`),[f,p]=(0,G.useState)(new Set),m=(0,G.useRef)(null),h=(0,G.useRef)(new Map),g=ye(a),_=(0,G.useMemo)(()=>Me(e),[e,s.language]),v=t!=null&&t!==`running`&&t!==`queued`,y=t===`running`,b=(0,G.useMemo)(()=>_.segments.map((e,t)=>Ne(e,{isLast:t===_.segments.length-1,jobSettled:v})),[_,v]),x=(0,G.useMemo)(()=>{let e=_.segments.map(e=>e.key);return _.setup.length>0&&e.push(Q),e},[_]),C=_.segments.length>0?_.segments[_.segments.length-1].key:Q,w=(0,G.useMemo)(()=>c?new Set(x):u===`follow`?new Set([C]):f,[c,u,C,f,x]),T=(0,G.useRef)(w);T.current=w;let E=(0,G.useRef)(_);E.current=_;let D=(0,G.useCallback)(e=>{let t=new Set(T.current);e?.(t),p(t),d(`manual`)},[]),O=(0,G.useCallback)(e=>{D(t=>{t.has(e)?t.delete(e):t.add(e)})},[D]),k=(0,G.useCallback)(e=>{D(t=>t.add(e)),requestAnimationFrame(()=>{h.current.get(e)?.scrollIntoView?.({behavior:`smooth`,block:`start`})})},[D]),j=(0,G.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]),M=(0,G.useCallback)(()=>{d(`follow`),requestAnimationFrame(j)},[j]),N=(0,G.useCallback)(()=>{p(new Set(x)),d(`manual`)},[x]),P=(0,G.useCallback)(()=>{p(new Set),d(`manual`)},[]);(0,G.useEffect)(()=>{u===`follow`&&!c&&j()},[_.totalLines,_.segments.length,u,c,j]);let F=(0,G.useCallback)(()=>{let e=m.current;!e||u!==`follow`||e.scrollHeight-e.scrollTop-e.clientHeight>80&&D()},[u,D]),L=(0,G.useCallback)((e,t)=>{t?h.current.set(e,t):h.current.delete(e)},[]),R=(0,G.useCallback)(e=>{let t=E.current.segments.find(t=>t.key===e),n=e===`__setup__`?E.current.setup.map(e=>e.content).join(`
17
- `):(t?.lines??[]).map(e=>e.content).join(`
18
- `);navigator.clipboard.writeText(n).then(()=>U.success(o(`loopExplorer.copied`))).catch(()=>U.error(o(`logViewer.copyFailed`)))},[o]),B=(0,G.useCallback)(()=>{let e=E.current,t=e.setup.map(e=>e.content);for(let n of e.segments){t.push(`── Step ${n.meta.index} · ${Y(n.meta.title)} ──`);for(let e of n.lines)t.push(e.content)}navigator.clipboard.writeText(t.join(`
19
- `)).then(()=>U.success(o(`logViewer.copySuccess`))).catch(()=>U.error(o(`logViewer.copyFailed`)))},[o]),V=(0,G.useMemo)(()=>Ie(_,{jobSettled:v,jobFailed:t===`failed`}),[_,v,t]),H=_.graphMeta?.iterationLimit??_.graphMeta?.graph.config.maxIterations??null,te=_.maxIteration>0?{current:_.maxIteration,limit:H}:null,ie=(0,G.useMemo)(()=>{if(!c)return _.totalLines;let e=c.toLowerCase(),t=_.setup.filter(t=>t.content.toLowerCase().includes(e)).length;for(let n of _.segments)t+=n.lines.filter(t=>t.content.toLowerCase().includes(e)).length;return t},[c,_]),ae=_.segments[_.segments.length-1],oe=y&&(_.segments.length===0||ae?.end!=null);return n?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`logViewer.loading`)})}):_.totalLines===0&&_.segments.length===0?(0,W.jsx)(`div`,{"data-testid":`loop-step-explorer`,className:`flex-1 flex items-center justify-center h-full`,children:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[y&&(0,W.jsx)($,{}),o(y?`loopExplorer.waiting`:`logViewer.empty`)]})}):(0,W.jsxs)(`div`,{"data-testid":`loop-step-explorer`,className:`relative flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:A(`border-b border-border flex items-center gap-2`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[(0,W.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,W.jsx)(ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,W.jsx)(S,{placeholder:o(`logViewer.filterPlaceholder`),value:c,onChange:e=>l(e.target.value),className:`pl-7 h-7`})]}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:N,"aria-label":o(`loopExplorer.expandAll`),title:o(`loopExplorer.expandAll`),children:(0,W.jsx)(re,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:P,"aria-label":o(`loopExplorer.collapseAll`),title:o(`loopExplorer.collapseAll`),children:(0,W.jsx)(ne,{className:`w-3.5 h-3.5`})}),u===`follow`&&y&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-accent-primary shrink-0`,children:[(0,W.jsx)($,{}),o(`loopExplorer.follow`)]}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:B,"aria-label":o(`logViewer.copySuccess`),children:(0,W.jsx)(z,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:o(`logViewer.lineCount`,{filtered:ie,total:_.totalLines})})]}),(0,W.jsx)(We,{chips:V,iteration:te,onChipClick:k,variant:r}),(0,W.jsxs)(`div`,{ref:m,onScroll:F,className:`flex-1 overflow-y-auto p-2 text-xs`,children:[_.setup.length>0&&(0,W.jsx)(Qe,{lines:_.setup,collapsed:!w.has(`__setup__`),filter:c,onToggle:O,setRef:L,onOpenTicket:g}),_.segments.map((e,t)=>(0,W.jsx)(Xe,{segment:e,status:b[t],collapsed:!w.has(e.key),filter:c,onToggle:O,onCopy:R,setRef:L,onOpenTicket:g},e.key)),oe&&(0,W.jsxs)(`div`,{"data-testid":`loop-waiting-row`,className:`mt-3 flex items-center gap-2 px-3 py-2 text-[11px] text-muted-foreground/70 italic`,children:[(0,W.jsx)($,{}),o(`loopExplorer.waiting`)]})]}),u===`manual`&&y&&!c&&(0,W.jsxs)(`button`,{type:`button`,"data-testid":`resume-follow-pill`,onClick:M,className:`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 rounded-full glass-card border border-accent-primary/30 px-3 py-1.5 text-[11px] font-medium text-foreground shadow-lg hover:border-accent-primary/60 transition-colors cursor-pointer animate-in fade-in slide-in-from-bottom-2 duration-200`,children:[(0,W.jsx)($,{}),o(`loopExplorer.resumeFollow`)]})]})}function et(e,t){switch(t.type){case`turn-user`:return{...e,streaming:!0,accepting:!0,queued:t.queued?e.queued+1:e.queued};case`turn-done`:{let n=Math.max(0,e.queued-1);return{...e,totals:t.totals,queued:n,streaming:e.queued>0}}case`finalized`:return{...e,streaming:!1,finalizing:!1,accepting:!1,queued:0,totals:t.totals??e.totals};case`accepting`:return t.accepting?{...e,accepting:!0}:{...e,accepting:!1,streaming:!1,queued:0};case`finalize-request`:return{...e,finalizing:!0};case`finalize-reject`:return{...e,finalizing:!1};case`blocked`:return{...e,accepting:!1,streaming:!1};default:return e}}function tt(){try{return b()}catch{return null}}function nt({jobId:e,projectId:t,settleMode:o,initialAcceptingTurns:s,kind:c=`job`,variant:l=`page`,onFinalized:u}){let{t:d}=i(`jobs`),p=o??`finalize`,h=()=>t?`${n}/api/projects/${t}`:R(),[_,v]=(0,G.useReducer)(et,{streaming:!1,queued:0,totals:null,accepting:s??!0,finalizing:!1}),[y,b]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),w=(0,G.useRef)(null);(0,G.useEffect)(()=>{s!==void 0&&v({type:`accepting`,accepting:s})},[s]);let T=(0,G.useRef)(u);T.current=u;let E=tt(),D=(0,G.useId)();(0,G.useEffect)(()=>{if(!E)return;let t=`interactive-composer-${e}-${D}`;return E.registerHandler(t,t=>{let n=t;n.jobId===e&&(n.type===`job.turn_user`?v({type:`turn-user`,queued:!!n.queued}):n.type===`job.turn_done`?v({type:`turn-done`,totals:n.totals}):n.type===`job.finalized`?(v({type:`finalized`,totals:n.totals??null}),T.current?.()):n.type===`job.interactive`&&v({type:`accepting`,accepting:!!n.acceptingTurns}))}),()=>E.unregisterHandler(t)},[E,e,D]);let O=c===`loop-step`&&!_.accepting;async function k(){let t=y.trim();if(!(!t||S||O)){C(!0);try{let n=await fetch(`${h()}/jobs/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)b(``),requestAnimationFrame(()=>w.current?.focus());else if(n.status===409&&c===`loop-step`)v({type:`blocked`});else{let e=await n.json().catch(()=>({}));U.error(d(`detail.toast.sendFailed`),{description:e.error})}}catch{U.error(d(`detail.toast.networkError`))}finally{C(!1)}}}async function j(){if(!_.finalizing){v({type:`finalize-request`});try{let t=await fetch(`${h()}/jobs/${e}/finalize`,{method:`POST`});if(t.ok)U.success(d(p===`finalize`?`detail.toast.finalizeScheduled`:c===`loop-step`?`detail.toast.wrapUpStepScheduled`:`detail.toast.wrapUpScheduled`));else if(t.status===409&&c===`loop-step`)v({type:`blocked`}),v({type:`finalize-reject`});else{let e=await t.json().catch(()=>({}));U.error(d(`detail.toast.finalizeFailed`),{description:e.error}),v({type:`finalize-reject`})}}catch{U.error(d(`detail.toast.networkError`)),v({type:`finalize-reject`})}}}let M=S||O||!y.trim(),N=d(`detail.interactive.working`);return(0,W.jsxs)(`div`,{"data-testid":`interactive-job-composer`,className:A(`shrink-0 border-t px-3 py-2 space-y-1.5`,`motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-300`,l===`glass`?`border-border/30 bg-surface/30`:`border-border/40 bg-surface/40`),children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[O?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(ie,{className:`h-3 w-3 motion-safe:animate-pulse`}),d(`detail.interactive.waitingForStepShort`)]}):_.streaming?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(x,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,W.jsxs)(`span`,{className:`relative`,children:[N,(0,W.jsx)(`span`,{"aria-hidden":!0,className:`title-shimmer pointer-events-none absolute inset-0`,children:N})]})]}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent-success motion-safe:animate-pulse`}),d(`detail.interactive.ready`)]}),_.queued>0&&(0,W.jsx)(`span`,{className:`rounded-full border border-accent-info/30 bg-accent-info/10 px-1.5 py-px text-[10px] tabular-nums text-accent-info motion-safe:animate-in motion-safe:fade-in`,children:d(`detail.interactive.queued`,{count:_.queued})})]}),(0,W.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.totals&&(0,W.jsx)(`span`,{className:`tabular-nums`,children:d(`detail.interactive.liveTotals`,{turns:_.totals.num_turns,cost:_.totals.total_cost_usd.toFixed(4)})}),p===`finalize`?(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>void j(),disabled:_.finalizing,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,W.jsx)(a,{className:`mr-1.5 h-3.5 w-3.5`}),_.finalizing?d(`detail.finalizing`):d(`detail.finalizeJob`)]})}),(0,W.jsx)(g,{children:d(`detail.finalizeJobTooltip`)})]}):(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:_.finalizing||O,className:A(`text-[11px] underline-offset-2 transition-colors`,O?`cursor-not-allowed text-muted-foreground/40`:`text-muted-foreground hover:text-accent-success hover:underline`),children:_.finalizing?d(`detail.interactive.wrappingUp`):d(c===`loop-step`?`detail.interactive.wrapUpStep`:`detail.interactive.wrapUp`)})}),(0,W.jsx)(g,{children:d(c===`loop-step`?`detail.interactive.wrapUpStepTooltip`:`detail.interactive.wrapUpTooltip`)})]})]})]}),p===`auto`&&(0,W.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground/60`,children:d(O?`detail.interactive.waitingForStep`:`detail.interactive.autoHint`)}),(0,W.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,W.jsx)(`textarea`,{ref:w,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())},rows:2,placeholder:d(O?`detail.interactive.waitingForStepShort`:`detail.interactive.placeholder`),"aria-label":d(`detail.interactive.placeholder`),disabled:O,className:A(`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm transition-opacity focus:outline-none focus:ring-2 focus:ring-ring`,O&&`opacity-60`)}),(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(`span`,{className:`shrink-0`,children:(0,W.jsxs)(I,{size:`sm`,onClick:()=>void k(),disabled:M,className:`h-9`,children:[(0,W.jsx)(f,{className:`mr-1.5 h-3.5 w-3.5`}),d(`detail.interactive.send`)]})})}),M&&!S&&(0,W.jsx)(g,{children:d(O?`detail.interactive.sendDisabledWaiting`:`detail.interactive.sendDisabledEmpty`)})]})]})]})}export{ce as a,le as i,$e as n,ae as o,we as r,nt as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./InteractiveJobComposer-zj8SrOAl.js";import{a as s,n as c}from"./auth-DpZq5p1e.js";import{B as l,Bn as u,H as d,Jn as f,L as p,U as ee,V as m,X as h,Yn as g,Z as _,en as v,et as y,lt as b,ot as x,tt as S,ut as C,wt as w,x as T,zn as E}from"./index-89SuhD4Y.js";var te=e(f(),1),D=e(g(),1),O=[1e3,2e3,4e3,8e3,16e3];function k(e,t){let[n,r]=(0,D.useState)(`connecting`),i=(0,D.useRef)(null),a=(0,D.useRef)(0),o=(0,D.useRef)(null),s=(0,D.useRef)(t);s.current=t;let l=(0,D.useCallback)(()=>{let t=c(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);s.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=O.length){r(`disconnected`);return}let t=O[e];a.current+=1,o.current=setTimeout(l,t)}},[e]);return(0,D.useEffect)(()=>(l(),()=>{o.current&&clearTimeout(o.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[l]),{connectionStatus:n}}var A=b();function ne(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(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`}var j={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function M({jobId:e,onClose:c,projectId:f}){let{t:g}=u(`jobs`),b=(0,D.useCallback)(()=>f?`${s}/api/projects/${f}`:C(),[f]),[O,M]=(0,D.useState)(null),[N,P]=(0,D.useState)([]),[F,I]=(0,D.useState)([]),[L,R]=(0,D.useState)({}),[z,B]=(0,D.useState)(!0),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(!1),[G,K]=(0,D.useState)(!1);(0,D.useEffect)(()=>{async function t(){try{let t=await fetch(`${b()}/jobs/${e}`);if(t.status===404){H(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(M(n.job),P(n.events),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{H(!0)}finally{B(!1)}}t()},[e,b]);let q=(0,D.useCallback)(()=>{fetch(`${b()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&M(e.job)}).catch(()=>{})},[e,b]),J=(0,D.useRef)([]),Y=(0,D.useRef)(null),X=(0,D.useCallback)(()=>{Y.current=null;let e=J.current;e.length!==0&&(J.current=[],P(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,D.useEffect)(()=>()=>{Y.current&&cancelAnimationFrame(Y.current)},[]),k(p,(0,D.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`job.finalized`&&n.jobId===e)q();else if(n.type===`phase`){let e=n.phase,t=n.state;R(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&O&&M(e=>e&&{...e,status:t.status})}},[e,O,X,q])),(0,D.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(U){W(!1);return}c()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,U]);let Z=O?i(O):`job`,Q=Z===`loop-run`;async function re(){K(!0);try{let n=await t({projectId:f??null,jobId:e,kind:Z});n.ok?(E.success(g(Q?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:g(Q?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),q()):E.error(g(`modal.toast.cancelFailed`),{description:n.error})}finally{K(!1)}}let $=O?j[O.status]??j.queued:j.queued,ie=O?.status===`running`,{panelRef:ae,panelStyle:oe,headerHandleProps:se,resizeHandles:ce,isFloating:le,guardBackdrop:ue}=_();return(0,te.createPortal)((0,A.jsx)(d,{delayDuration:400,children:(0,A.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:ue(c)}),(0,A.jsxs)(`div`,{ref:ae,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:oe,children:[(0,A.jsxs)(`div`,{...se,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${le?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[O&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(l,{children:[(0,A.jsx)(ee,{asChild:!0,children:(0,A.jsx)(`div`,{children:(0,A.jsx)(y,{variant:$.variant,children:g($.labelKey)})})}),(0,A.jsx)(m,{children:g($.tooltipKey)})]}),(0,A.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:O.command}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:T(new Date(O.started_at),{addSuffix:!0,locale:x()})}),O.total_cost_usd!=null&&O.total_cost_usd>0&&(0,A.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,O.total_cost_usd.toFixed(4)]}),O.finished_at&&(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ne(O.started_at,O.finished_at)})]}),z&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`common:states.loading`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[F.length>0&&(0,A.jsx)(`div`,{className:`mr-3`,children:(0,A.jsx)(n,{phases:L,phaseDefinitions:F})}),ie&&(0,A.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>W(!0),disabled:G,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[G&&(0,A.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),g(Q?`dashboard:railControls.stop`:Z===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,A.jsx)(`button`,{onClick:c,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,A.jsx)(w,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:V?(0,A.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g(`modal.notFound`)})}):O?.command.startsWith(`loop:`)?(0,A.jsx)(r,{events:N,jobStatus:O.status,isLoading:z,variant:`glass`,projectId:f}):(0,A.jsx)(a,{events:N,isLoading:z,projectId:f})}),!!O?.interactive&&O.status===`running`&&(0,A.jsx)(o,{jobId:e,projectId:f,settleMode:O.interactiveSettleMode,initialAcceptingTurns:O.interactiveAcceptingTurns,kind:O.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:q})]}),(0,A.jsx)(h,{handles:ce}),U&&(0,A.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>W(!1)}),(0,A.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,A.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:g(Q?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,A.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:g(Q?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>W(!1),children:g(`modal.keepRunning`)}),(0,A.jsx)(S,{variant:`destructive`,size:`sm`,onClick:()=>{W(!1),re()},children:g(Q?`modal.stopRun`:Z===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{M as JobDetailModal};
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{a as t,i as n,n as r,r as i,t as a}from"./InteractiveJobComposer-zj8SrOAl.js";import{B as o,Bn as s,C as c,Cn as l,Dn as u,En as d,Gn as ee,Ht as f,Kn as p,Sn as te,Tn as m,U as h,Un as g,V as _,Yn as v,_n as y,b,ct as x,en as S,et as C,it as ne,lt as w,nt as T,ot as E,rn as D,tt as O,ut as k,w as A,x as j,yn as M,zn as N}from"./index-89SuhD4Y.js";import{t as P}from"./format-command-Db1viey1.js";var F=e(v(),1),I=w();function L(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 R(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var z={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function B(e,t){if(t.type===`reset`)return z;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=A(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function V({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[d,ee]=(0,F.useState)(n),f=(0,F.useMemo)(()=>R(t),[t]),p=e.status===`running`,m=e.status===`completed`,[h,g]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(e)},[p]);let[_,v]=(0,F.useReducer)(B,z),y=(0,F.useRef)(e.id);(0,F.useEffect)(()=>{y.current!==e.id&&(y.current=e.id,v({type:`reset`})),v({type:`consume`,events:t})},[e.id,t]);let[b,x]=(0,F.useState)(!0);(0,F.useEffect)(()=>{if(!p)return;x(!0);let e=window.setTimeout(()=>x(!1),8e3);return()=>window.clearTimeout(e)},[p,e.id]);let C=e.finished_at?L(e.started_at,e.finished_at):p?L(e.started_at,h):`—`,ne=!!e.total_cost_usd_estimated,w=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,E=e.num_turns==null?null:String(e.num_turns),D=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),O=D==null?null:`${(D/1e3).toFixed(1)}k`,k=(0,F.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),A=p&&_.steps===0?`connecting`:_.actionKey||`thinking`,j=c.has(A)&&_.actionArg!==``,M=c.has(A)&&!j?`working`:A,N=j?o(`statusPanel.activity.${M}`,{arg:_.actionArg}):o(`statusPanel.activity.${M}`),P=k??(p&&_.steps===0?o(`statusPanel.activity.starting`):null),V=_.steps>0?o(`statusPanel.steps`,{count:_.steps}):null,G=o(p?`statusPanel.inProgress`:m?`statusPanel.completed`:`statusPanel.failed`),re=p?`border-accent-info/20 bg-accent-info/5`:m?`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`,K=p?S:m?l:te,q=p?`w-4 h-4 text-accent-info shrink-0 animate-spin`:m?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,I.jsxs)(`div`,{className:T(`mx-4 my-2 rounded-xl border transition-colors duration-500`,re),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>ee(!d),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,I.jsx)(K,{className:q,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:G}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`tabular-nums`,children:C}),p?V&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:V}):(0,I.jsxs)(I.Fragment,{children:[w&&(0,I.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:w}),f.length>0&&(0,I.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,I.jsx)(u,{className:T(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,d&&`rotate-180`)})]}),d&&(0,I.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:C})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,I.jsx)(S,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),P&&(0,I.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:P}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:N}),V&&(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,V]})]})]}),b&&(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,I.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,I.jsx)(W,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,I.jsx)(W,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,I.jsx)(W,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,I.jsx)(H,{label:o(`statusPanel.duration`),value:C}),(0,I.jsx)(U,{label:o(`statusPanel.cost`),value:w,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(U,{label:o(`statusPanel.turns`),value:E,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(U,{label:o(`statusPanel.tokens`),value:O,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(H,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,I.jsx)(H,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(0,I.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})})]}),f.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,I.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function H({label:e,value:t,valueClass:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:T(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function U({label:e,value:t,valueClass:n,naCaption:r}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:T(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function W({label:e,caption:t,tooltip:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,I.jsx)(M,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var G=4;function re({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,F.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,I.jsx)(K,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,I.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,I.jsx)(m,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,I.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,I.jsx)(`span`,{className:T(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,I.jsxs)(`span`,{className:T(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,I.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var q={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 J(){let{t:e}=s(`jobs`),{id:c}=p(),{activeProjectId:l,projects:u}=ne(),te=u.find(e=>e.id===l)?.provider,m=ee(),{openTicketDetail:v}=b(),[S,w]=(0,F.useState)(null),[A,M]=(0,F.useState)([]),[L,R]=(0,F.useState)([]),[z,B]=(0,F.useState)({}),[H,U]=(0,F.useState)([]),[W,G]=(0,F.useState)(!0),[K,J]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(!c)return;let e=new AbortController;w(null),M([]),R([]),B({}),G(!0),J(!1);async function t(){try{let t=await fetch(`${k()}/jobs/${c}`,{signal:e.signal});if(t.status===404){J(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();w(n.job),M(n.events)}catch(e){if(e.name===`AbortError`)return;J(!0)}finally{e.signal.aborted||G(!1)}}return t(),()=>e.abort()},[c,l]),(0,F.useEffect)(()=>{if(!S?.pipeline_id){U([]);return}let e=S.pipeline_id;fetch(`${k()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&U(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,F.useRef)(l);Y.current=l;let ie=(0,F.useRef)(null);ie.current=S?.status??null;let X=(0,F.useRef)([]),Z=(0,F.useRef)(null),ae=(0,F.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],M(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,F.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(ae)},[ae]);(0,F.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let oe=(0,F.useCallback)(e=>{let t=e;if(!(Y.current&&t.projectId&&t.projectId!==Y.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];R(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;B(n)}else if(t.type===`event`&&t.jobId===c)Q({id:Date.now(),job_id:c??``,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===c)Q({id:Date.now(),job_id:c??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.finalized`&&t.jobId===c)fetch(`${k()}/jobs/${c}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;B(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===c);if(e){let t=e.status,n=ie.current;w(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&n!==`running`)&&fetch(`${k()}/jobs/${c}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{})}}}},[c,Q]),{registerHandler:se,unregisterHandler:ce}=x();(0,F.useEffect)(()=>(se(`job-detail-${c}`,oe),()=>ce(`job-detail-${c}`)),[c,oe,se,ce]),(0,F.useEffect)(()=>{if(!c||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${k()}/jobs/${c}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&w(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[c,S?.status,S?.hasTelemetry]);async function le(){if(!c)return;let n=await t({projectId:null,jobId:c});n.ok?n.status===`deleted`?(N.success(e(`detail.toast.jobDeleted`)),m(`/jobs`)):N.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?N.error(e(`detail.toast.networkError`)):N.error(e(`detail.toast.failed`),{description:n.error})}async function ue(){if(S)try{let t=await fetch(`${k()}/jobs/${S.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){N.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function de(){if(S)try{let t=await fetch(`${k()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));N.success(e(`detail.toast.jobRequeued`)),m(`/jobs/${n.jobId}`)}catch(e){N.error(e.message)}}if(W)return(0,I.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,I.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,I.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(K||!S)return(0,I.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:c})}),(0,I.jsx)(O,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(g,{to:`/`,children:[(0,I.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=q[S.status]??q.queued,fe=S.status===`running`,pe=S.status===`completed`||S.status===`failed`,me=!!S.interactive,he=me&&fe,ge=(S.tickets?.length??0)>0,_e=S.command.startsWith(`loop:`),ve=H.length>1?{totalCostUsd:H.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:H.some(e=>e.total_cost_usd==null),costEstimated:H.some(e=>!!e.total_cost_usd_estimated),nullCostCount:H.filter(e=>e.total_cost_usd==null).length,totalTokensIn:H.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:H.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:H.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:H.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:H.length}:null;return(0,I.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,I.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(g,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,I.jsx)(D,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,I.jsx)(d,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:c?.slice(0,8)})})]}),ge&&(0,I.jsx)(re,{tickets:S.tickets??[],onTicketClick:v}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsx)(`div`,{children:(0,I.jsx)(C,{variant:$.variant,children:e($.labelKey)})})}),(0,I.jsx)(_,{children:e($.tooltipKey)})]}),(0,I.jsx)(`code`,{className:T(`font-mono text-foreground/90 truncate`,ge?`text-xs text-muted-foreground`:`text-sm`),children:P(S.command,te)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,I.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:j(new Date(S.started_at),{addSuffix:!0,locale:E()})}):e(`detail.queuedWaiting`)}),S.model&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsxs)(O,{variant:`outline`,size:`sm`,className:`h-7`,onClick:ue,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,I.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,I.jsx)(_,{children:e(`detail.exportDiagnosticTooltip`)})]}),pe&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsxs)(O,{variant:`outline`,size:`sm`,onClick:de,className:`h-7`,children:[(0,I.jsx)(f,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,I.jsx)(_,{children:e(`detail.reExecuteTooltip`)})]}),fe&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsx)(O,{variant:`outline`,size:`sm`,onClick:le,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(me?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,I.jsx)(_,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,I.jsx)(n,{phases:z,phaseDefinitions:L})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,I.jsx)(V,{job:S,events:A,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:ve??void 0,phases:z,phaseDefinitions:L}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:_e?(0,I.jsx)(r,{events:A,jobStatus:S.status,variant:`page`}):(0,I.jsx)(i,{events:A})}),he&&(0,I.jsx)(a,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{J as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,Bn as n,Cn as r,G as i,Gn as a,J as o,K as s,M as c,Ot as l,Rn as u,Sn as d,U as f,V as p,W as m,X as h,Y as g,Yn as _,Z as v,at as y,bn as b,et as ee,it as x,j as te,lt as ne,ot as re,q as ie,t as S,tn as ae,tt as C,ut as w,wt as T,x as E,zn as D}from"./index-89SuhD4Y.js";import{t as oe}from"./format-command-Db1viey1.js";import{t as O}from"./ExportDropdown-a43XHO3Y.js";var se=u(`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`}]]),k=e(_(),1),A=ne();function j(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 M(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function N(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function P({label:e,a:t,b:n,highlight:r}){return(0,A.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,A.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,A.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function F(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ce({jobIds:e,onClose:t}){let{t:i}=n(`jobs`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(!0),[l,u]=(0,k.useState)(null),{panelRef:f,panelStyle:p,headerHandleProps:m,resizeHandles:g,isFloating:_,guardBackdrop:y}=v();(0,k.useEffect)(()=>{let t=new AbortController;return fetch(`${w()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),c(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),c(!1))}),()=>t.abort()},[e]);function b(e,t){return(0,A.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:i(`comparison.jobN`,{n:t+1})}),(0,A.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,A.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,A.jsx)(r,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,A.jsx)(d,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,A.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:i(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,A.jsxs)(`div`,{ref:f,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:p,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between ${_?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`comparison.title`)}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,A.jsx)(T,{className:`w-4 h-4`})})]}),s&&(0,A.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,A.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,A.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:i(`comparison.loadFailed`,{error:l})}),a&&(()=>{let[e,t]=a.jobs,n=F(e.durationMs,t.durationMs,!0),r=F(e.totalCostUsd,t.totalCostUsd,!0),o=F(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,A.jsx)(`div`,{}),b(e,0),b(t,1)]}),(0,A.jsx)(P,{label:i(`comparison.duration`),a:j(e.durationMs),b:j(t.durationMs),highlight:n}),(0,A.jsx)(P,{label:i(`comparison.cost`),a:M(e.totalCostUsd),b:M(t.totalCostUsd),highlight:r}),(0,A.jsx)(P,{label:i(`comparison.tokensOut`),a:N(e.tokensOut),b:N(t.tokensOut),highlight:o}),(0,A.jsx)(P,{label:i(`comparison.tokensIn`),a:N(e.tokensIn),b:N(t.tokensIn),highlight:null}),(0,A.jsx)(P,{label:i(`comparison.cacheRead`),a:N(e.tokensCacheRead),b:N(t.tokensCacheRead),highlight:null}),(0,A.jsx)(P,{label:i(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,A.jsx)(P,{label:i(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),a&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:i(`comparison.betterValueHint`)})]}),(0,A.jsx)(h,{handles:g})]})}var le={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},ue=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],I={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){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 pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){try{return E(new Date(e),{addSuffix:!0,locale:re()})}catch{return e}}function L(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function R(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function z(e,t,n){if(!t&&!n)return!0;let r=new Date(e).getTime();return Number.isNaN(r)?!0:!(t&&r<L(t)||n&&r>R(n))}var B=10;function V({jobs:e,isLoading:r,onJobsCleared:c,onProposalClick:u,onProposalDelete:d}){let{t:_}=n(`jobs`),y=a(),{activeProjectId:te,projects:ne}=x(),re=ne.find(e=>e.id===te)?.provider,[S,T]=(0,k.useState)(null),[E,O]=(0,k.useState)(``),[j,M]=(0,k.useState)(``),[N,P]=(0,k.useState)(!1),[F,V]=(0,k.useState)(``),[H,U]=(0,k.useState)(``),[W,he]=(0,k.useState)(!1),[G,K]=(0,k.useState)(null),[q,ge]=(0,k.useState)(B),[J,_e]=(0,k.useState)(!1),[Y,X]=(0,k.useState)([]),[ve,Z]=(0,k.useState)(null),{panelRef:ye,panelStyle:be,headerHandleProps:xe,resizeHandles:Se,isFloating:Ce,guardBackdrop:we}=v();(0,k.useEffect)(()=>{ge(B)},[e.length]);function Te(){_e(e=>!e),X([])}function Ee(e){X(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&&Z(n),n})}let Q=e.filter(e=>S&&e.status!==S?!1:z(e.started_at,E,j)),De=e.filter(e=>z(e.started_at,F,H)).length;async function $(e){he(!0);try{let t={};e===`range`&&(F&&(t.from=new Date(L(F)).toISOString()),H&&(t.to=new Date(R(H)).toISOString()));let n=await fetch(`${w()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();D.success(_(`recent.toast.cleared`,{count:e.deleted})),P(!1),V(``),U(``),c?.()}else D.error(_(`recent.toast.clearFailed`))}catch{D.error(_(`recent.toast.networkError`))}finally{he(!1)}}return r?(0,A.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,A.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,A.jsx)(b,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,A.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:_(`recent.emptyTitle`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:_(`recent.emptyDescription`)})]}):(0,A.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>T(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:_(`recent.filterAll`,{count:e.length})}),ue.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,A.jsx)(`button`,{type:`button`,onClick:()=>T(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:_(`recent.filterStatus`,{status:_(`statusName.${t}`),count:n})},t)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`date`,value:E,onChange:e=>O(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:_(`recent.fromDate`)}),(0,A.jsx)(`input`,{type:`date`,value:j,onChange:e=>M(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:_(`recent.toDate`)}),(E||j)&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{O(``),M(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:_(`recent.clear`)}),(0,A.jsxs)(t,{children:[(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(C,{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:Te,children:(0,A.jsx)(se,{className:`w-3.5 h-3.5`})})}),(0,A.jsx)(p,{children:_(J?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,A.jsxs)(t,{children:[(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>P(!0),children:(0,A.jsx)(l,{className:`w-3.5 h-3.5`})})}),(0,A.jsx)(p,{children:_(`recent.clearJobs`)})]})]})]}),J&&(0,A.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,A.jsxs)(`span`,{children:[Y.length===0&&_(`recent.selectTwoToCompare`),Y.length===1&&_(`recent.selectOneMore`),Y.length===2&&_(`recent.readyToCompare`)]}),Y.length===2&&(0,A.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Z(Y),children:_(`recent.compareAction`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,A.jsx)(`span`,{className:`w-14`,children:_(`recent.colStatus`)}),(0,A.jsx)(`span`,{className:`flex-1 min-w-0`,children:_(`recent.colCommand`)}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,A.jsx)(`span`,{className:`w-14 text-right`,children:_(`recent.colDuration`)}),(0,A.jsx)(`span`,{className:`w-12 text-right`,children:_(`recent.colTokens`)}),(0,A.jsx)(`span`,{className:`w-12 text-right`,children:_(`recent.colCost`)}),(0,A.jsx)(`span`,{className:`w-20 text-right`,children:_(`recent.colStarted`)})]})]}),(0,A.jsx)(`div`,{className:`space-y-0.5`,children:Q.slice(0,q).map(e=>{let n=le[e.status]??le.queued,r=de(e.total_cost_usd),i=fe(e.started_at,e.finished_at),a=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),o=e.id.startsWith(`proposal:`),s=o?e.id.replace(`proposal:`,``):null,c=Y.includes(e.id),d=J&&!o&&Y.length===2&&!c;return(0,A.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`:d?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(J&&!o){Ee(e.id);return}o&&s?u?.(s):y(`/jobs/${e.id}`)},children:[(0,A.jsxs)(t,{children:[(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(`div`,{children:(0,A.jsx)(ee,{variant:n.variant,children:_(n.labelKey)})})}),(0,A.jsx)(p,{children:_(n.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,A.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${I[e.priority].className}`,children:_(I[e.priority].labelKey)}),e.profile_name&&(0,A.jsxs)(t,{children:[(0,A.jsx)(f,{asChild:!0,children:(0,A.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,A.jsx)(p,{children:_(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,A.jsxs)(t,{children:[(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(ae,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,A.jsxs)(p,{children:[_(`recent.pipelinePart`),e.depends_on_job_id&&` ${_(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,A.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:oe(e.command,re)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,A.jsx)(`span`,{className:`w-14 text-right`,children:i??`—`}),(0,A.jsx)(`span`,{className:`w-12 text-right`,children:a?`${a}`:`—`}),(0,A.jsx)(`span`,{className:`w-12 text-right`,children:r??`—`}),(0,A.jsx)(`span`,{className:`w-20 text-right`,children:me(e.started_at)}),o&&s&&(0,A.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(),K(s)},title:_(`recent.deleteProposal`),children:(0,A.jsx)(l,{className:`w-3 h-3`})})]})]},e.id)})}),Q.length>q&&(0,A.jsx)(`div`,{className:`pt-1 text-center`,children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>e+B),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:_(`recent.loadMore`,{count:Q.length-q})})}),N&&(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:we(()=>P(!1)),children:[(0,A.jsxs)(`div`,{ref:ye,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:be,children:[(0,A.jsxs)(`div`,{...xe,className:Ce?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:_(`recent.clearModal.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:_(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,A.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:W,onClick:()=>$(`all`),children:_(`recent.clearModal.clearAll`,{count:e.length})}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`recent.clearModal.orByRange`)}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`date`,value:F,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:_(`recent.clearModal.fromPlaceholder`)}),(0,A.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:_(`recent.clearModal.toPlaceholder`)})]}),(0,A.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:W||!F&&!H,onClick:()=>$(`range`),children:F||H?_(`recent.clearModal.clearInRange`,{count:De}):_(`recent.clearModal.clearRange`)})]}),(0,A.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>P(!1),children:_(`common:actions.cancel`)})]}),(0,A.jsx)(h,{handles:Se})]}),(0,A.jsx)(m,{open:G!==null,onOpenChange:e=>!e&&K(null),children:(0,A.jsxs)(i,{className:`max-w-sm`,children:[(0,A.jsxs)(o,{children:[(0,A.jsx)(g,{children:_(`recent.deleteProposalConfirm.title`)}),(0,A.jsx)(s,{children:_(`recent.deleteProposalConfirm.description`)})]}),(0,A.jsxs)(ie,{children:[(0,A.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>K(null),children:_(`common:actions.cancel`)}),(0,A.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{G&&d?.(G),K(null)},children:_(`common:actions.delete`)})]})]})}),ve&&(0,A.jsx)(ce,{jobIds:ve,onClose:()=>{Z(null),X([]),_e(!1)}})]})}function H(){let{t:e}=n(`jobs`),{activeProjectId:t}=x(),{recentJobs:r}=S(t),{data:a,isFirstLoad:s,refresh:l}=y({namespace:`jobs`,projectId:t,initialValue:r,fetcher:async()=>{let e=await fetch(`${w()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:u}=y({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async()=>{let e=await fetch(`${w()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),d={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},f=u.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:d[e.status]??`queued`})),p=[...a,...f].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[h,_]=(0,k.useState)(null),v=(0,k.useCallback)(async e=>{try{let t=await fetch(`${w()}/propose/${e}`);if(!t.ok)return;_((await t.json()).proposal)}catch{}},[]),b=(0,k.useCallback)(async t=>{try{(await fetch(`${w()}/propose/${t}`,{method:`DELETE`})).ok&&(D.success(e(`page.proposalDeleted`)),l())}catch{}},[l,e]);return(0,A.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,A.jsx)(O,{baseUrl:`${w()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,A.jsx)(V,{jobs:p,isLoading:s,onJobsCleared:l,onProposalClick:v,onProposalDelete:b}),(0,A.jsx)(m,{open:h!==null,onOpenChange:e=>!e&&_(null),children:(0,A.jsx)(i,{className:`max-w-3xl glass-card`,children:h&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(o,{children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(g,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,A.jsx)(ee,{variant:h.status===`created`?`success`:h.status===`cancelled`?`destructive`:`secondary`,children:h.status})]})}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:h.idea}),h.result_markdown?(0,A.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,A.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,A.jsx)(c,{remarkPlugins:[te],children:h.result_markdown})})}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),h.issue_url&&(0,A.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,A.jsx)(`a`,{href:h.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:h.issue_url})]}),(0,A.jsxs)(ie,{children:[(0,A.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{b(h.id),_(null)},children:e(`common:actions.delete`)}),(0,A.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>_(null),children:e(`common:actions.close`)})]})]})})})]})}export{H as default};