@saga-ai/dashboard 4.2.3 → 4.4.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.
@@ -11,5 +11,5 @@ Error generating stack: `+a.message+`
11
11
  `);return c.length>Lm?c.slice(-Lm):c}function t0({truncatedOutput:s,outputAvailable:r}){const c=_.useRef(null);return _.useLayoutEffect(()=>{s&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[s]),r?s?f.jsx("pre",{ref:c,className:"font-mono bg-bg-dark text-xs p-2 rounded max-h-24 overflow-y-auto whitespace-pre-wrap",role:"presentation",children:s}):null:f.jsx("div",{className:"text-text-muted text-sm italic",children:"Output unavailable"})}function e0({session:s}){const[r,c]=_.useState(()=>{const m=new Date(s.startTime).getTime(),g=Date.now();return Math.floor((g-m)/Gm)}),o=Pb(s.outputPreview);return _.useEffect(()=>{const m=setInterval(()=>{const g=new Date(s.startTime).getTime(),p=Date.now();c(Math.floor((p-g)/Gm))},Ib);return()=>clearInterval(m)},[s.startTime]),f.jsx(il,{to:`/story/${s.storyId}?tab=sessions`,className:"block",children:f.jsxs(ne,{className:"hover:border-primary/50 transition-colors cursor-pointer",children:[f.jsx(ye,{className:"pb-2",children:f.jsx(ua,{className:"text-base",children:s.storyId})}),f.jsxs(Ae,{className:"space-y-2",children:[f.jsx("div",{className:"text-sm text-text-muted",children:eo(r)}),f.jsx(t0,{truncatedOutput:o,outputAvailable:s.outputAvailable})]})]})})}function kc(){return f.jsxs(ne,{className:"animate-pulse min-w-[300px] flex-shrink-0","data-testid":"session-card-skeleton",children:[f.jsxs(ye,{className:"pb-2",children:[f.jsx("div",{className:"h-5 w-32 bg-bg-light rounded"}),f.jsx("div",{className:"h-4 w-20 bg-bg-light rounded mt-1"})]}),f.jsx(Ae,{children:f.jsx("div",{className:"h-16 w-full bg-bg-light rounded"})})]})}function l0(){const{sessions:s,setSessions:r}=wl(),[c,o]=_.useState(!0);_.useEffect(()=>{(async()=>{try{const p=await fetch("/api/sessions?status=running");if(p.ok){const b=await p.json();r(b)}}catch{r([])}finally{o(!1)}})()},[r]);const m=_.useMemo(()=>s.filter(g=>g.status==="running"),[s]);return c?f.jsx(a0,{}):m.length===0?null:f.jsxs("section",{"data-testid":"active-sessions",className:"space-y-4",children:[f.jsx("h2",{className:"text-xl font-semibold text-text",children:"Active Sessions"}),f.jsx("div",{className:"flex gap-4 overflow-x-auto pb-2",children:m.map(g=>f.jsx("div",{className:"min-w-[300px] flex-shrink-0",children:f.jsx(e0,{session:g})},g.name))})]})}function a0(){return f.jsxs("section",{"data-testid":"active-sessions-skeleton",className:"space-y-4",children:[f.jsx("h2",{className:"text-xl font-semibold text-text",children:"Active Sessions"}),f.jsxs("div",{className:"flex gap-4 overflow-x-auto pb-2",children:[f.jsx(kc,{}),f.jsx(kc,{}),f.jsx(kc,{})]})]})}const n0=100;function Kc(){return f.jsxs(ne,{className:"animate-pulse","data-testid":"epic-card-skeleton",children:[f.jsx(ye,{children:f.jsx("div",{className:"h-6 w-48 bg-bg-light rounded"})}),f.jsxs(Ae,{className:"space-y-4",children:[f.jsx("div",{className:"h-4 w-full bg-bg-light rounded"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("div",{className:"h-6 w-16 bg-bg-light rounded-full"}),f.jsx("div",{className:"h-6 w-16 bg-bg-light rounded-full"}),f.jsx("div",{className:"h-6 w-16 bg-bg-light rounded-full"})]})]})]})}function i0({epic:s}){const{storyCounts:r}=s,c=r.total>0?Math.round(r.completed/r.total*n0):0;return f.jsx(il,{to:`/epic/${s.id}`,className:"block",children:f.jsxs(ne,{className:"hover:border-primary/50 transition-colors cursor-pointer",children:[f.jsx(ye,{children:f.jsx(ua,{className:"text-lg",children:s.title})}),f.jsxs(Ae,{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex justify-between text-sm",children:[f.jsx("span",{className:"text-text-muted",children:"Progress"}),f.jsxs("span",{className:"text-text-muted",children:[r.completed,"/",r.total," stories"]})]}),f.jsx(ho,{value:c})]}),f.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.pending>0&&f.jsx(Qc,{status:"pending",count:r.pending}),r.inProgress>0&&f.jsx(Qc,{status:"inProgress",count:r.inProgress}),r.completed>0&&f.jsx(Qc,{status:"completed",count:r.completed})]})]})]})})}function s0(){const{epics:s,setEpics:r}=wl(),[c,o]=_.useState(!0);_.useEffect(()=>{(async()=>{try{const p=await fetch("/api/epics");if(p.ok){const b=await p.json();r(b)}}catch(p){const b=p instanceof Error?p.message:"Unknown error";Sh("/api/epics",b)}finally{o(!1)}})()},[r]);const m=c;return f.jsxs("div",{className:"space-y-6",children:[f.jsx(l0,{}),f.jsx("div",{className:"flex items-center justify-between",children:f.jsx("h1",{className:"text-2xl font-bold text-text",children:"Epics"})}),m&&f.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[f.jsx(Kc,{}),f.jsx(Kc,{}),f.jsx(Kc,{})]}),!m&&s.length===0&&f.jsxs("div",{className:"text-center py-12",children:[f.jsx("p",{className:"text-text-muted text-lg",children:"No epics found."}),f.jsxs("p",{className:"text-text-muted",children:["Run ",f.jsx("code",{className:"text-primary",children:"/create-epic"})," to get started."]})]}),!m&&s.length>0&&f.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:s.map(g=>f.jsx(i0,{epic:g},g.id))})]})}const u0=so("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ah=_.forwardRef(({className:s,variant:r,size:c,asChild:o=!1,...m},g)=>{const p=o?yp:"button";return f.jsx(p,{className:Bt(u0({variant:r,size:c,className:s})),ref:g,...m})});Ah.displayName="Button";function Ka(s,r,c){let o=c.initialDeps??[],m,g=!0;function p(){var b,j,M;let U;c.key&&((b=c.debug)!=null&&b.call(c))&&(U=Date.now());const D=s();if(!(D.length!==o.length||D.some(($,X)=>o[X]!==$)))return m;o=D;let k;if(c.key&&((j=c.debug)!=null&&j.call(c))&&(k=Date.now()),m=r(...D),c.key&&((M=c.debug)!=null&&M.call(c))){const $=Math.round((Date.now()-U)*100)/100,X=Math.round((Date.now()-k)*100)/100,W=X/16,Tt=(jt,xt)=>{for(jt=String(jt);jt.length<xt;)jt=" "+jt;return jt};console.info(`%c⏱ ${Tt(X,5)} /${Tt($,5)} ms`,`
12
12
  font-size: .6rem;
13
13
  font-weight: bold;
14
- color: hsl(${Math.max(0,Math.min(120-120*W,120))}deg 100% 31%);`,c?.key)}return c?.onChange&&!(g&&c.skipInitialOnChange)&&c.onChange(m),g=!1,m}return p.updateDeps=b=>{o=b},p}function Vm(s,r){if(s===void 0)throw new Error("Unexpected undefined");return s}const c0=(s,r)=>Math.abs(s-r)<1.01,o0=(s,r,c)=>{let o;return function(...m){s.clearTimeout(o),o=s.setTimeout(()=>r.apply(this,m),c)}},Xm=s=>{const{offsetWidth:r,offsetHeight:c}=s;return{width:r,height:c}},r0=s=>s,f0=s=>{const r=Math.max(s.startIndex-s.overscan,0),c=Math.min(s.endIndex+s.overscan,s.count-1),o=[];for(let m=r;m<=c;m++)o.push(m);return o},d0=(s,r)=>{const c=s.scrollElement;if(!c)return;const o=s.targetWindow;if(!o)return;const m=p=>{const{width:b,height:j}=p;r({width:Math.round(b),height:Math.round(j)})};if(m(Xm(c)),!o.ResizeObserver)return()=>{};const g=new o.ResizeObserver(p=>{const b=()=>{const j=p[0];if(j?.borderBoxSize){const M=j.borderBoxSize[0];if(M){m({width:M.inlineSize,height:M.blockSize});return}}m(Xm(c))};s.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(b):b()});return g.observe(c,{box:"border-box"}),()=>{g.unobserve(c)}},Qm={passive:!0},Zm=typeof window>"u"?!0:"onscrollend"in window,m0=(s,r)=>{const c=s.scrollElement;if(!c)return;const o=s.targetWindow;if(!o)return;let m=0;const g=s.options.useScrollendEvent&&Zm?()=>{}:o0(o,()=>{r(m,!1)},s.options.isScrollingResetDelay),p=U=>()=>{const{horizontal:D,isRtl:R}=s.options;m=D?c.scrollLeft*(R&&-1||1):c.scrollTop,g(),r(m,U)},b=p(!0),j=p(!1);c.addEventListener("scroll",b,Qm);const M=s.options.useScrollendEvent&&Zm;return M&&c.addEventListener("scrollend",j,Qm),()=>{c.removeEventListener("scroll",b),M&&c.removeEventListener("scrollend",j)}},h0=(s,r,c)=>{if(r?.borderBoxSize){const o=r.borderBoxSize[0];if(o)return Math.round(o[c.options.horizontal?"inlineSize":"blockSize"])}return s[c.options.horizontal?"offsetWidth":"offsetHeight"]},g0=(s,{adjustments:r=0,behavior:c},o)=>{var m,g;const p=s+r;(g=(m=o.scrollElement)==null?void 0:m.scrollTo)==null||g.call(m,{[o.options.horizontal?"left":"top"]:p,behavior:c})};class y0{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let c=null;const o=()=>c||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:c=new this.targetWindow.ResizeObserver(m=>{m.forEach(g=>{const p=()=>{this._measureElement(g.target,g)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(p):p()})}));return{disconnect:()=>{var m;(m=o())==null||m.disconnect(),c=null},observe:m=>{var g;return(g=o())==null?void 0:g.observe(m,{box:"border-box"})},unobserve:m=>{var g;return(g=o())==null?void 0:g.unobserve(m)}}})(),this.range=null,this.setOptions=c=>{Object.entries(c).forEach(([o,m])=>{typeof m>"u"&&delete c[o]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:r0,rangeExtractor:f0,onChange:()=>{},measureElement:h0,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,...c}},this.notify=c=>{var o,m;(m=(o=this.options).onChange)==null||m.call(o,this,c)},this.maybeNotify=Ka(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),c=>{this.notify(c)},{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(c=>c()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var c;const o=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==o){if(this.cleanup(),!o){this.maybeNotify();return}this.scrollElement=o,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((c=this.scrollElement)==null?void 0:c.window)??null,this.elementsCache.forEach(m=>{this.observer.observe(m)}),this.unsubs.push(this.options.observeElementRect(this,m=>{this.scrollRect=m,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(m,g)=>{this.scrollAdjustments=0,this.scrollDirection=g?this.getScrollOffset()<m?"forward":"backward":null,this.scrollOffset=m,this.isScrolling=g,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},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=(c,o)=>{const m=new Map,g=new Map;for(let p=o-1;p>=0;p--){const b=c[p];if(m.has(b.lane))continue;const j=g.get(b.lane);if(j==null||b.end>j.end?g.set(b.lane,b):b.end<j.end&&m.set(b.lane,!0),m.size===this.options.lanes)break}return g.size===this.options.lanes?Array.from(g.values()).sort((p,b)=>p.end===b.end?p.index-b.index:p.end-b.end)[0]:void 0},this.getMeasurementOptions=Ka(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(c,o,m,g,p,b)=>(this.prevLanes!==void 0&&this.prevLanes!==b&&(this.lanesChangedFlag=!0),this.prevLanes=b,this.pendingMeasuredCacheIndexes=[],{count:c,paddingStart:o,scrollMargin:m,getItemKey:g,enabled:p,lanes:b}),{key:!1}),this.getMeasurements=Ka(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:c,paddingStart:o,scrollMargin:m,getItemKey:g,enabled:p,lanes:b},j)=>{if(!p)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>c)for(const R of this.laneAssignments.keys())R>=c&&this.laneAssignments.delete(R);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(R=>{this.itemSizeCache.set(R.key,R.size)}));const M=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===c&&(this.lanesSettling=!1);const U=this.measurementsCache.slice(0,M),D=new Array(b).fill(void 0);for(let R=0;R<M;R++){const k=U[R];k&&(D[k.lane]=R)}for(let R=M;R<c;R++){const k=g(R),$=this.laneAssignments.get(R);let X,W;if($!==void 0&&this.options.lanes>1){X=$;const vt=D[X],qt=vt!==void 0?U[vt]:void 0;W=qt?qt.end+this.options.gap:o+m}else{const vt=this.options.lanes===1?U[R-1]:this.getFurthestMeasurement(U,R);W=vt?vt.end+this.options.gap:o+m,X=vt?vt.lane:R%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(R,X)}const Tt=j.get(k),jt=typeof Tt=="number"?Tt:this.options.estimateSize(R),xt=W+jt;U[R]={index:R,start:W,size:jt,end:xt,key:k,lane:X},D[X]=R}return this.measurementsCache=U,U},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ka(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(c,o,m,g)=>this.range=c.length>0&&o>0?p0({measurements:c,outerSize:o,scrollOffset:m,lanes:g}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ka(()=>{let c=null,o=null;const m=this.calculateRange();return m&&(c=m.startIndex,o=m.endIndex),this.maybeNotify.updateDeps([this.isScrolling,c,o]),[this.options.rangeExtractor,this.options.overscan,this.options.count,c,o]},(c,o,m,g,p)=>g===null||p===null?[]:c({startIndex:g,endIndex:p,overscan:o,count:m}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=c=>{const o=this.options.indexAttribute,m=c.getAttribute(o);return m?parseInt(m,10):(console.warn(`Missing attribute name '${o}={index}' on measured element.`),-1)},this._measureElement=(c,o)=>{const m=this.indexFromElement(c),g=this.measurementsCache[m];if(!g)return;const p=g.key,b=this.elementsCache.get(p);b!==c&&(b&&this.observer.unobserve(b),this.observer.observe(c),this.elementsCache.set(p,c)),c.isConnected&&this.resizeItem(m,this.options.measureElement(c,o,this))},this.resizeItem=(c,o)=>{const m=this.measurementsCache[c];if(!m)return;const g=this.itemSizeCache.get(m.key)??m.size,p=o-g;p!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(m,p,this):m.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=p,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(m.index),this.itemSizeCache=new Map(this.itemSizeCache.set(m.key,o)),this.notify(!1))},this.measureElement=c=>{if(!c){this.elementsCache.forEach((o,m)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(m))});return}this._measureElement(c,void 0)},this.getVirtualItems=Ka(()=>[this.getVirtualIndexes(),this.getMeasurements()],(c,o)=>{const m=[];for(let g=0,p=c.length;g<p;g++){const b=c[g],j=o[b];m.push(j)}return m},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=c=>{const o=this.getMeasurements();if(o.length!==0)return Vm(o[Oh(0,o.length-1,m=>Vm(o[m]).start,c)])},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;{const c=this.scrollElement.document.documentElement;return this.options.horizontal?c.scrollWidth-this.scrollElement.innerWidth:c.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(c,o,m=0)=>{if(!this.scrollElement)return 0;const g=this.getSize(),p=this.getScrollOffset();o==="auto"&&(o=c>=p+g?"end":"start"),o==="center"?c+=(m-g)/2:o==="end"&&(c-=g);const b=this.getMaxScrollOffset();return Math.max(Math.min(b,c),0)},this.getOffsetForIndex=(c,o="auto")=>{c=Math.max(0,Math.min(c,this.options.count-1));const m=this.measurementsCache[c];if(!m)return;const g=this.getSize(),p=this.getScrollOffset();if(o==="auto")if(m.end>=p+g-this.options.scrollPaddingEnd)o="end";else if(m.start<=p+this.options.scrollPaddingStart)o="start";else return[p,o];if(o==="end"&&c===this.options.count-1)return[this.getMaxScrollOffset(),o];const b=o==="end"?m.end+this.options.scrollPaddingEnd:m.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(b,o,m.size),o]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(c,{align:o="start",behavior:m}={})=>{m==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(c,o),{adjustments:void 0,behavior:m})},this.scrollToIndex=(c,{align:o="auto",behavior:m}={})=>{m==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),c=Math.max(0,Math.min(c,this.options.count-1)),this.currentScrollToIndex=c;let g=0;const p=10,b=M=>{if(!this.targetWindow)return;const U=this.getOffsetForIndex(c,M);if(!U){console.warn("Failed to get offset for index:",c);return}const[D,R]=U;this._scrollToOffset(D,{adjustments:void 0,behavior:m}),this.targetWindow.requestAnimationFrame(()=>{const k=()=>{if(this.currentScrollToIndex!==c)return;const $=this.getScrollOffset(),X=this.getOffsetForIndex(c,R);if(!X){console.warn("Failed to get offset for index:",c);return}c0(X[0],$)||j(R)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(k):k()})},j=M=>{this.targetWindow&&this.currentScrollToIndex===c&&(g++,g<p?this.targetWindow.requestAnimationFrame(()=>b(M)):console.warn(`Failed to scroll to index ${c} after ${p} attempts.`))};b(o)},this.scrollBy=(c,{behavior:o}={})=>{o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+c,{adjustments:void 0,behavior:o})},this.getTotalSize=()=>{var c;const o=this.getMeasurements();let m;if(o.length===0)m=this.options.paddingStart;else if(this.options.lanes===1)m=((c=o[o.length-1])==null?void 0:c.end)??0;else{const g=Array(this.options.lanes).fill(null);let p=o.length-1;for(;p>=0&&g.some(b=>b===null);){const b=o[p];g[b.lane]===null&&(g[b.lane]=b.end),p--}m=Math.max(...g.filter(b=>b!==null))}return Math.max(m-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(c,{adjustments:o,behavior:m})=>{this.options.scrollToFn(c,{behavior:m,adjustments:o},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(r)}}const Oh=(s,r,c,o)=>{for(;s<=r;){const m=(s+r)/2|0,g=c(m);if(g<o)s=m+1;else if(g>o)r=m-1;else return m}return s>0?s-1:0};function p0({measurements:s,outerSize:r,scrollOffset:c,lanes:o}){const m=s.length-1,g=j=>s[j].start;if(s.length<=o)return{startIndex:0,endIndex:m};let p=Oh(0,m,g,c),b=p;if(o===1)for(;b<m&&s[b].end<c+r;)b++;else if(o>1){const j=Array(o).fill(0);for(;b<m&&j.some(U=>U<c+r);){const U=s[b];j[U.lane]=U.end,b++}const M=Array(o).fill(c+r);for(;p>=0&&M.some(U=>U>=c);){const U=s[p];M[U.lane]=U.start,p--}p=Math.max(0,p-p%o),b=Math.min(m,b+(o-1-b%o))}return{startIndex:p,endIndex:b}}const km=typeof document<"u"?_.useLayoutEffect:_.useEffect;function v0({useFlushSync:s=!0,...r}){const c=_.useReducer(()=>({}),{})[1],o={...r,onChange:(g,p)=>{var b;s&&p?pp.flushSync(c):c(),(b=r.onChange)==null||b.call(r,g,p)}},[m]=_.useState(()=>new y0(o));return m.setOptions(o),km(()=>m._didMount(),[]),km(()=>m._willUpdate()),m}function b0(s){return v0({observeElementRect:d0,observeElementOffset:m0,scrollToFn:g0,...s})}const Mh=24,x0=5,S0=50;function E0(s){switch(s.subtype){case"pipeline_start":return`[Pipeline] Starting execution for story: ${s.storyId}`;case"pipeline_step":return`[Pipeline] Step ${s.step}: ${s.message}`;case"pipeline_end":return`[Pipeline] ${s.status==="completed"?"Completed":"Incomplete"} - ${s.cycles} cycles, ${s.elapsedMinutes}min (exit: ${s.exitCode})`;case"cycle_start":return`[Cycle ${s.cycle}/${s.maxCycles}] Starting`;case"cycle_end":return`[Cycle ${s.cycle}] Ended${s.exitCode!=null?` (exit: ${s.exitCode})`:""}`;default:return JSON.stringify(s)}}function N0(s){const r=typeof s.message=="object"&&s.message!==null?s.message.content:s.content;return typeof r=="string"?r:null}function z0(s){return s.type==="text"?s.content||"":s.type==="saga_worker"?E0(s):s.type==="assistant"?N0(s)??JSON.stringify(s):s.type==="result"&&typeof s.result=="string"?`[Result] ${s.result}`:JSON.stringify(s)}function T0(s){return s.type==="saga_worker"?s.subtype==="pipeline_end"?s.status==="completed"?"text-success":"text-danger":"text-primary":"text-text"}function j0({status:s}){return s==="running"?f.jsxs("div",{"data-testid":"status-indicator-streaming",className:"flex items-center gap-1.5 text-primary text-sm",children:[f.jsx(pv,{className:"h-3.5 w-3.5 animate-spin","data-testid":"status-icon-loader"}),f.jsx("span",{children:"Streaming"})]}):f.jsxs("div",{"data-testid":"status-indicator-complete",className:"flex items-center gap-1.5 text-success text-sm",children:[f.jsx(vs,{className:"h-3.5 w-3.5","data-testid":"status-icon-complete"}),f.jsx("span",{children:"Complete"})]})}function A0(){return f.jsxs("div",{"data-testid":"log-viewer-skeleton",className:"p-4 space-y-2",children:[f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-3/4"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-1/2"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-5/6"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-2/3"})]})}function O0({status:s,autoScroll:r,onToggleAutoScroll:c}){return f.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bg-light",children:[f.jsx(j0,{status:s}),f.jsxs("button",{type:"button","data-testid":"auto-scroll-toggle",onClick:c,"aria-pressed":r,title:r?"Autoscroll locked to bottom":"Autoscroll unlocked",className:`flex items-center gap-1.5 px-2 py-1 text-xs rounded-md transition-colors ${r?"bg-success/20 text-success hover:bg-success/30":"bg-bg-light text-text-muted hover:bg-bg-lighter"}`,children:[r?f.jsx(Sv,{className:"h-3.5 w-3.5","data-testid":"autoscroll-icon-enabled"}):f.jsx(bv,{className:"h-3.5 w-3.5","data-testid":"autoscroll-icon-disabled"}),f.jsx("span",{children:"Autoscroll"})]})]})}function M0({virtualizer:s,virtualItems:r,messages:c}){return f.jsx("div",{className:"relative w-full",style:{height:`${s.getTotalSize()}px`},"data-testid":"log-height-container",children:f.jsx("div",{className:"absolute top-0 left-0 w-full px-4",style:{transform:`translateY(${r[0]?.start??0}px)`},children:r.map(o=>{const m=c[o.index];return f.jsx("div",{"data-testid":"log-line","data-index":o.index,className:`leading-relaxed ${m?T0(m):"text-text"}`,style:{height:`${Mh}px`},children:m?z0(m):" "},o.key)})})})}function C0(){return f.jsx("div",{"data-testid":"log-viewer",className:"h-full bg-bg-dark rounded-md font-mono flex items-center justify-center",children:f.jsx("span",{className:"text-text-muted",children:"Output unavailable"})})}function D0({error:s}){return f.jsxs("div",{"data-testid":"log-viewer",className:"h-full bg-bg-dark rounded-md font-mono flex flex-col items-center justify-center gap-2",children:[f.jsx(ps,{className:"h-6 w-6 text-danger"}),f.jsx("span",{className:"text-danger text-sm",children:"Failed to load logs"}),f.jsx("span",{className:"text-text-muted text-xs max-w-xs text-center",children:s})]})}function _0(s,r){const[c,o]=_.useState([]),[m,g]=_.useState(!0),[p,b]=_.useState(!1),[j,M]=_.useState(null);return _.useEffect(()=>{if(!r){g(!1);return}const U=Tm();if(!U){g(!1);return}return Gp(s,(D,R,k)=>{R?(o(D),g(!1)):o($=>[...$,...D]),k&&b(!0)},D=>{M(D),g(!1)}),U({event:"subscribe:logs",data:{sessionName:s}}),()=>{Lp(s);const D=Tm();D&&D({event:"unsubscribe:logs",data:{sessionName:s}})}},[s,r]),{messages:c,isLoading:m,streamComplete:p,error:j}}function R0(s,r,c,o){const[m,g]=_.useState(c==="running"),p=_.useRef(0);_.useEffect(()=>{m&&o>p.current&&requestAnimationFrame(()=>{if(r.current&&s.current){const M=r.current.getTotalSize();s.current.scrollTop=M}}),p.current=o},[o,m,r,s]);const b=_.useCallback(()=>{const M=s.current;if(!M)return;!(M.scrollHeight-M.scrollTop-M.clientHeight<S0)&&m&&g(!1)},[m,s]),j=_.useCallback(()=>{g(M=>(M||requestAnimationFrame(()=>{if(r.current&&s.current){const U=r.current.getTotalSize();s.current.scrollTop=U}}),!M))},[r,s]);return{autoScroll:m,handleScroll:b,toggleAutoScroll:j}}function U0(s){if(!s)return[];const r=s.split(`
14
+ color: hsl(${Math.max(0,Math.min(120-120*W,120))}deg 100% 31%);`,c?.key)}return c?.onChange&&!(g&&c.skipInitialOnChange)&&c.onChange(m),g=!1,m}return p.updateDeps=b=>{o=b},p}function Vm(s,r){if(s===void 0)throw new Error("Unexpected undefined");return s}const c0=(s,r)=>Math.abs(s-r)<1.01,o0=(s,r,c)=>{let o;return function(...m){s.clearTimeout(o),o=s.setTimeout(()=>r.apply(this,m),c)}},Xm=s=>{const{offsetWidth:r,offsetHeight:c}=s;return{width:r,height:c}},r0=s=>s,f0=s=>{const r=Math.max(s.startIndex-s.overscan,0),c=Math.min(s.endIndex+s.overscan,s.count-1),o=[];for(let m=r;m<=c;m++)o.push(m);return o},d0=(s,r)=>{const c=s.scrollElement;if(!c)return;const o=s.targetWindow;if(!o)return;const m=p=>{const{width:b,height:j}=p;r({width:Math.round(b),height:Math.round(j)})};if(m(Xm(c)),!o.ResizeObserver)return()=>{};const g=new o.ResizeObserver(p=>{const b=()=>{const j=p[0];if(j?.borderBoxSize){const M=j.borderBoxSize[0];if(M){m({width:M.inlineSize,height:M.blockSize});return}}m(Xm(c))};s.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(b):b()});return g.observe(c,{box:"border-box"}),()=>{g.unobserve(c)}},Qm={passive:!0},Zm=typeof window>"u"?!0:"onscrollend"in window,m0=(s,r)=>{const c=s.scrollElement;if(!c)return;const o=s.targetWindow;if(!o)return;let m=0;const g=s.options.useScrollendEvent&&Zm?()=>{}:o0(o,()=>{r(m,!1)},s.options.isScrollingResetDelay),p=U=>()=>{const{horizontal:D,isRtl:R}=s.options;m=D?c.scrollLeft*(R&&-1||1):c.scrollTop,g(),r(m,U)},b=p(!0),j=p(!1);c.addEventListener("scroll",b,Qm);const M=s.options.useScrollendEvent&&Zm;return M&&c.addEventListener("scrollend",j,Qm),()=>{c.removeEventListener("scroll",b),M&&c.removeEventListener("scrollend",j)}},h0=(s,r,c)=>{if(r?.borderBoxSize){const o=r.borderBoxSize[0];if(o)return Math.round(o[c.options.horizontal?"inlineSize":"blockSize"])}return s[c.options.horizontal?"offsetWidth":"offsetHeight"]},g0=(s,{adjustments:r=0,behavior:c},o)=>{var m,g;const p=s+r;(g=(m=o.scrollElement)==null?void 0:m.scrollTo)==null||g.call(m,{[o.options.horizontal?"left":"top"]:p,behavior:c})};class y0{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let c=null;const o=()=>c||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:c=new this.targetWindow.ResizeObserver(m=>{m.forEach(g=>{const p=()=>{this._measureElement(g.target,g)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(p):p()})}));return{disconnect:()=>{var m;(m=o())==null||m.disconnect(),c=null},observe:m=>{var g;return(g=o())==null?void 0:g.observe(m,{box:"border-box"})},unobserve:m=>{var g;return(g=o())==null?void 0:g.unobserve(m)}}})(),this.range=null,this.setOptions=c=>{Object.entries(c).forEach(([o,m])=>{typeof m>"u"&&delete c[o]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:r0,rangeExtractor:f0,onChange:()=>{},measureElement:h0,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,...c}},this.notify=c=>{var o,m;(m=(o=this.options).onChange)==null||m.call(o,this,c)},this.maybeNotify=Ka(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),c=>{this.notify(c)},{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(c=>c()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var c;const o=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==o){if(this.cleanup(),!o){this.maybeNotify();return}this.scrollElement=o,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((c=this.scrollElement)==null?void 0:c.window)??null,this.elementsCache.forEach(m=>{this.observer.observe(m)}),this.unsubs.push(this.options.observeElementRect(this,m=>{this.scrollRect=m,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(m,g)=>{this.scrollAdjustments=0,this.scrollDirection=g?this.getScrollOffset()<m?"forward":"backward":null,this.scrollOffset=m,this.isScrolling=g,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},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=(c,o)=>{const m=new Map,g=new Map;for(let p=o-1;p>=0;p--){const b=c[p];if(m.has(b.lane))continue;const j=g.get(b.lane);if(j==null||b.end>j.end?g.set(b.lane,b):b.end<j.end&&m.set(b.lane,!0),m.size===this.options.lanes)break}return g.size===this.options.lanes?Array.from(g.values()).sort((p,b)=>p.end===b.end?p.index-b.index:p.end-b.end)[0]:void 0},this.getMeasurementOptions=Ka(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(c,o,m,g,p,b)=>(this.prevLanes!==void 0&&this.prevLanes!==b&&(this.lanesChangedFlag=!0),this.prevLanes=b,this.pendingMeasuredCacheIndexes=[],{count:c,paddingStart:o,scrollMargin:m,getItemKey:g,enabled:p,lanes:b}),{key:!1}),this.getMeasurements=Ka(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:c,paddingStart:o,scrollMargin:m,getItemKey:g,enabled:p,lanes:b},j)=>{if(!p)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>c)for(const R of this.laneAssignments.keys())R>=c&&this.laneAssignments.delete(R);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(R=>{this.itemSizeCache.set(R.key,R.size)}));const M=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===c&&(this.lanesSettling=!1);const U=this.measurementsCache.slice(0,M),D=new Array(b).fill(void 0);for(let R=0;R<M;R++){const k=U[R];k&&(D[k.lane]=R)}for(let R=M;R<c;R++){const k=g(R),$=this.laneAssignments.get(R);let X,W;if($!==void 0&&this.options.lanes>1){X=$;const vt=D[X],qt=vt!==void 0?U[vt]:void 0;W=qt?qt.end+this.options.gap:o+m}else{const vt=this.options.lanes===1?U[R-1]:this.getFurthestMeasurement(U,R);W=vt?vt.end+this.options.gap:o+m,X=vt?vt.lane:R%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(R,X)}const Tt=j.get(k),jt=typeof Tt=="number"?Tt:this.options.estimateSize(R),xt=W+jt;U[R]={index:R,start:W,size:jt,end:xt,key:k,lane:X},D[X]=R}return this.measurementsCache=U,U},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ka(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(c,o,m,g)=>this.range=c.length>0&&o>0?p0({measurements:c,outerSize:o,scrollOffset:m,lanes:g}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ka(()=>{let c=null,o=null;const m=this.calculateRange();return m&&(c=m.startIndex,o=m.endIndex),this.maybeNotify.updateDeps([this.isScrolling,c,o]),[this.options.rangeExtractor,this.options.overscan,this.options.count,c,o]},(c,o,m,g,p)=>g===null||p===null?[]:c({startIndex:g,endIndex:p,overscan:o,count:m}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=c=>{const o=this.options.indexAttribute,m=c.getAttribute(o);return m?parseInt(m,10):(console.warn(`Missing attribute name '${o}={index}' on measured element.`),-1)},this._measureElement=(c,o)=>{const m=this.indexFromElement(c),g=this.measurementsCache[m];if(!g)return;const p=g.key,b=this.elementsCache.get(p);b!==c&&(b&&this.observer.unobserve(b),this.observer.observe(c),this.elementsCache.set(p,c)),c.isConnected&&this.resizeItem(m,this.options.measureElement(c,o,this))},this.resizeItem=(c,o)=>{const m=this.measurementsCache[c];if(!m)return;const g=this.itemSizeCache.get(m.key)??m.size,p=o-g;p!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(m,p,this):m.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=p,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(m.index),this.itemSizeCache=new Map(this.itemSizeCache.set(m.key,o)),this.notify(!1))},this.measureElement=c=>{if(!c){this.elementsCache.forEach((o,m)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(m))});return}this._measureElement(c,void 0)},this.getVirtualItems=Ka(()=>[this.getVirtualIndexes(),this.getMeasurements()],(c,o)=>{const m=[];for(let g=0,p=c.length;g<p;g++){const b=c[g],j=o[b];m.push(j)}return m},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=c=>{const o=this.getMeasurements();if(o.length!==0)return Vm(o[Oh(0,o.length-1,m=>Vm(o[m]).start,c)])},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;{const c=this.scrollElement.document.documentElement;return this.options.horizontal?c.scrollWidth-this.scrollElement.innerWidth:c.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(c,o,m=0)=>{if(!this.scrollElement)return 0;const g=this.getSize(),p=this.getScrollOffset();o==="auto"&&(o=c>=p+g?"end":"start"),o==="center"?c+=(m-g)/2:o==="end"&&(c-=g);const b=this.getMaxScrollOffset();return Math.max(Math.min(b,c),0)},this.getOffsetForIndex=(c,o="auto")=>{c=Math.max(0,Math.min(c,this.options.count-1));const m=this.measurementsCache[c];if(!m)return;const g=this.getSize(),p=this.getScrollOffset();if(o==="auto")if(m.end>=p+g-this.options.scrollPaddingEnd)o="end";else if(m.start<=p+this.options.scrollPaddingStart)o="start";else return[p,o];if(o==="end"&&c===this.options.count-1)return[this.getMaxScrollOffset(),o];const b=o==="end"?m.end+this.options.scrollPaddingEnd:m.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(b,o,m.size),o]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(c,{align:o="start",behavior:m}={})=>{m==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(c,o),{adjustments:void 0,behavior:m})},this.scrollToIndex=(c,{align:o="auto",behavior:m}={})=>{m==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),c=Math.max(0,Math.min(c,this.options.count-1)),this.currentScrollToIndex=c;let g=0;const p=10,b=M=>{if(!this.targetWindow)return;const U=this.getOffsetForIndex(c,M);if(!U){console.warn("Failed to get offset for index:",c);return}const[D,R]=U;this._scrollToOffset(D,{adjustments:void 0,behavior:m}),this.targetWindow.requestAnimationFrame(()=>{const k=()=>{if(this.currentScrollToIndex!==c)return;const $=this.getScrollOffset(),X=this.getOffsetForIndex(c,R);if(!X){console.warn("Failed to get offset for index:",c);return}c0(X[0],$)||j(R)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(k):k()})},j=M=>{this.targetWindow&&this.currentScrollToIndex===c&&(g++,g<p?this.targetWindow.requestAnimationFrame(()=>b(M)):console.warn(`Failed to scroll to index ${c} after ${p} attempts.`))};b(o)},this.scrollBy=(c,{behavior:o}={})=>{o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+c,{adjustments:void 0,behavior:o})},this.getTotalSize=()=>{var c;const o=this.getMeasurements();let m;if(o.length===0)m=this.options.paddingStart;else if(this.options.lanes===1)m=((c=o[o.length-1])==null?void 0:c.end)??0;else{const g=Array(this.options.lanes).fill(null);let p=o.length-1;for(;p>=0&&g.some(b=>b===null);){const b=o[p];g[b.lane]===null&&(g[b.lane]=b.end),p--}m=Math.max(...g.filter(b=>b!==null))}return Math.max(m-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(c,{adjustments:o,behavior:m})=>{this.options.scrollToFn(c,{behavior:m,adjustments:o},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(r)}}const Oh=(s,r,c,o)=>{for(;s<=r;){const m=(s+r)/2|0,g=c(m);if(g<o)s=m+1;else if(g>o)r=m-1;else return m}return s>0?s-1:0};function p0({measurements:s,outerSize:r,scrollOffset:c,lanes:o}){const m=s.length-1,g=j=>s[j].start;if(s.length<=o)return{startIndex:0,endIndex:m};let p=Oh(0,m,g,c),b=p;if(o===1)for(;b<m&&s[b].end<c+r;)b++;else if(o>1){const j=Array(o).fill(0);for(;b<m&&j.some(U=>U<c+r);){const U=s[b];j[U.lane]=U.end,b++}const M=Array(o).fill(c+r);for(;p>=0&&M.some(U=>U>=c);){const U=s[p];M[U.lane]=U.start,p--}p=Math.max(0,p-p%o),b=Math.min(m,b+(o-1-b%o))}return{startIndex:p,endIndex:b}}const km=typeof document<"u"?_.useLayoutEffect:_.useEffect;function v0({useFlushSync:s=!0,...r}){const c=_.useReducer(()=>({}),{})[1],o={...r,onChange:(g,p)=>{var b;s&&p?pp.flushSync(c):c(),(b=r.onChange)==null||b.call(r,g,p)}},[m]=_.useState(()=>new y0(o));return m.setOptions(o),km(()=>m._didMount(),[]),km(()=>m._willUpdate()),m}function b0(s){return v0({observeElementRect:d0,observeElementOffset:m0,scrollToFn:g0,...s})}const Mh=24,x0=5,S0=50;function E0(s){switch(s.subtype){case"pipeline_start":return`[Pipeline] Starting execution for story: ${s.storyId}`;case"pipeline_step":return`[Pipeline] Step ${s.step}: ${s.message}`;case"pipeline_end":return`[Pipeline] ${s.status==="completed"?"Completed":"Incomplete"} - ${s.cycles} cycles, ${s.elapsedMinutes}min (exit: ${s.exitCode})`;case"cycle_start":return`[Cycle ${s.cycle}/${s.maxCycles}] Starting`;case"cycle_end":return`[Cycle ${s.cycle}] Ended${s.exitCode!=null?` (exit: ${s.exitCode})`:""}`;default:return JSON.stringify(s)}}function N0(s){const r=typeof s.message=="object"&&s.message!==null?s.message.content:s.content;return typeof r=="string"?r:null}function z0(s){return s.type==="text"?s.content||"":s.type==="saga_worker"?E0(s):s.type==="assistant"?N0(s)??JSON.stringify(s):s.type==="result"&&typeof s.result=="string"?`[Result] ${s.result}`:JSON.stringify(s)}function T0(s){return s.type==="saga_worker"?s.subtype==="pipeline_end"?s.status==="completed"?"text-success":"text-danger":"text-primary":"text-text"}function j0({status:s}){return s==="running"?f.jsxs("div",{"data-testid":"status-indicator-streaming",className:"flex items-center gap-1.5 text-primary text-sm",children:[f.jsx(pv,{className:"h-3.5 w-3.5 animate-spin","data-testid":"status-icon-loader"}),f.jsx("span",{children:"Streaming"})]}):f.jsxs("div",{"data-testid":"status-indicator-complete",className:"flex items-center gap-1.5 text-success text-sm",children:[f.jsx(vs,{className:"h-3.5 w-3.5","data-testid":"status-icon-complete"}),f.jsx("span",{children:"Complete"})]})}function A0(){return f.jsxs("div",{"data-testid":"log-viewer-skeleton",className:"p-4 space-y-2",children:[f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-3/4"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-1/2"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-5/6"}),f.jsx("div",{className:"h-4 bg-bg-light rounded animate-pulse w-2/3"})]})}function O0({status:s,autoScroll:r,onToggleAutoScroll:c}){return f.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bg-light",children:[f.jsx(j0,{status:s}),f.jsxs("button",{type:"button","data-testid":"auto-scroll-toggle",onClick:c,"aria-pressed":r,title:r?"Autoscroll locked to bottom":"Autoscroll unlocked",className:`flex items-center gap-1.5 px-2 py-1 text-xs rounded-md transition-colors ${r?"bg-success/20 text-success hover:bg-success/30":"bg-bg-light text-text-muted hover:bg-bg-lighter"}`,children:[r?f.jsx(Sv,{className:"h-3.5 w-3.5","data-testid":"autoscroll-icon-enabled"}):f.jsx(bv,{className:"h-3.5 w-3.5","data-testid":"autoscroll-icon-disabled"}),f.jsx("span",{children:"Autoscroll"})]})]})}function M0({virtualizer:s,virtualItems:r,messages:c}){return f.jsx("div",{className:"relative w-full",style:{height:`${s.getTotalSize()}px`},"data-testid":"log-height-container",children:f.jsx("div",{className:"absolute top-0 left-0 w-full px-4",style:{transform:`translateY(${r[0]?.start??0}px)`},children:r.map(o=>{const m=c[o.index];return f.jsx("div",{"data-testid":"log-line","data-index":o.index,className:`leading-relaxed whitespace-nowrap ${m?T0(m):"text-text"}`,style:{height:`${Mh}px`},children:m?z0(m):" "},o.key)})})})}function C0(){return f.jsx("div",{"data-testid":"log-viewer",className:"h-full bg-bg-dark rounded-md font-mono flex items-center justify-center",children:f.jsx("span",{className:"text-text-muted",children:"Output unavailable"})})}function D0({error:s}){return f.jsxs("div",{"data-testid":"log-viewer",className:"h-full bg-bg-dark rounded-md font-mono flex flex-col items-center justify-center gap-2",children:[f.jsx(ps,{className:"h-6 w-6 text-danger"}),f.jsx("span",{className:"text-danger text-sm",children:"Failed to load logs"}),f.jsx("span",{className:"text-text-muted text-xs max-w-xs text-center",children:s})]})}function _0(s,r){const[c,o]=_.useState([]),[m,g]=_.useState(!0),[p,b]=_.useState(!1),[j,M]=_.useState(null);return _.useEffect(()=>{if(!r){g(!1);return}const U=Tm();if(!U){g(!1);return}return Gp(s,(D,R,k)=>{R?(o(D),g(!1)):o($=>[...$,...D]),k&&b(!0)},D=>{M(D),g(!1)}),U({event:"subscribe:logs",data:{sessionName:s}}),()=>{Lp(s);const D=Tm();D&&D({event:"unsubscribe:logs",data:{sessionName:s}})}},[s,r]),{messages:c,isLoading:m,streamComplete:p,error:j}}function R0(s,r,c,o){const[m,g]=_.useState(c==="running"),p=_.useRef(0);_.useEffect(()=>{m&&o>p.current&&requestAnimationFrame(()=>{if(r.current&&s.current){const M=r.current.getTotalSize();s.current.scrollTop=M}}),p.current=o},[o,m,r,s]);const b=_.useCallback(()=>{const M=s.current;if(!M)return;!(M.scrollHeight-M.scrollTop-M.clientHeight<S0)&&m&&g(!1)},[m,s]),j=_.useCallback(()=>{g(M=>(M||requestAnimationFrame(()=>{if(r.current&&s.current){const U=r.current.getTotalSize();s.current.scrollTop=U}}),!M))},[r,s]);return{autoScroll:m,handleScroll:b,toggleAutoScroll:j}}function U0(s){if(!s)return[];const r=s.split(`
15
15
  `),c=[];for(const o of r){const m=o.trim();if(!m){c.push({type:"text",content:""});continue}try{const g=JSON.parse(m);typeof g=="object"&&g!==null&&g.type?c.push(g):c.push({type:"text",content:m})}catch{c.push({type:"text",content:m})}}return c}function w0(s,r,c,o){const m=_.useRef(null),g=_.useRef(null),{messages:p,isLoading:b,streamComplete:j,error:M}=_0(s,c),U=_.useMemo(()=>U0(o),[o]),D=U.length>0?U:p,R=j?"completed":r,k=b0({count:D.length,getScrollElement:()=>m.current,estimateSize:()=>Mh,overscan:x0});g.current=k;const{autoScroll:$,handleScroll:X,toggleAutoScroll:W}=R0(m,g,R,D.length);return{scrollContainerRef:m,isLoading:b,error:M,effectiveStatus:R,virtualizer:k,autoScroll:$,handleScroll:X,toggleAutoScroll:W,messages:D}}function H0({sessionName:s,status:r,outputAvailable:c,initialContent:o=""}){const{scrollContainerRef:m,isLoading:g,error:p,effectiveStatus:b,virtualizer:j,autoScroll:M,handleScroll:U,toggleAutoScroll:D,messages:R}=w0(s,r,c,o);if(!c)return f.jsx(C0,{});if(p)return f.jsx(D0,{error:p});const k=g&&!o,$=j.getVirtualItems();return f.jsxs("div",{"data-testid":"log-viewer",className:"flex flex-col h-full bg-bg-dark rounded-md",children:[f.jsx(O0,{status:b,autoScroll:M,onToggleAutoScroll:D}),f.jsx("div",{"data-testid":"log-content",ref:m,onScroll:U,className:"flex-1 min-h-0 font-mono overflow-auto",children:k?f.jsx(A0,{}):f.jsx(M0,{virtualizer:j,virtualItems:$,messages:R})})]})}const B0=1e3,q0=1e3;function Jc(){return f.jsx(ne,{className:"animate-pulse","data-testid":"session-card-skeleton",children:f.jsxs(ye,{className:"pb-2",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"h-4 w-4 bg-bg-light rounded"}),f.jsx("div",{className:"h-5 w-48 bg-bg-light rounded"}),f.jsx("div",{className:"h-5 w-16 bg-bg-light rounded-full ml-auto"})]}),f.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[f.jsx("div",{className:"h-4 w-32 bg-bg-light rounded"}),f.jsx("div",{className:"h-4 w-20 bg-bg-light rounded"})]})]})})}function Y0(){return f.jsxs("div",{"data-testid":"sessions-panel-skeleton",className:"space-y-4",children:[f.jsx(Jc,{}),f.jsx(Jc,{}),f.jsx(Jc,{})]})}function Km({status:s}){return s==="running"?f.jsxs(sa,{className:"bg-primary/20 text-primary flex items-center gap-1",children:[f.jsx(Nv,{className:"w-3 h-3"}),"Running"]}):f.jsxs(sa,{className:"bg-success/20 text-success flex items-center gap-1",children:[f.jsx(vs,{className:"w-3 h-3"}),"Completed"]})}function Jm(s){return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Wc(s,r){const c=new Date(s).getTime(),o=r?new Date(r).getTime():Date.now();return Math.floor((o-c)/B0)}function G0(s,r,c){const[o,m]=_.useState(()=>Wc(s,r));return _.useEffect(()=>{if(!c){m(Wc(s,r));return}const g=setInterval(()=>{m(Wc(s,r))},q0);return()=>clearInterval(g)},[s,r,c]),o}function L0({session:s,defaultExpanded:r=!1}){const[c,o]=_.useState(r),m=s.status==="running",g=G0(s.startTime,s.endTime,m);return s.outputAvailable?f.jsx(mo,{open:c,onOpenChange:o,children:f.jsxs(ne,{"data-testid":"session-detail-card",children:[f.jsx(fo,{asChild:!0,children:f.jsxs(ye,{"data-testid":"session-card-trigger",className:"cursor-pointer hover:bg-bg-light/50 transition-colors py-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[c?f.jsx(uo,{className:"w-4 h-4 text-text-muted"}):f.jsx(co,{className:"w-4 h-4 text-text-muted"}),f.jsx(Pc,{className:"w-4 h-4 text-text-muted"}),f.jsx("span",{className:"font-medium text-text truncate",children:s.name}),f.jsx(Km,{status:s.status})]}),f.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-text-muted pl-8",children:[f.jsxs("span",{children:["Started at ",Jm(s.startTime)]}),f.jsx("span",{children:eo(g)})]})]})}),f.jsx(ro,{children:f.jsx(Ae,{className:"pt-0 pb-4",children:f.jsx("div",{className:"h-64",children:f.jsx(H0,{sessionName:s.name,status:s.status,outputAvailable:s.outputAvailable})})})})]})}):f.jsx(ne,{"data-testid":"session-detail-card",className:"opacity-60",children:f.jsxs(ye,{className:"py-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Pc,{className:"w-4 h-4 text-text-muted"}),f.jsx("span",{className:"font-medium text-text truncate",children:s.name}),f.jsx(Km,{status:s.status})]}),f.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-text-muted",children:[f.jsxs("span",{children:["Started at ",Jm(s.startTime)]}),f.jsx("span",{children:eo(g)})]}),f.jsx("div",{className:"mt-2 text-sm text-text-muted italic",children:"Output unavailable"})]})})}function V0(){return f.jsxs("div",{"data-testid":"sessions-panel-empty",className:"text-center py-8",children:[f.jsx(Pc,{className:"w-8 h-8 text-text-muted mx-auto mb-2"}),f.jsx("p",{className:"text-text-muted",children:"No sessions found for this story"})]})}function X0({onRetry:s}){return f.jsxs("div",{"data-testid":"sessions-panel-error",className:"text-center py-8",children:[f.jsx(ps,{className:"w-8 h-8 text-danger mx-auto mb-2"}),f.jsx("p",{className:"text-danger font-medium mb-1",children:"Failed to load sessions"}),f.jsx("p",{className:"text-text-muted text-sm mb-4",children:"Something went wrong while fetching sessions."}),f.jsxs(Ah,{variant:"outline",size:"sm",onClick:s,children:[f.jsx(Tv,{className:"w-4 h-4 mr-2"}),"Retry"]})]})}function Q0(s){if(s.length===0)return null;const r=s.filter(c=>c.status==="running");return r.length>0?r[0].name:s[0].name}function Z0(s){const[r,c]=_.useState([]),[o,m]=_.useState(!0),[g,p]=_.useState(!1),b=_.useCallback(async()=>{m(!0),p(!1);try{const j=await fetch(`/api/sessions?storyId=${s}`);if(j.ok){const M=await j.json();c(M)}else p(!0),c([])}catch{p(!0),c([])}finally{m(!1)}},[s]);return _.useEffect(()=>{b()},[b]),{localSessions:r,isLoading:o,error:g,fetchSessions:b}}function k0(s){const{sessions:r}=wl(),{localSessions:c,isLoading:o,error:m,fetchSessions:g}=Z0(s),p=_.useRef(void 0),b=_.useMemo(()=>r.filter(D=>D.storyId===s),[r,s]),j=b.length>0?b:c,M=_.useMemo(()=>[...j].sort((D,R)=>new Date(R.startTime).getTime()-new Date(D.startTime).getTime()),[j]);p.current===void 0&&M.length>0&&(p.current=Q0(M));const U=p.current??null;return{sortedSessions:M,isLoading:o,error:m,fetchSessions:g,autoExpandSessionName:U}}function K0({storyId:s}){const{sortedSessions:r,isLoading:c,error:o,fetchSessions:m,autoExpandSessionName:g}=k0(s);return c?f.jsx(Y0,{}):o?f.jsx("div",{"data-testid":"sessions-panel",children:f.jsx(X0,{onRetry:m})}):r.length===0?f.jsx("div",{"data-testid":"sessions-panel",children:f.jsx(V0,{})}):f.jsx("div",{"data-testid":"sessions-panel",className:"space-y-4",children:r.map(p=>f.jsx(L0,{session:p,defaultExpanded:p.name===g},p.name))})}const Ch=_.forwardRef(({...s},r)=>f.jsx(vp,{ref:r,...s}));Ch.displayName="Tabs";const Dh=_.forwardRef(({className:s,...r},c)=>f.jsx(bp,{ref:c,className:Bt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...r}));Dh.displayName="TabsList";const Zn=_.forwardRef(({className:s,...r},c)=>f.jsx(xp,{ref:c,className:Bt("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs",s),...r}));Zn.displayName="TabsTrigger";const kn=_.forwardRef(({className:s,...r},c)=>f.jsx(Sp,{ref:c,className:Bt("mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...r}));kn.displayName="TabsContent";const J0=["tasks","content","journal","sessions"];function W0(s){const r=s.get("tab");return r&&J0.includes(r)?r:"tasks"}function $0(){return f.jsxs("div",{className:"animate-pulse space-y-4","data-testid":"story-header-skeleton",children:[f.jsx("div",{className:"h-8 w-64 bg-bg-light rounded"}),f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("div",{className:"h-6 w-24 bg-bg-light rounded-full"}),f.jsx("div",{className:"h-4 w-32 bg-bg-light rounded"})]})]})}function F0(){return f.jsxs("div",{className:"animate-pulse space-y-4","data-testid":"story-content-skeleton",children:[f.jsx("div",{className:"h-6 w-48 bg-bg-light rounded"}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"h-4 w-full bg-bg-light rounded"}),f.jsx("div",{className:"h-4 w-3/4 bg-bg-light rounded"}),f.jsx("div",{className:"h-4 w-5/6 bg-bg-light rounded"})]})]})}function I0({status:s}){const r={className:"w-5 h-5 pointer-events-none cursor-default"};switch(s){case"completed":return f.jsx(vs,{...r,className:`${r.className} text-success`,"data-testid":"icon-check-circle"});case"inProgress":return f.jsx(Ic,{...r,className:`${r.className} text-primary fill-primary/20`,"data-testid":"icon-circle-in-progress"});default:return f.jsx(Ic,{...r,className:`${r.className} text-text-muted`,"data-testid":"icon-circle-pending"})}}const Wm={pending:"bg-text-muted/20 text-text-muted",inProgress:"bg-primary/20 text-primary",completed:"bg-success/20 text-success"},P0={pending:"pending",inProgress:"in progress",completed:"completed"};function tx(s){return Wm[s]||Wm.pending}function ex({task:s}){const r=tx(s.status);return f.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-md hover:bg-bg-light/50",children:[f.jsx(I0,{status:s.status}),f.jsx("span",{className:s.status==="completed"?"text-text-muted line-through":"text-text",children:s.subject}),f.jsx(sa,{className:`ml-auto text-xs ${r}`,children:P0[s.status]})]})}function lx(s){switch(s){case"blocker":return{bg:"bg-danger/10",text:"text-danger",border:"border-danger/30"};case"resolution":return{bg:"bg-success/10",text:"text-success",border:"border-success/30"};default:return{bg:"bg-bg-light",text:"text-text",border:"border-border-muted"}}}function ax({entry:s,defaultOpen:r=!1}){const[c,o]=_.useState(r),m=lx(s.type);return f.jsx(mo,{open:c,onOpenChange:o,children:f.jsxs(ne,{className:`${m.bg} border ${m.border}`,children:[f.jsx(fo,{asChild:!0,children:f.jsx(ye,{className:"cursor-pointer hover:bg-bg-light/50 transition-colors py-3",children:f.jsxs("div",{className:"flex items-center gap-3",children:[c?f.jsx(uo,{className:"w-4 h-4 text-text-muted","data-testid":"icon-chevron-down"}):f.jsx(co,{className:"w-4 h-4 text-text-muted","data-testid":"icon-chevron-right"}),f.jsx(sa,{className:`${m.bg} ${m.text} border ${m.border}`,children:s.type}),f.jsx(ua,{className:`text-sm font-medium ${m.text}`,children:s.title}),s.type==="blocker"&&f.jsx(ps,{className:"w-4 h-4 text-danger ml-auto","data-testid":"icon-alert-circle"}),s.timestamp&&f.jsx("span",{className:"text-xs text-text-muted ml-auto",children:s.timestamp})]})})}),f.jsx(ro,{children:f.jsx(Ae,{className:"pt-0 pb-4",children:f.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:f.jsx("pre",{className:"whitespace-pre-wrap text-sm text-text-muted font-mono bg-bg-dark p-3 rounded-md overflow-x-auto",children:s.content})})})})]})})}function nx(s){return s?{completed:s.tasks.filter(r=>r.status==="completed").length,total:s.tasks.length}:{completed:0,total:0}}function _h(s){return{blockers:s.filter(r=>r.type==="blocker"),sessions:s.filter(r=>r.type==="session"),resolutions:s.filter(r=>r.type==="resolution")}}function ix({storyId:s}){return f.jsxs("div",{className:"text-center py-12",children:[f.jsx("h1",{className:"text-2xl font-bold text-text mb-2",children:"Story not found"}),f.jsxs("p",{className:"text-text-muted mb-4",children:['The story "',s,'" does not exist.']}),f.jsx(il,{to:"/",className:"text-primary hover:underline",children:"← Back to epics"})]})}function sx({error:s}){return f.jsxs("div",{className:"text-center py-12",children:[f.jsx("h1",{className:"text-2xl font-bold text-danger mb-2",children:"Error"}),f.jsx("p",{className:"text-text-muted mb-4",children:s}),f.jsx(il,{to:"/",className:"text-primary hover:underline",children:"← Back to epics"})]})}function ux(){return f.jsxs("div",{className:"space-y-6",children:[f.jsx($0,{}),f.jsx(F0,{})]})}function cx({story:s,storyId:r}){const c=nx(s);return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.epic&&f.jsxs(f.Fragment,{children:[f.jsx(il,{to:`/epic/${s.epic}`,className:"hover:text-primary",children:s.epic}),f.jsx("span",{children:"/"})]}),f.jsx("span",{className:"text-text",children:r})]}),f.jsx("h1",{className:"text-2xl font-bold text-text",children:s.title}),f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(zh,{status:s.status}),f.jsxs("span",{className:"text-sm text-text-muted",children:[c.completed,"/",c.total," tasks completed"]})]})]})}function ox({tasks:s}){return f.jsxs(ne,{children:[f.jsx(ye,{children:f.jsx(ua,{className:"text-lg",children:"Tasks"})}),f.jsx(Ae,{children:s.length===0?f.jsx("p",{className:"text-text-muted text-center py-4",children:"No tasks defined for this story."}):f.jsx("div",{className:"divide-y divide-border-muted",children:s.map(r=>f.jsx(ex,{task:r},r.id))})})]})}function rx({content:s}){return f.jsxs(ne,{children:[f.jsx(ye,{children:f.jsx(ua,{className:"text-lg",children:"Story Content"})}),f.jsx(Ae,{children:s?f.jsx("div",{className:"prose prose-sm prose-invert max-w-none prose-headings:text-text prose-p:text-text-muted prose-strong:text-text prose-code:text-primary prose-code:bg-bg-dark prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none prose-pre:bg-bg-dark prose-pre:border prose-pre:border-border-muted prose-a:text-primary prose-a:no-underline prose-a:hover:underline prose-li:text-text-muted prose-table:border prose-table:border-border-muted prose-th:bg-bg-dark prose-th:px-3 prose-th:py-2 prose-th:text-text prose-td:px-3 prose-td:py-2 prose-td:border-t prose-td:border-border-muted",children:f.jsx($m,{remarkPlugins:[Fm],children:s})}):f.jsx("p",{className:"text-text-muted text-center py-4",children:"No story content available."})})]})}function fx(s){return s==="Blockers"?"text-danger":s==="Resolutions"?"text-success":"text-text"}function $c({entries:s,type:r,icon:c}){if(s.length===0)return null;const o=fx(r);return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("h3",{className:`text-sm font-semibold ${o} flex items-center gap-2`,children:[f.jsx(c,{className:"w-4 h-4"}),r," (",s.length,")"]}),s.map(m=>f.jsx(ax,{entry:m,defaultOpen:r==="Blockers"},`${r.toLowerCase()}-${m.title}-${m.timestamp??""}`))]})}function dx({journal:s}){if(s.length===0)return f.jsx(ne,{children:f.jsx(Ae,{className:"py-8",children:f.jsx("p",{className:"text-text-muted text-center",children:"No journal entries yet."})})});const{blockers:r,sessions:c,resolutions:o}=_h(s);return f.jsxs("div",{className:"space-y-4",children:[f.jsx($c,{entries:r,type:"Blockers",icon:ps}),f.jsx($c,{entries:o,type:"Resolutions",icon:vs}),f.jsx($c,{entries:c,type:"Sessions",icon:Ic})]})}function mx(s,r,c,o,m){_.useEffect(()=>{if(r&&c)return o(s),()=>{m(s)}},[s,r,c,o,m])}function hx(s){const{currentStory:r,setCurrentStory:c,clearCurrentStory:o,subscribeToStory:m,unsubscribeFromStory:g,isConnected:p}=wl(),[b,j]=_.useState(!0),[M,U]=_.useState(!1),[D,R]=_.useState(null),k=!!s;return _.useEffect(()=>(k&&(async()=>{j(!0),U(!1),R(null);try{const X=await fetch(`/api/stories/${s}`),W=await Th(X);W.type==="notFound"?U(!0):W.type==="error"?R("Failed to load story"):(qb(W.data),c(W.data))}catch(X){jh(`/api/stories/${s}`,"story",X,R)}finally{j(!1)}})(),o),[s,k,c,o]),mx(s,k,p,m,g),{currentStory:r,loading:b,notFound:M,error:D}}function gx(){const{storyId:s}=lo(),[r]=Op(),{currentStory:c,loading:o,notFound:m,error:g}=hx(s),p=W0(r);if(m)return f.jsx(ix,{storyId:s??""});if(g&&!o)return f.jsx(sx,{error:g});if(o||!c)return f.jsx(ux,{});const{blockers:b}=_h(c.journal??[]);return f.jsxs("div",{className:"space-y-6",children:[f.jsx(cx,{story:c,storyId:s??""}),f.jsxs(Ch,{defaultValue:p,className:"w-full",children:[f.jsxs(Dh,{className:"mb-4",children:[f.jsx(Zn,{value:"tasks",children:"Tasks"}),f.jsx(Zn,{value:"content",children:"Story Content"}),f.jsxs(Zn,{value:"journal",children:["Journal",b.length>0&&f.jsx(sa,{className:"ml-2 bg-danger/20 text-danger text-xs",children:b.length})]}),f.jsx(Zn,{value:"sessions",children:"Sessions"})]}),f.jsx(kn,{value:"tasks",className:"space-y-4",children:f.jsx(ox,{tasks:c.tasks})}),f.jsx(kn,{value:"content",className:"space-y-4",children:f.jsx(rx,{content:c.description})}),f.jsx(kn,{value:"journal",className:"space-y-4",children:f.jsx(dx,{journal:c.journal??[]})}),f.jsx(kn,{value:"sessions",className:"space-y-4",children:f.jsx(K0,{storyId:s??""})})]})]})}const yx=[{path:"/",element:f.jsx(Db,{}),children:[{path:"/",element:f.jsx(s0,{})},{path:"epic/:epicId",element:f.jsx(Fb,{})},{path:"story/:storyId",element:f.jsx(gx,{})}]}];function px(){return f.jsx(Mp,{children:f.jsx(Cp,{children:yx.map(s=>f.jsx(vm,{path:s.path,element:s.element,children:s.children?.map(r=>f.jsx(vm,{path:r.path,element:r.element},r.path))},s.path))})})}const Rh=document.getElementById("root");if(!Rh)throw new Error("Root element not found");wp.createRoot(Rh).render(f.jsx(_.StrictMode,{children:f.jsx($p,{children:f.jsx(px,{})})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>SAGA Dashboard</title>
8
- <script type="module" crossorigin src="/assets/index-BE60sVjH.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-gMTub-O2.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-xstate-Dogcz2PC.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/vendor-radix-BuqlnHDi.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BQ8AP4vp.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saga-ai/dashboard",
3
- "version": "4.2.3",
3
+ "version": "4.4.0",
4
4
  "description": "Dashboard and session monitoring for SAGA - Structured Autonomous Goal Achievement",
5
5
  "type": "module",
6
6
  "bin": {