import{f,g,h as b,i as h,k as j,l as v,r as t,m as y,t as C,j as n,n as w,S as A}from"./index-tKq6NBmA.js";function R(){const{agent:S,projectPath:o}=f(),{sessions:i,activeSessionId:m,setActiveSession:a}=g(),r=b(o),c=h(),l=j(),u=v(o),d=t.useMemo(()=>i.filter(e=>e.cwd===o).sort((e,s)=>s.updatedAt.localeCompare(e.updatedAt)),[i,o]),k=t.useMemo(()=>y(d),[d]),p=t.useCallback(async e=>{try{const s=await c.forkSession(e,void 0,o??void 0);await l.invalidateQueries({queryKey:["sessions"]}),a(s.id)}catch(s){C.error(s instanceof Error?s.message:"Failed to fork session")}},[c,o,l,a]),x=t.useCallback((e,s)=>{u.mutate({sessionId:e,title:s})},[u]);return n.jsxs("div",{className:"flex flex-col",children:[r.tasks==="enabled"&&n.jsx("div",{className:"border-b",children:n.jsx(w,{toolStatus:r.tasks,agentId:S.id})}),n.jsx(A,{activeSessionId:m,groupedSessions:k,onSessionClick:a,onForkSession:p,onRenameSession:x})]})}export{R as SessionsTab};
