import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t}from"./vendor-dnd-C1cICjTT.js";import{s as n}from"./vendor-markdown-Db1-9wH7.js";import{t as r}from"./sessionStore-DVOX7Q2x.js";import{B as i,C as a}from"./index-Dzmo3iV3.js";import{t as o}from"./useSessionMessages-CABX2U-R.js";import{o as s,t as c}from"./RenderedTurnTranscript-pNU6vfTW.js";var l=e(t(),1),u=n();function d({sessionId:e,sessionFilePath:t,cwd:n,title:d,subtitle:f,parentReportedActive:p=!1,onOpenFileAsArtifact:m}){(0,l.useEffect)(()=>(i.getState().watch(e),()=>i.getState().unwatch(e)),[e]);let h=r(t=>t.sessions.get(e)),g=i(t=>t.sessions.get(e)),{messages:_,loading:v,error:y}=o(e,{live:!0,nativeSessionKey:e,expectedMessageCount:h?.messageCount??0}),b=g?.agentActive===!0,{meaningful:x,timelineItems:S,groups:C}=s({sessionId:e,messages:_,storedTurns:h?.turns,runtimeLifecycle:h?.runtimeLifecycle,taskStatus:h?.task_status,runtimeOwnsCurrentTurn:b}),w=b||g?.agentActive!==!1&&p,T=(0,l.useMemo)(()=>w?C.reduce((e,t,n)=>t.items.some(e=>e.kind===`message`?e.message.role===`user`:e.messages.some(e=>e.role===`user`))?n:e,-1):-1,[C,w]),E=()=>a({piSessionId:e,sessionFilePath:t,cwd:n??``,title:d,sessionType:`pi`,wasIdle:!w});return(0,u.jsxs)(`section`,{className:`min-w-0 py-1`,"data-testid":`pi-rendered-nested-session`,"data-nested-session-id":e,"data-nested-session-working":w?`true`:`false`,children:[(0,u.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pb-1.5`,children:[(0,u.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w?`animate-pulse bg-terminal-green`:`bg-terminal-muted/50`}`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-terminal-text/80`,title:d,children:d}),f&&(0,u.jsx)(`span`,{className:`shrink-0 truncate text-[10px] text-terminal-muted/55`,children:f}),(0,u.jsx)(`button`,{type:`button`,onClick:E,className:`ml-auto shrink-0 text-[10px] text-terminal-muted/60 transition-colors hover:text-terminal-text focus-visible:text-terminal-text focus-visible:outline-none`,"data-testid":`pi-rendered-open-nested-session`,children:`Open session`})]}),(0,u.jsx)(`div`,{className:`min-w-0 space-y-3 border-l border-terminal-border/25 pl-3`,children:x.length>0?(0,u.jsx)(c,{groups:C,timelineItems:S,sessionKey:e,isWorking:w,latestWorkingTurnGroupIndex:T,workOnlyPreview:!0,cwd:n??h?.cwd,onOpenFileAsArtifact:m}):(0,u.jsx)(`div`,{className:`text-[10px] text-terminal-muted/60`,children:y?`Could not load this agent's transcript: ${y}`:v?`Loading agent transcript…`:w?`Waiting for the agent to start…`:`This agent recorded no transcript.`})})]})}export{d as default};