@grackle-ai/web 0.28.0 → 0.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.
@@ -88,4 +88,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
88
88
  `),ne=Bd(ge.entries());!(R=ne()).done;){var je=R.value,G=je[0],U=je[1];te.push({type:"text",value:G===ge.length-1?U:U+`
89
89
  `,position:{start:{line:y+G,column:1},end:{line:y+G,column:1}}})}return y+=he,te}if(Object.prototype.hasOwnProperty.call(K,"children")){var X=y;return K.children=H(K.children),te.push(K),K.position={start:{line:X,column:1},end:{line:y,column:1}},te}return te.push(K),te},[])})(v.children),v.position=v.children.length>0?{start:{line:v.children[0].position.start.line,column:0},end:{line:v.children[v.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var N,D=(function(H){var J=/{([\d,-]+)}/,te=H.split(",").map(function(he){return he.trim()}).join();if(J.test(te)){var K=J.exec(te)[1],W=u1(K);return function(he){return W.includes(he+1)}}return function(){return!1}})(p),w=(function(H){var J=cf(/showLineNumbers=(\d+)/i,{lines:1});if(J.test(H)){var te=J.exec(H);return Number(te.groups.lines)}return 1})(p),j=(function(H){for(var J=new Array(H),te=0;te<H;te++)J[te]={type:"element",tagName:"span",properties:{className:[]},children:[]};return J})(v.position.end.line),V=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],M=function(){var H,J,te=N.value,K=te[0],W=te[1];W.properties.className=["code-line"];var he=d1(v,function(R){return R.position.start.line<=K+1&&R.position.end.line>=K+1});W.children=he.children,(p.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(b))&&!V.some(function(R){return p.toLowerCase().includes(R)})&&(W.properties.line=[(K+w).toString()],W.properties.className.push("line-number")),D(K)&&W.properties.className.push("highlight-line"),(b==="diff"||(H=b)!=null&&H.includes("diff-"))&&Er(W).substring(0,1)==="-"?W.properties.className.push("deleted"):(b==="diff"||(J=b)!=null&&J.includes("diff-"))&&Er(W).substring(0,1)==="+"&&W.properties.className.push("inserted")},$=Bd(j.entries());!(N=$()).done;)M();j.length>0&&Er(j[j.length-1]).trim()===""&&j.pop(),o.children=j}}}})(c1);const xA="_systemEvent_2kh3g_1",_A="_systemTimestamp_2kh3g_9",TA="_textEvent_2kh3g_13",EA="_toolUseEvent_2kh3g_100",jA="_toolUseHeader_2kh3g_116",CA="_toolUsePrefix_2kh3g_123",AA="_toolUseName_2kh3g_128",NA="_toolUseArgs_2kh3g_133",wA="_toolResultEvent_2kh3g_144",DA="_toolResultHeader_2kh3g_150",kA="_toolResultIndicatorOk_2kh3g_174",RA="_toolResultIndicatorError_2kh3g_181",MA="_toolResultLabel_2kh3g_188",OA="_toolResultToggle_2kh3g_192",BA="_toolResultCommand_2kh3g_198",LA="_toolResultEllipsis_2kh3g_208",UA="_toolResultPre_2kh3g_212",zA="_errorEvent_2kh3g_227",VA="_statusEvent_2kh3g_236",HA="_userInputEvent_2kh3g_246",IA="_userInputContent_2kh3g_253",GA="_defaultEvent_2kh3g_265",ht={systemEvent:xA,systemTimestamp:_A,textEvent:TA,toolUseEvent:EA,toolUseHeader:jA,toolUsePrefix:CA,toolUseName:AA,toolUseArgs:NA,toolResultEvent:wA,toolResultHeader:DA,toolResultIndicatorOk:kA,toolResultIndicatorError:RA,toolResultLabel:MA,toolResultToggle:OA,toolResultCommand:BA,toolResultEllipsis:LA,toolResultPre:UA,errorEvent:zA,statusEvent:VA,userInputEvent:HA,userInputContent:IA,defaultEvent:GA};function PA({time:n,content:s}){return h.jsxs("div",{className:ht.systemEvent,children:[h.jsxs("span",{className:ht.systemTimestamp,children:["[",n,"]"]})," ",s]})}function qA({content:n}){return h.jsx("div",{className:ht.textEvent,children:h.jsx(uf,{remarkPlugins:[df],rehypePlugins:[SA],children:n})})}function YA({content:n}){let s="",l=n;try{const o=JSON.parse(n);s=o.tool||"",l=JSON.stringify(o.args,null,2)}catch{}return h.jsxs("div",{className:ht.toolUseEvent,children:[h.jsxs("div",{className:ht.toolUseHeader,children:[h.jsx("span",{className:ht.toolUsePrefix,children:">"}),s?h.jsx("span",{className:ht.toolUseName,children:s}):null]}),h.jsx("pre",{className:ht.toolUseArgs,children:l})]})}const Cy=5;function KA(n,s){if(s==null)return"";if(typeof s!="object")return String(s);const l=s;if(typeof l.command=="string")return l.command;if(typeof l.file_path=="string")return l.file_path;if(typeof l.pattern=="string"){const o=typeof l.path=="string"?` in ${l.path}`:"";return`${l.pattern}${o}`}if(typeof l.path=="string")return l.path;if(typeof l.query=="string")return l.query;try{const o=JSON.stringify(s);return o.length>150?`${o.slice(0,150)}…`:o}catch{return""}}function ZA({content:n,raw:s,toolUseCtx:l}){const[o,c]=S.useState(!1);let d=!1;if(s)try{d=JSON.parse(s).is_error===!0}catch{}const f=n.split(`
90
90
  `),m=f.length>Cy,p=o?n:f.slice(0,Cy).join(`
91
- `),y=((l==null?void 0:l.tool)??"")||(d?"Tool error":"Tool output"),b=l?KA(l.tool,l.args):"",_=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:d?ht.toolResultIndicatorError:ht.toolResultIndicatorOk,"aria-label":d?"error":"success",children:d?"✗":"✓"}),h.jsx("span",{className:ht.toolResultLabel,children:y}),m&&h.jsx("span",{className:ht.toolResultToggle,"aria-hidden":"true",children:o?"▾":"▸"})]});return h.jsxs("div",{className:ht.toolResultEvent,children:[m?h.jsx("button",{className:ht.toolResultHeader,onClick:()=>{c(T=>!T)},"aria-expanded":o,children:_}):h.jsx("div",{className:ht.toolResultHeader,children:_}),b&&h.jsx("div",{className:ht.toolResultCommand,children:b}),h.jsxs("pre",{className:ht.toolResultPre,children:[p,!o&&m&&h.jsx("span",{className:ht.toolResultEllipsis,children:"…"})]})]})}function XA({content:n}){return h.jsxs("div",{className:ht.errorEvent,children:["Error: ",n]})}function $A({content:n}){return h.jsxs("div",{className:ht.statusEvent,children:["--- ",n," ---"]})}function QA({content:n}){return h.jsx("div",{className:ht.userInputEvent,children:h.jsx("span",{className:ht.userInputContent,children:n})})}function FA({content:n}){return h.jsx("div",{className:ht.defaultEvent,children:n})}function qb({event:n,toolUseCtx:s}){const l=new Date(n.timestamp).toLocaleTimeString();switch(n.eventType){case"system":return h.jsx(PA,{time:l,content:n.content});case"text":case"output":return h.jsx(qA,{content:n.content});case"tool_use":return h.jsx(YA,{content:n.content});case"tool_result":return h.jsx(ZA,{content:n.content,raw:n.raw,toolUseCtx:s});case"error":return h.jsx(XA,{content:n.content});case"status":return h.jsx($A,{content:n.content});case"user_input":return h.jsx(QA,{content:n.content});default:return h.jsx(FA,{content:n.content})}}const JA="_overlay_cmicx_1",WA="_dialog_cmicx_11",eN="_title_cmicx_30",tN="_description_cmicx_38",nN="_actions_cmicx_45",aN="_cancelButton_cmicx_52",sN="_confirmButton_cmicx_79",ws={overlay:JA,dialog:WA,title:eN,description:tN,actions:nN,cancelButton:aN,confirmButton:sN};function lc({isOpen:n,title:s,description:l,confirmLabel:o="Delete",onConfirm:c,onCancel:d}){const f=S.useId(),m=S.useId();return h.jsx(Ui,{children:n&&h.jsx(la.div,{className:ws.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:d,onKeyDown:p=>{p.key==="Escape"&&d()},role:"dialog","aria-modal":"true","aria-labelledby":f,"aria-describedby":l?m:void 0,children:h.jsxs(la.div,{className:ws.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:p=>p.stopPropagation(),children:[h.jsx("h3",{id:f,className:ws.title,children:s}),l&&h.jsx("p",{id:m,className:ws.description,children:l}),h.jsxs("div",{className:ws.actions,children:[h.jsx("button",{type:"button",className:ws.cancelButton,onClick:d,autoFocus:!0,children:"Cancel"}),h.jsx("button",{type:"button",className:ws.confirmButton,onClick:c,children:o})]})]})})})}const iN="_spinner_13c8l_1",lN="_spin_13c8l_1",oN="_sm_13c8l_14",rN="_md_13c8l_20",cN="_lg_13c8l_26",Ay={spinner:iN,spin:lN,sm:oN,md:rN,lg:cN};function Ny({size:n="md",className:s,label:l="Loading",liveRegion:o=!1}){return h.jsx("span",{className:`${Ay.spinner} ${Ay[n]} ${s??""}`,role:o?"status":void 0,"aria-label":l,"aria-hidden":o?void 0:!0})}const uN="_container_7z2xb_1",dN="_header_7z2xb_5",fN="_addButton_7z2xb_17",hN="_createForm_7z2xb_44",mN="_createInput_7z2xb_50",pN="_createButton_7z2xb_81",gN="_creatingHint_7z2xb_122",vN="_projectRow_7z2xb_131",yN="_selected_7z2xb_149",bN="_expandArrow_7z2xb_154",SN="_expanded_7z2xb_161",xN="_projectName_7z2xb_165",_N="_taskCount_7z2xb_169",TN="_newTaskButton_7z2xb_175",EN="_taskRow_7z2xb_202",jN="_taskStatusIcon_7z2xb_227",CN="_taskTitle_7z2xb_231",AN="_dependencyBadge_7z2xb_238",NN="_blockedBadge_7z2xb_250",wN="_leafSpacer_7z2xb_255",DN="_childCountBadge_7z2xb_260",kN="_addChildButton_7z2xb_273",RN="_emptyCta_7z2xb_317",MN="_ctaDescription_7z2xb_330",ON="_ctaButton_7z2xb_336",BN="_emptyTaskCta_7z2xb_371",LN="_createTaskLink_7z2xb_376",Ze={container:uN,header:dN,addButton:fN,createForm:hN,createInput:mN,createButton:pN,creatingHint:gN,projectRow:vN,selected:yN,expandArrow:bN,expanded:SN,projectName:xN,taskCount:_N,newTaskButton:TN,taskRow:EN,taskStatusIcon:jN,taskTitle:CN,dependencyBadge:AN,blockedBadge:NN,leafSpacer:wN,childCountBadge:DN,addChildButton:kN,emptyCta:RN,ctaDescription:MN,ctaButton:ON,emptyTaskCta:BN,createTaskLink:LN},wy={not_started:{color:"var(--text-tertiary)",icon:"○"},working:{color:"var(--accent-green)",icon:"●"},paused:{color:"var(--accent-yellow)",icon:"◉"},complete:{color:"var(--accent-green)",icon:"✓"},failed:{color:"var(--accent-red)",icon:"✗"}};function UN(n){const s=new Map(n.map(o=>[o.id,{...o,children:[]}])),l=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):l.push(o);for(const o of s.values())o.children.sort((c,d)=>c.sortOrder-d.sortOrder);return l.sort((o,c)=>o.sortOrder-c.sortOrder)}const zN=34,VN=16;function Yb({node:n,depth:s,expandedTasks:l,toggleTask:o,selectedTaskId:c,navigate:d,projectId:f,taskStatusById:m}){const p=wy[n.status]||wy.not_started,v=n.dependsOn.length>0&&n.dependsOn.some(N=>m.get(N)!=="complete"),y=l.has(n.id),b=n.children.length>0,_=c===n.id,T=zN+s*VN;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{onClick:()=>d(Di(n.id)),className:`${Ze.taskRow} ${_?Ze.selected:""}`,style:{paddingLeft:T},"data-task-id":n.id,children:[b&&h.jsx("span",{className:`${Ze.expandArrow} ${y?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":y?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),o(n.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),o(n.id))},children:"▸"}),!b&&h.jsx("span",{className:Ze.leafSpacer}),h.jsx("span",{className:Ze.taskStatusIcon,style:{color:p.color},children:p.icon}),h.jsx("span",{className:Ze.taskTitle,title:n.title,children:n.title}),b&&h.jsxs("span",{className:Ze.childCountBadge,children:[n.children.filter(N=>N.status==="complete").length,"/",n.children.length]}),n.dependsOn.length>0&&h.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${n.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<fA&&h.jsx("button",{onClick:N=>{N.stopPropagation(),d(ki(f,n.id))},title:"Add child task","aria-label":"Add child task",className:Ze.addChildButton,children:"+"})]}),h.jsx(Ui,{children:b&&y&&h.jsx(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:n.children.map(N=>h.jsx(Yb,{node:N,depth:s+1,expandedTasks:l,toggleTask:o,selectedTaskId:c,navigate:d,projectId:f,taskStatusById:m},N.id))})})]})}function HN(){const{projects:n,tasks:s,loadTasks:l,createProject:o,projectCreating:c}=Ft(),d=oa(),[f,m]=S.useState(new Set),[p,v]=S.useState(new Set),[y,b]=S.useState(new Set),[_,T]=S.useState(!1),[N,D]=S.useState(""),w=tn("/tasks/:taskId/*"),j=tn("/projects/:projectId"),V=(w==null?void 0:w.params.taskId)!=="new"?w==null?void 0:w.params.taskId:void 0,M=j==null?void 0:j.params.projectId,$=S.useRef(f);$.current=f;const H=S.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),J=W=>{m(he=>{const R=new Set(he);return R.has(W)?R.delete(W):(R.add(W),l(W)),R})},te=W=>{v(he=>{const R=new Set(he);return R.has(W)?(R.delete(W),b(ge=>new Set(ge).add(W))):(R.add(W),b(ge=>{const ne=new Set(ge);return ne.delete(W),ne})),R})};S.useEffect(()=>{const W=new Set(s.filter(he=>he.parentTaskId).map(he=>he.parentTaskId));W.size>0&&v(he=>{const R=new Set(he);for(const ge of W)y.has(ge)||R.add(ge);return R})},[s,y]),S.useEffect(()=>{M&&!$.current.has(M)&&(m(W=>new Set(W).add(M)),l(M))},[M,l]);const K=()=>{!N.trim()||c||(o(N.trim()),D(""),T(!1))};return h.jsxs("div",{className:Ze.container,children:[h.jsxs("div",{className:Ze.header,children:[h.jsx("span",{children:"Projects"}),h.jsx("button",{className:Ze.addButton,onClick:()=>T(!_),"aria-label":"Create project",title:"Create project",children:"+"})]}),_&&h.jsxs("div",{className:Ze.createForm,children:[h.jsx("input",{type:"text",value:N,onChange:W=>D(W.target.value),onKeyDown:W=>W.key==="Enter"&&K(),placeholder:"Project name...",autoFocus:!0,disabled:c,className:Ze.createInput}),h.jsx("button",{onClick:K,className:Ze.createButton,disabled:c,children:c?h.jsx(Ny,{size:"sm",label:"Creating project"}):"OK"})]}),c&&h.jsxs("div",{className:Ze.creatingHint,children:[h.jsx(Ny,{size:"sm",label:"Creating project"}),"Creating project…"]}),n.length===0&&!_&&h.jsxs("div",{className:Ze.emptyCta,children:[h.jsx("button",{className:Ze.ctaButton,onClick:()=>T(!0),children:"Create Project"}),h.jsx("div",{className:Ze.ctaDescription,children:"Organize your work into projects"})]}),n.map(W=>{const he=f.has(W.id),R=s.filter(je=>je.projectId===W.id),ge=M===W.id,ne=he?UN(R):[];return h.jsxs("div",{children:[h.jsxs("div",{onClick:()=>{ge?J(W.id):(he||J(W.id),d($l(W.id)))},className:`${Ze.projectRow} ${ge?Ze.selected:""}`,children:[h.jsx("span",{className:`${Ze.expandArrow} ${he?Ze.expanded:""}`,children:"▸"}),h.jsx("span",{className:Ze.projectName,title:W.name,children:W.name}),h.jsx("span",{className:Ze.taskCount,children:R.length>0&&`${R.filter(je=>je.status==="complete").length}/${R.length}`}),h.jsx("button",{onClick:je=>{je.stopPropagation(),d(ki(W.id))},title:"New task",className:Ze.newTaskButton,children:"+"})]}),h.jsx(Ui,{children:he&&h.jsxs(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},style:{overflow:"hidden"},children:[ne.map(je=>h.jsx(Yb,{node:je,depth:0,expandedTasks:p,toggleTask:te,selectedTaskId:V,navigate:d,projectId:W.id,taskStatusById:H},je.id)),R.length===0&&h.jsx("div",{className:Ze.emptyTaskCta,children:h.jsx("button",{className:Ze.createTaskLink,onClick:()=>d(ki(W.id)),children:"+ Create Task"})})]})})]},W.id)})]})}const IN="_container_1purk_1",GN="_content_1purk_30",Dy={container:IN,content:GN},PN=320,Kb=220,Zb=600,Xb="grackle-sidebar-width";function qN(){try{const n=localStorage.getItem(Xb);if(n!==null){const s=Number(n);if(Number.isFinite(s)&&s>=Kb&&s<=Zb)return s}}catch{}return PN}function YN(n){try{localStorage.setItem(Xb,String(n))}catch{}}function KN(){const[n]=S.useState(qN),s=S.useRef(null);return S.useEffect(()=>{const l=s.current;if(!l)return;const o=new ResizeObserver(c=>{for(const d of c){const f=d.borderBoxSize[0];if(f){const m=Math.round(f.inlineSize);m>=Kb&&m<=Zb&&YN(m)}}});return o.observe(l),()=>{o.disconnect()}},[]),h.jsx("div",{className:Dy.container,ref:s,"data-testid":"sidebar",style:{width:n},children:h.jsx("div",{className:Dy.content,children:h.jsx(HN,{})})})}const ZN="_bar_teqep_1",XN="_barColumn_teqep_26",$N="_barRow_teqep_52",QN="_input_teqep_58",FN="_inputSmall_teqep_87",JN="_select_teqep_150",WN="_btnPrimary_teqep_180",ew="_btnDanger_teqep_211",tw="_btnGhost_teqep_250",nw="_badge_teqep_278",aw="_statusText_teqep_288",sw="_statusCompleted_teqep_293",iw="_statusFailed_teqep_297",lw="_statusBlocked_teqep_301",ow="_hintText_teqep_306",rw="_creatingHint_teqep_311",cw="_errorHint_teqep_319",uw="_disconnectHint_teqep_325",de={bar:ZN,barColumn:XN,barRow:$N,input:QN,inputSmall:FN,select:JN,btnPrimary:WN,btnDanger:ew,btnGhost:tw,badge:nw,statusText:aw,statusCompleted:sw,statusFailed:iw,statusBlocked:lw,hintText:ow,creatingHint:rw,errorHint:cw,disconnectHint:uw};function ky({value:n,onChange:s,testId:l}){return h.jsxs("select",{"data-testid":l,value:n,onChange:o=>s(o.target.value),className:de.select,children:[h.jsx("option",{value:"claude-code",children:"claude-code"}),h.jsx("option",{value:"codex",children:"codex"}),h.jsx("option",{value:"copilot",children:"copilot"}),h.jsx("option",{value:"stub",children:"stub"})]})}function Ry(n,s){if(!n)return!1;const l=s.find(o=>o.id===n);return l!==void 0&&(l.status==="disconnected"||l.status==="error")}function My({environmentId:n,onReconnect:s}){return h.jsxs(h.Fragment,{children:[h.jsx("span",{className:de.disconnectHint,"data-testid":"env-disconnect-hint",children:"Environment unavailable"}),h.jsx("button",{type:"button",onClick:()=>s(n),className:de.btnGhost,"data-testid":"reconnect-btn",title:"Reconnect the environment to resume messaging",children:"Reconnect"})]})}function dw(){const{spawn:n,sendInput:s,kill:l,sessions:o,tasks:c,environments:d,personas:f,addEnvironment:m,provisionEnvironment:p,codespaces:v,codespaceError:y,codespaceListError:b,codespaceCreating:_,listCodespaces:T,createCodespace:N}=Ft(),{showToast:D}=to(),w=oa(),[j]=Sf(),V=tn("/sessions/:sessionId"),M=tn("/tasks/:taskId"),$=tn("/tasks/:taskId/stream"),H=tn("/tasks/:taskId/findings"),J=tn("/tasks/:taskId/edit"),te=tn("/sessions/new"),K=tn("/environments/new"),W=tn("/projects/:projectId"),he=tn("/tasks/new"),R=tn("/"),ge=tn("/settings/*"),ne=V==null?void 0:V.params.sessionId,je=(M==null?void 0:M.params.taskId)??($==null?void 0:$.params.taskId)??(H==null?void 0:H.params.taskId),G=!!te,U=!!K,X=!!W,ee=!!he,Ae=!!J,Ee=!!R&&!G&&!U&&!X&&!ee,Ge=!!ge,we=G?j.get("env")??"":"",_e=G?j.get("runtime")??"claude-code":"claude-code",[Ce,Q]=S.useState(""),[ce,Ie]=S.useState(G?_e:"claude-code"),[F,sn]=S.useState(""),Qn=pe=>{if(sn(pe),pe){const le=f.find(Te=>Te.id===pe);le!=null&&le.runtime&&Ie(le.runtime)}},[ln,jn]=S.useState(""),[dt,Jt]=S.useState("local"),[Hn,In]=S.useState("claude-code"),[mn,Gn]=S.useState(""),[Yt,Pn]=S.useState(""),[Z,se]=S.useState(""),[oe,ue]=S.useState(""),[Se,xe]=S.useState(""),[Xe,Re]=S.useState(""),[nt,xt]=S.useState(""),[pt,At]=S.useState(""),[at,gt]=S.useState(""),[Wt,ft]=S.useState("pick");S.useEffect(()=>{G&&Ie(_e)},[G,_e]);const Lt=ne?o.find(pe=>pe.id===ne):void 0,Ut=je?c.find(pe=>pe.id===je):void 0,cs=(Ut==null?void 0:Ut.latestSessionId)||void 0,qn=cs?o.find(pe=>pe.id===cs):void 0,ae=Ut?Ut.dependsOn.some(pe=>{const le=c.find(Te=>Te.id===pe);return le&&le.status!=="complete"}):!1;if(Ee||Ge)return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Select a session or click + to start"})});if(Ae||ee)return h.jsx(h.Fragment,{});if(U){const pe=P=>{if(!P.trim())return!0;const Fe=Number(P);return Number.isInteger(Fe)&&Fe>=1&&Fe<=65535},le=()=>!(!ln.trim()||dt==="ssh"&&!mn.trim()||dt==="codespace"&&!Xe.trim()||(dt==="local"||dt==="ssh")&&!pe(Yt)),Te=()=>{if(!le())return;const P={};if(dt==="local"){if(mn.trim()&&(P.host=mn.trim()),Yt.trim()){const Fe=Number(Yt);Number.isInteger(Fe)&&(P.port=Fe)}}else if(dt==="ssh"){if(P.host=mn.trim(),Z.trim()&&(P.user=Z.trim()),Yt.trim()){const Fe=Number(Yt);Number.isInteger(Fe)&&(P.sshPort=Fe)}nt.trim()&&(P.identityFile=nt.trim())}else dt==="docker"?(oe.trim()&&(P.image=oe.trim()),Se.trim()&&(P.repo=Se.trim())):dt==="codespace"&&(P.codespaceName=Xe.trim());m(ln.trim(),dt,P,Hn),D("Environment added successfully","success"),jn(""),Jt("local"),In("claude-code"),Gn(""),Pn(""),se(""),ue(""),xe(""),Re(""),xt(""),At(""),gt(""),ft("pick"),w(wi,{replace:!0})};return h.jsxs("div",{className:de.barColumn,children:[h.jsxs("div",{className:de.barRow,children:[h.jsx("span",{className:de.badge,children:"new env"}),h.jsx("input",{type:"text",value:ln,onChange:P=>jn(P.target.value),placeholder:"Environment name...",autoFocus:!0,className:de.input}),h.jsxs("select",{value:dt,onChange:P=>{Jt(P.target.value),P.target.value==="codespace"&&(T(),ft("pick"),Re(""))},className:de.select,children:[h.jsx("option",{value:"local",children:"local"}),h.jsx("option",{value:"ssh",children:"ssh"}),h.jsx("option",{value:"docker",children:"docker"}),h.jsx("option",{value:"codespace",children:"codespace"})]}),h.jsx(ky,{value:Hn,onChange:In,testId:"new-environment-runtime-select"}),h.jsx("button",{onClick:Te,disabled:!le(),className:de.btnPrimary,children:"Add"})]}),h.jsxs("div",{className:de.barRow,children:[dt==="local"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:mn,onChange:P=>Gn(P.target.value),placeholder:"Host (optional)...",className:de.inputSmall}),h.jsx("input",{type:"number",min:1,max:65535,value:Yt,onChange:P=>Pn(P.target.value),placeholder:"Port (optional)...",className:de.inputSmall})]}),dt==="ssh"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:mn,onChange:P=>Gn(P.target.value),placeholder:"Host (required)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:Z,onChange:P=>se(P.target.value),placeholder:"User (optional)...",className:de.inputSmall}),h.jsx("input",{type:"number",min:1,max:65535,value:Yt,onChange:P=>Pn(P.target.value),placeholder:"SSH port (optional)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:nt,onChange:P=>xt(P.target.value),placeholder:"Identity file (optional)...",className:de.inputSmall})]}),dt==="docker"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:oe,onChange:P=>ue(P.target.value),placeholder:"Image (optional)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:Se,onChange:P=>xe(P.target.value),placeholder:"Repo (optional)...",className:de.inputSmall})]}),dt==="codespace"&&Wt==="pick"&&h.jsxs(h.Fragment,{children:[!b&&h.jsxs("select",{value:Xe,onChange:P=>{P.target.value==="__create__"?(ft("create"),Re("")):(Re(P.target.value),P.target.value&&!ln.trim()&&jn(P.target.value))},disabled:_,className:de.select,children:[h.jsx("option",{value:"",children:"Select a codespace..."}),v.map(P=>h.jsxs("option",{value:P.name,children:[P.name," (",P.repository,") — ",P.state]},P.name)),h.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),_&&h.jsx("span",{className:de.creatingHint,children:"Creating codespace..."}),b&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:de.errorHint,children:b}),h.jsx("input",{type:"text",value:Xe,onChange:P=>Re(P.target.value),placeholder:"Or enter codespace name manually...",className:de.inputSmall})]}),y&&!b&&h.jsx("span",{className:de.errorHint,children:y})]}),dt==="codespace"&&Wt==="create"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:pt,onChange:P=>At(P.target.value),placeholder:"owner/repo",className:de.inputSmall}),h.jsx("input",{type:"text",value:at,onChange:P=>gt(P.target.value),placeholder:"Machine type (optional)...",className:de.inputSmall}),h.jsx("button",{onClick:()=>{pt.trim()&&(N(pt.trim(),at.trim()||void 0),ft("pick"),At(""),gt(""))},disabled:!pt.trim(),className:de.btnPrimary,children:"Create"}),h.jsx("button",{onClick:()=>{ft("pick"),At(""),gt("")},className:de.btnGhost,children:"Cancel"})]})]})]})}if(X)return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Select a task or click + to create one"})});if(je&&Ut){if(Ut.status==="not_started"){const pe=ae?Ut.dependsOn.map(le=>c.find(Te=>Te.id===le)).filter(le=>le&&le.status!=="complete").map(le=>le.title):[];return h.jsx("div",{className:de.bar,children:ae?h.jsxs("span",{className:de.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):h.jsx("span",{className:de.hintText,children:"Use the buttons above to start or manage this task"})})}if(Ut.status==="working"||Ut.status==="paused"){if((qn==null?void 0:qn.status)==="idle"){const le=qn.environmentId,Te=Ry(le,d),P=Fe=>{Fe.preventDefault();const on=Ut.latestSessionId||cs;!Ce.trim()||!on||Te||(s(on,Ce),Q(""))};return h.jsxs("form",{onSubmit:P,className:de.bar,children:[Te&&le&&h.jsx(My,{environmentId:le,onReconnect:p}),h.jsx("input",{type:"text",value:Ce,onChange:Fe=>Q(Fe.target.value),placeholder:"Type a message...",autoFocus:!Te,disabled:Te,className:de.input}),h.jsx("span",{title:Te?"Environment is unavailable — reconnect first":void 0,children:h.jsx("button",{type:"submit",disabled:!Ce.trim()||Te,className:de.btnPrimary,children:"Send"})})]})}return h.jsx("div",{className:de.bar,children:h.jsx("input",{type:"text",disabled:!0,placeholder:"Agent is working...",className:de.input})})}if(Ut.status==="complete")return h.jsxs("div",{className:de.bar,children:[h.jsx("span",{className:`${de.statusText} ${de.statusCompleted}`,children:"Task completed"}),h.jsx("button",{onClick:()=>w(ki(Ut.projectId)),className:de.btnPrimary,children:"+ New Task"})]});if(Ut.status==="failed")return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:`${de.statusText} ${de.statusFailed}`,children:"Task failed"})})}if(G){const pe=le=>{le.preventDefault(),!(!Ce.trim()||!we)&&(n(we,Ce,void 0,ce,F),D("Session started","success"),Q(""),sn(""))};return h.jsxs("form",{onSubmit:pe,className:de.bar,children:[h.jsx("span",{className:de.badge,children:"new chat"}),h.jsx("input",{type:"text",value:Ce,onChange:le=>Q(le.target.value),placeholder:"Enter prompt...",autoFocus:!0,className:de.input}),h.jsx(ky,{value:ce,onChange:Ie,testId:"new-chat-runtime-select"}),h.jsxs("select",{value:F,onChange:le=>Qn(le.target.value),className:de.select,children:[h.jsx("option",{value:"",children:"No persona"}),f.map(le=>h.jsx("option",{value:le.id,children:le.name},le.id))]}),h.jsx("button",{type:"submit",disabled:!Ce.trim()||!we,className:de.btnPrimary,children:"Go"})]})}if(ne){const pe=(Lt==null?void 0:Lt.status)==="running",le=(Lt==null?void 0:Lt.status)==="idle",Te=Lt!==void 0&&["completed","failed","interrupted"].includes(Lt.status);if(pe)return h.jsxs("div",{className:de.bar,children:[h.jsx("input",{type:"text",disabled:!0,placeholder:"Agent is working...",className:de.input}),h.jsx("button",{onClick:()=>l(ne),className:de.btnDanger,title:"Stop session",children:"Stop"})]});if(le){const P=Ry(Lt.environmentId,d),Fe=on=>{on.preventDefault(),!(!Ce.trim()||P)&&(s(ne,Ce),Q(""))};return h.jsxs("form",{onSubmit:Fe,className:de.bar,children:[P&&Lt.environmentId&&h.jsx(My,{environmentId:Lt.environmentId,onReconnect:p}),h.jsx("input",{type:"text",value:Ce,onChange:on=>Q(on.target.value),placeholder:"Type a message...",autoFocus:!P,disabled:P,className:de.input}),h.jsx("span",{title:P?"Environment is unavailable — reconnect first":void 0,children:h.jsx("button",{type:"submit",disabled:!Ce.trim()||P,className:de.btnPrimary,children:"Send"})}),h.jsx("button",{type:"button",onClick:()=>l(ne),className:de.btnDanger,title:"Stop session",children:"Stop"})]})}if(Te)return h.jsxs("div",{className:de.bar,children:[h.jsxs("span",{className:`${de.statusText} ${de.hintText}`,children:["Session ",Lt.status]}),h.jsx("button",{onClick:()=>w(m0(Lt.environmentId,Lt.runtime)),className:de.btnPrimary,children:"+ New Chat"})]})}return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Loading..."})})}const fw="_toast_da8ll_1",hw="_success_da8ll_18",mw="_icon_da8ll_22",pw="_error_da8ll_25",gw="_warning_da8ll_32",vw="_info_da8ll_38",yw="_message_da8ll_53",bw="_close_da8ll_60",Ll={toast:fw,success:hw,icon:mw,error:pw,warning:gw,info:vw,message:yw,close:bw},Sw={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function xw({toast:n,onDismiss:s}){return S.useEffect(()=>{const l=setTimeout(()=>s(n.id),n.duration);return()=>clearTimeout(l)},[n.id,n.duration,s]),h.jsxs(la.div,{className:`${Ll.toast} ${Ll[n.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[h.jsx("span",{className:Ll.icon,"aria-hidden":"true",children:Sw[n.variant]}),h.jsx("span",{className:Ll.message,children:n.message}),h.jsx("button",{type:"button",className:Ll.close,onClick:()=>s(n.id),"aria-label":"Dismiss notification",children:"×"})]})}const _w="_container_qqse2_1",Tw={container:_w};function Ew(){const{toasts:n,dismissToast:s}=to();return h.jsx("div",{className:Tw.container,"data-testid":"toast-container",children:h.jsx(Ui,{children:n.map(l=>h.jsx(xw,{toast:l,onDismiss:s},l.id))})})}function jw(n,s){const l=S.useRef(null);S.useEffect(()=>{const o=l.current;if(l.current=n,o===null)return;const c=new Map;for(const f of o)c.set(f.id,f);const d=new Set;for(const f of n){d.add(f.id);const m=c.get(f.id);m&&m.status!==f.status&&(f.status==="connecting"||f.status==="sleeping"||(f.status==="connected"?s("Environment connected","success"):f.status==="error"?s("Environment provision failed","error"):f.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))))}for(const f of o)d.has(f.id)||s("Environment removed","info")},[n,s])}const Cw="_panelContainer_1blx0_1",Aw="_emptyState_1blx0_8",Nw="_projectSummary_1blx0_17",ww="_projectSummaryTitle_1blx0_28",Dw="_projectSummarySubtitle_1blx0_32",kw="_header_1blx0_36",Rw="_headerInfo_1blx0_63",Mw="_killButton_1blx0_69",Ow="_headerTitle_1blx0_98",Bw="_headerActions_1blx0_108",Lw="_taskStatusBadge_1blx0_115",Uw="_taskBranch_1blx0_124",zw="_taskBlockedBadge_1blx0_130",Vw="_btnPrimary_1blx0_138",Hw="_btnDanger_1blx0_169",Iw="_btnGhost_1blx0_208",Gw="_tabBar_1blx0_264",Pw="_tab_1blx0_264",qw="_active_1blx0_285",Yw="_eventScroll_1blx0_290",Kw="_tabContent_1blx0_296",Zw="_noContext_1blx0_301",Xw="_overviewContent_1blx0_307",$w="_overviewDashboard_1blx0_316",Qw="_overviewHero_1blx0_322",Fw="_statusBadge_1blx0_329",Jw="_statusPending_1blx0_341",Ww="_statusInProgress_1blx0_351",eD="_statusDone_1blx0_361",tD="_statusFailed_1blx0_366",nD="_statusWaitingInput_1blx0_371",aD="_overviewBranchPill_1blx0_376",sD="_branchLink_1blx0_391",iD="_overviewSection_1blx0_402",lD="_overviewLabel_1blx0_408",oD="_overviewValue_1blx0_415",rD="_overviewMuted_1blx0_420",cD="_overviewMarkdown_1blx0_426",uD="_envRow_1blx0_495",dD="_envDot_1blx0_501",fD="_envDotGreen_1blx0_508",hD="_envDotYellow_1blx0_512",mD="_envDotRed_1blx0_516",pD="_envDotGray_1blx0_520",gD="_depList_1blx0_524",vD="_depItem_1blx0_530",yD="_depBlocked_1blx0_537",bD="_depDone_1blx0_541",SD="_timeline_1blx0_545",xD="_timelineRow_1blx0_551",_D="_timelineKey_1blx0_558",TD="_timelineValue_1blx0_564",ED="_timelineDelta_1blx0_568",jD="_reviewNotes_1blx0_579",CD="_waitingMessage_1blx0_596",AD="_errorMessage_1blx0_600",ND="_eventOverflowWarning_1blx0_604",wD="_attemptSelector_1blx0_618",DD="_attemptLabel_1blx0_629",kD="_attemptButton_1blx0_633",RD="_attemptActive_1blx0_650",MD="_attemptStatus_1blx0_656",OD="_emptyCta_1blx0_662",BD="_ctaTitle_1blx0_674",LD="_ctaDescription_1blx0_680",UD="_ctaButton_1blx0_687",zD="_projectHeader_1blx0_736",VD="_projectName_1blx0_761",HD="_projectMeta_1blx0_774",ID="_metaRow_1blx0_782",GD="_metaLabel_1blx0_789",PD="_metaValue_1blx0_799",qD="_metaPlaceholder_1blx0_809",YD="_editButton_1blx0_814",KD="_editInput_1blx0_830",ZD="_editTextarea_1blx0_862",XD="_editSelect_1blx0_898",$D="_archiveButton_1blx0_931",QD="_repoLink_1blx0_961",FD="_metaValueClickable_1blx0_971",JD="_editHint_1blx0_990",WD="_editError_1blx0_999",ek="_editInputInvalid_1blx0_1006",tk="_unsavedDot_1blx0_1011",nk="_metaToggle_1blx0_1019",ak="_metaToggleArrow_1blx0_1040",sk="_metaToggleArrowOpen_1blx0_1045",ik="_progressBarContainer_1blx0_1049",lk="_progressBar_1blx0_1049",ok="_progressFill_1blx0_1065",rk="_progressLabel_1blx0_1072",ck="_metaTimestamps_1blx0_1079",uk="_metaTimestamp_1blx0_1079",dk="_editFieldWrapper_1blx0_1095",A={panelContainer:Cw,emptyState:Aw,projectSummary:Nw,projectSummaryTitle:ww,projectSummarySubtitle:Dw,header:kw,headerInfo:Rw,killButton:Mw,headerTitle:Ow,headerActions:Bw,taskStatusBadge:Lw,taskBranch:Uw,taskBlockedBadge:zw,btnPrimary:Vw,btnDanger:Hw,btnGhost:Iw,tabBar:Gw,tab:Pw,active:qw,eventScroll:Yw,tabContent:Kw,noContext:Zw,overviewContent:Xw,overviewDashboard:$w,overviewHero:Qw,statusBadge:Fw,statusPending:Jw,statusInProgress:Ww,statusDone:eD,statusFailed:tD,statusWaitingInput:nD,overviewBranchPill:aD,branchLink:sD,overviewSection:iD,overviewLabel:lD,overviewValue:oD,overviewMuted:rD,overviewMarkdown:cD,envRow:uD,envDot:dD,envDotGreen:fD,envDotYellow:hD,envDotRed:mD,envDotGray:pD,depList:gD,depItem:vD,depBlocked:yD,depDone:bD,timeline:SD,timelineRow:xD,timelineKey:_D,timelineValue:TD,timelineDelta:ED,reviewNotes:jD,waitingMessage:CD,errorMessage:AD,eventOverflowWarning:ND,attemptSelector:wD,attemptLabel:DD,attemptButton:kD,attemptActive:RD,attemptStatus:MD,emptyCta:OD,ctaTitle:BD,ctaDescription:LD,ctaButton:UD,projectHeader:zD,projectName:VD,projectMeta:HD,metaRow:ID,metaLabel:GD,metaValue:PD,metaPlaceholder:qD,editButton:YD,editInput:KD,editTextarea:ZD,editSelect:XD,archiveButton:$D,repoLink:QD,metaValueClickable:FD,editHint:JD,editError:WD,editInputInvalid:ek,unsavedDot:tk,metaToggle:nk,metaToggleArrow:ak,metaToggleArrowOpen:sk,progressBarContainer:ik,progressBar:lk,progressFill:ok,progressLabel:rk,metaTimestamps:ck,metaTimestamp:uk,editFieldWrapper:dk};function fk(){const{projects:n,createProject:s}=Ft();return n.length===0?h.jsxs("div",{className:A.emptyCta,children:[h.jsx("div",{className:A.ctaTitle,children:"Welcome to Grackle"}),h.jsx("div",{className:A.ctaDescription,children:"Organize your work into projects and let agents tackle the tasks."}),h.jsx("button",{className:A.ctaButton,onClick:()=>{const l=window.prompt("Project name:");l!=null&&l.trim()&&s(l.trim())},children:"Create Your First Project"})]}):h.jsx("div",{className:A.emptyState,children:"Select a project or task to get started"})}function hk(n,s){const l=[];let o=n;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const d=s.get(o);l.unshift(d),o=d.parentTaskId||void 0}return l}const Os={label:"Home",url:"/"};function mk(n){return n?[Os,{label:"Settings",url:"/settings"},{label:n,url:void 0}]:[Os,{label:"Settings",url:void 0}]}function pk(){return[Os,{label:"New Environment",url:void 0}]}function gk(){return[Os,{label:"New Chat",url:void 0}]}function vk(n){return[Os,{label:`Session ${n.slice(0,8)}`,url:void 0}]}function yk(n,s){const l=s.find(o=>o.id===n);return[Os,{label:(l==null?void 0:l.name)??"Project",url:void 0}]}function bk(n,s,l){const o=hk(n,l),c=l.get(n),d=c==null?void 0:c.projectId,f=d?s.find(v=>v.id===d):void 0,m=[Os];f&&m.push({label:f.name,url:$l(f.id)});for(let v=0;v<o.length-1;v++)m.push({label:o[v].title,url:Di(o[v].id)});const p=o[o.length-1];return m.push({label:(p==null?void 0:p.title)??n,url:void 0}),m}function Sk(){const n=gk();return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:n}),h.jsx("div",{className:A.emptyState,children:"Enter a prompt below to start a new session"})]})}function $b(n){const s=[];for(const l of n){const o=s[s.length-1];l.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+l.content}:s.push(l)}return s}function Qb(n){const s=new Map;for(const d of n)if(d.raw)try{s.set(d,JSON.parse(d.raw))}catch{}const l=new Map;for(const d of n){if(d.eventType!=="tool_use")continue;const f=s.get(d);if(!(!f||typeof f.id!="string"))try{const m=JSON.parse(d.content);l.set(f.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return n.map(d=>{if(d.eventType!=="tool_result")return d;const f=s.get(d);if(!f||typeof f.tool_use_id!="string")return d;const m=l.get(f.tool_use_id);return m?(o.add(f.tool_use_id),{...d,toolUseCtx:m}):d}).filter(d=>{if(d.eventType!=="tool_use")return!0;const f=s.get(d);return f&&typeof f.id=="string"?!o.has(f.id):!0})}function xk({sessionId:n,session:s,isActive:l,onKill:o}){return h.jsxs("div",{className:A.header,children:[h.jsxs("span",{children:["Session: ",n.slice(0,8),s&&` | ${s.runtime} | ${s.status}`]}),h.jsxs("span",{className:A.headerInfo,children:[s&&h.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),l&&h.jsx("button",{onClick:()=>o(n),title:"Stop session",className:A.killButton,children:"×"})]})]})}function _k({eventsDropped:n}){return n<=0?h.jsx(h.Fragment,{}):h.jsxs("div",{className:A.eventOverflowWarning,role:"alert",children:["⚠ ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Tk({sessionEvents:n,session:s,eventsDropped:l,scrollRef:o}){const c=s&&["completed","failed","interrupted"].includes(s.status),d=c?`Session ${s.status} with no events recorded.`:"Waiting for events...";return h.jsxs("div",{ref:o,className:A.eventScroll,children:[n.length===0&&h.jsx("div",{className:c?A.errorMessage:A.waitingMessage,children:d}),h.jsx(_k,{eventsDropped:l}),n.map((f,m)=>h.jsx(qb,{event:f,toolUseCtx:f.toolUseCtx},`${f.sessionId}-${f.timestamp}-${m}`))]})}function Ek(){const{sessionId:n}=Jr(),{events:s,eventsDropped:l,sessions:o,kill:c,loadSessionEvents:d}=Ft(),f=S.useRef(null),m=S.useRef(void 0),p=vk(n),v=o.find(_=>_.id===n)??void 0,y=S.useMemo(()=>{const _=n?s.filter(T=>T.sessionId===n):[];return Qb($b(_))},[s,n]);if(S.useEffect(()=>{n&&n!==m.current&&(m.current=n,d(n))},[n,d]),S.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[y.length]),!n)return h.jsx("div",{className:A.emptyState,children:"No session selected"});const b=(v==null?void 0:v.status)==="running"||(v==null?void 0:v.status)==="idle";return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:p}),h.jsx(xk,{sessionId:n,session:v,isActive:b,onKill:c}),h.jsx(Tk,{sessionEvents:y,session:v,eventsDropped:l,scrollRef:f})]})}const Oy=220,By=70,jk=40,Ck=60,Ak="hierarchy",Nk="dependency";function wk(n){return S.useMemo(()=>{if(n.length===0)return{nodes:[],edges:[]};const s=new Pg.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"TB",nodesep:jk,ranksep:Ck});const l=new Map(n.map(f=>[f.id,f])),o=new Map;for(const f of n)if(f.parentTaskId&&l.has(f.parentTaskId)){const m=o.get(f.parentTaskId)||[];m.push(f),o.set(f.parentTaskId,m)}for(const f of n)s.setNode(f.id,{width:Oy,height:By});const c=[];for(const f of n){if(f.parentTaskId&&l.has(f.parentTaskId)){const m=`hierarchy-${f.parentTaskId}-${f.id}`;s.setEdge(f.parentTaskId,f.id,{},m),c.push({id:m,source:f.parentTaskId,target:f.id,type:"smoothstep",data:{edgeType:Ak},style:{stroke:"var(--accent-green)",strokeWidth:2},animated:!1})}for(const m of f.dependsOn)if(l.has(m)){const p=`dependency-${m}-${f.id}`;s.setEdge(m,f.id,{},p),c.push({id:p,source:m,target:f.id,type:"smoothstep",data:{edgeType:Nk},style:{stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeDasharray:"6 3"},animated:!1})}}return Pg.layout(s),{nodes:n.map(f=>{const m=s.node(f.id),p=o.get(f.id)||[];return{id:f.id,type:"task",position:{x:m.x-Oy/2,y:m.y-By/2},data:{task:f,childCount:p.length,doneChildCount:p.filter(v=>v.status==="complete").length,hasDependencies:f.dependsOn.length>0}}}),edges:c}},[n])}const Dk="_dagContainer_3al6d_1",kk="_taskNode_3al6d_26",Rk="_taskNodeBorder_3al6d_48",Mk="_taskNodeContent_3al6d_54",Ok="_taskNodeHeader_3al6d_64",Bk="_taskNodeIcon_3al6d_71",Lk="_taskNodeTitle_3al6d_76",Uk="_taskNodeBadges_3al6d_84",zk="_childBadge_3al6d_89",Vk="_depBadge_3al6d_101",Hk="_handle_3al6d_113",Ik="_emptyCta_3al6d_120",Gk="_ctaDescription_3al6d_131",Pk="_ctaButton_3al6d_138",nn={dagContainer:Dk,taskNode:kk,taskNodeBorder:Rk,taskNodeContent:Mk,taskNodeHeader:Ok,taskNodeIcon:Bk,taskNodeTitle:Lk,taskNodeBadges:Uk,childBadge:zk,depBadge:Vk,handle:Hk,emptyCta:Ik,ctaDescription:Gk,ctaButton:Pk},Ly={not_started:{color:"var(--text-tertiary)",icon:"○"},working:{color:"var(--accent-green)",icon:"●"},paused:{color:"var(--accent-yellow)",icon:"◉"},complete:{color:"var(--accent-green)",icon:"✓"},failed:{color:"var(--accent-red)",icon:"✗"}};function qk({data:n}){const{task:s,childCount:l,doneChildCount:o,hasDependencies:c}=n,d=Ly[s.status]||Ly.not_started;return h.jsxs("div",{className:nn.taskNode,"data-task-id":s.id,"data-task-title":s.title,children:[h.jsx(qg,{type:"target",position:Yg.Top,className:nn.handle}),h.jsx("div",{className:nn.taskNodeBorder,style:{backgroundColor:d.color}}),h.jsxs("div",{className:nn.taskNodeContent,children:[h.jsxs("div",{className:nn.taskNodeHeader,children:[h.jsx("span",{className:nn.taskNodeIcon,style:{color:d.color},children:d.icon}),h.jsx("span",{className:nn.taskNodeTitle,children:s.title})]}),h.jsxs("div",{className:nn.taskNodeBadges,children:[l>0&&h.jsxs("span",{className:nn.childBadge,children:[o,"/",l]}),c&&h.jsx("span",{className:nn.depBadge,children:"dep"})]})]}),h.jsx(qg,{type:"source",position:Yg.Bottom,className:nn.handle})]})}const Yk={pending:"--text-tertiary",assigned:"--accent-blue",in_progress:"--accent-green",review:"--accent-yellow",done:"--accent-green",failed:"--accent-red",waiting_input:"--accent-yellow"},Kk={task:qk};function Zk({projectId:n}){const{tasks:s}=Ft(),l=oa(),{resolvedThemeId:o}=Zy(),c=S.useMemo(()=>s.filter(y=>y.projectId===n),[s,n]),{nodes:d,edges:f}=wk(c),m=S.useMemo(()=>{const y=getComputedStyle(document.documentElement),b={};for(const[_,T]of Object.entries(Yk))b[_]=y.getPropertyValue(T).trim()||"#6b7a8d";return b},[o]),p=S.useCallback((y,b)=>{l(Di(b.id))},[l]),v=S.useCallback(y=>{const b=y.data;return m[b.task.status]||m.pending},[m]);return c.length===0?h.jsxs("div",{className:nn.emptyCta,children:[h.jsx("button",{className:nn.ctaButton,onClick:()=>l(ki(n)),children:"Create Task"}),h.jsx("div",{className:nn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):h.jsx("div",{className:nn.dagContainer,children:h.jsxs(h1,{nodes:d,edges:f,nodeTypes:Kk,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[h.jsx(m1,{variant:p1.Dots,gap:24,size:1,color:"var(--text-disabled)"}),h.jsx(g1,{showInteractive:!1}),h.jsx(v1,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function Xk(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?A.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?A.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?A.envDotRed:A.envDotGray}function Uy(n){if(!n)return"";const s=new Date(n);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const d=Math.floor(c/60);if(d<24)return`${d}h ago`;const f=Math.floor(d/24);return f<30?`${f}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function $k(){const{projectId:n}=Jr(),s=oa(),{tasks:l,environments:o,projects:c,archiveProject:d,updateProject:f}=Ft(),[m,p]=S.useState("tasks"),[v,y]=S.useState(!1),[b,_]=S.useState(null),[T,N]=S.useState(""),[D,w]=S.useState(""),[j,V]=S.useState(!1),M=S.useRef(void 0),$=S.useRef(null),H=S.useRef(null),J=S.useRef(null),te=S.useRef(null),K=S.useRef(null),W=S.useRef(null),he=yk(n,c);S.useEffect(()=>{const Q=M.current;M.current=n,!(Q===void 0||Q===n)&&(b!==null||T!=="")&&(_(null),N(""))},[n,b,T]),S.useEffect(()=>{if(b===null)return;const Q=b==="name"?H.current:b==="description"?J.current:b==="repoUrl"?te.current:b==="worktreeBasePath"?W.current:K.current;if(!Q)return;const ce=window.setTimeout(()=>{Q.focus()},0);return()=>{window.clearTimeout(ce)}},[b]);const R=c.find(Q=>Q.id===n),ge=l.filter(Q=>Q.projectId===n),ne=ge.filter(Q=>Q.status==="complete").length,je=ge.length,G=je>0?Math.round(ne/je*100):0,U=100,X=(Q,ce)=>{$.current=Q,_(Q),N(ce),w("")},ee=()=>{$.current=null,_(null),N(""),w("")},Ae=(Q,ce)=>{if(Q==="name"){const Ie=ce.trim();if(!Ie)return"Name is required";if(Ie.length>U)return`Max ${U} characters`}if(Q==="repoUrl"){const Ie=ce.trim();if(Ie&&!/^https?:\/\/.+/.test(Ie))return"Must be a valid http(s) URL"}return""},Ee=Q=>{if(!R)return;const ce=T.trim(),Ie=Ae(Q,T);if(Ie){w(Ie);return}if(Q==="name"){if(ce===R.name){ee();return}f(R.id,{name:ce})}else if(Q==="description"){const F=T;if(F===R.description){ee();return}f(R.id,{description:F})}else if(Q==="repoUrl"){if(ce===R.repoUrl){ee();return}f(R.id,{repoUrl:ce})}else if(Q==="defaultEnvironmentId"){if(T===R.defaultEnvironmentId){ee();return}f(R.id,{defaultEnvironmentId:T})}else{if(ce===R.worktreeBasePath){ee();return}f(R.id,{worktreeBasePath:ce})}ee()},Ge=(Q,ce)=>{Q.key==="Escape"?ee():Q.key==="Enter"&&ce!=="description"&&Ee(ce)},we=Q=>R?Q==="name"?T.trim()!==R.name:Q==="description"?T!==R.description:Q==="repoUrl"?T.trim()!==R.repoUrl:Q==="defaultEnvironmentId"?T!==R.defaultEnvironmentId:T.trim()!==R.worktreeBasePath:!1,_e=o.find(Q=>Q.id===(R==null?void 0:R.defaultEnvironmentId)),Ce=b==="description"?"Tab to save · Esc to cancel":"Enter to save · Esc to cancel";return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:he}),h.jsxs("div",{className:A.projectHeader,children:[h.jsx("span",{className:A.projectName,"data-testid":"project-name",children:b==="name"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:H,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="name"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="name"||Ee("name")},onKeyDown:Q=>Ge(Q,"name"),maxLength:U,"aria-label":"Project name","data-testid":"edit-name-input"}),we("name")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("name",(R==null?void 0:R.name)||""),title:"Click to edit name","aria-label":`Edit project name: ${(R==null?void 0:R.name)||n}`,"data-testid":"edit-name-button",children:[(R==null?void 0:R.name)||n,h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})}),h.jsx("button",{className:A.archiveButton,onClick:()=>y(!0),title:"Archive project","data-testid":"archive-project-button",children:"Archive"})]}),h.jsxs("button",{className:A.metaToggle,onClick:()=>V(!j),"aria-expanded":!j,"aria-controls":"project-meta-panel","data-testid":"meta-toggle",children:[h.jsx("span",{className:`${A.metaToggleArrow} ${j?"":A.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!j&&h.jsxs("div",{className:A.projectMeta,"data-testid":"project-meta",id:"project-meta-panel",children:[h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Description"}),h.jsx("div",{className:A.metaValue,children:b==="description"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("textarea",{ref:J,className:A.editTextarea,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="description"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="description"||Ee("description")},onKeyDown:Q=>Ge(Q,"description"),title:"Project description","aria-label":"Project description","data-testid":"edit-description-input"}),we("description")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("description",(R==null?void 0:R.description)||""),title:"Click to edit description","aria-label":"Edit project description","data-testid":"edit-description-button",children:[R!=null&&R.description?h.jsx("span",{className:A.overviewMarkdown,children:h.jsx(uf,{remarkPlugins:[df],children:R.description})}):h.jsx("span",{className:A.metaPlaceholder,children:"No description"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Repository"}),h.jsx("div",{className:A.metaValue,children:b==="repoUrl"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:te,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="repoUrl"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="repoUrl"||Ee("repoUrl")},onKeyDown:Q=>Ge(Q,"repoUrl"),placeholder:"https://github.com/...","aria-label":"Project repository URL","data-testid":"edit-repo-input"}),we("repoUrl")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:Q=>{Q.preventDefault(),X("repoUrl",(R==null?void 0:R.repoUrl)||"")},title:"Click to edit repository URL","aria-label":"Edit project repository URL","data-testid":"edit-repo-button",children:[R!=null&&R.repoUrl&&/^https?:\/\//i.test(R.repoUrl)?h.jsx("a",{className:A.repoLink,href:R.repoUrl,target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),children:R.repoUrl}):R!=null&&R.repoUrl?h.jsx("span",{children:R.repoUrl}):h.jsx("span",{className:A.metaPlaceholder,children:"No repository"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Environment"}),h.jsx("div",{className:A.metaValue,children:b==="defaultEnvironmentId"?h.jsxs("select",{ref:K,className:A.editSelect,value:T,onChange:Q=>{$.current=null,N(Q.target.value);const ce=Q.target.value;R&&ce!==R.defaultEnvironmentId&&f(R.id,{defaultEnvironmentId:ce}),ee()},onBlur:Q=>{if($.current==="defaultEnvironmentId"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="defaultEnvironmentId"||ee()},title:"Default environment","aria-label":"Project default environment","data-testid":"edit-env-select",children:[h.jsx("option",{value:"",children:"None"}),o.map(Q=>h.jsx("option",{value:Q.id,children:Q.displayName},Q.id))]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("defaultEnvironmentId",(R==null?void 0:R.defaultEnvironmentId)||""),title:"Click to change default environment","aria-label":"Edit project default environment","data-testid":"edit-env-button",children:[_e?h.jsxs("span",{className:A.envRow,children:[h.jsx("span",{className:`${A.envDot} ${Xk(_e.status)}`}),_e.displayName]}):h.jsx("span",{className:A.metaPlaceholder,children:(R==null?void 0:R.defaultEnvironmentId)||"No default environment"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Worktree Base"}),h.jsx("div",{className:A.metaValue,children:b==="worktreeBasePath"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:W,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="worktreeBasePath"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="worktreeBasePath"||Ee("worktreeBasePath")},onKeyDown:Q=>Ge(Q,"worktreeBasePath"),placeholder:"/workspaces/my-repo","aria-label":"Worktree base path","data-testid":"edit-worktree-base-path-input"}),we("worktreeBasePath")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("worktreeBasePath",(R==null?void 0:R.worktreeBasePath)||""),title:"Click to edit worktree base path","aria-label":"Edit worktree base path","data-testid":"edit-worktree-base-path-button",children:[R!=null&&R.worktreeBasePath?h.jsx("span",{children:R.worktreeBasePath}):h.jsx("span",{className:A.metaPlaceholder,children:"Default (server default)"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),R&&h.jsxs("div",{className:A.metaTimestamps,children:[h.jsxs("span",{className:A.metaTimestamp,children:["Created ",Uy(R.createdAt)]}),R.updatedAt&&R.updatedAt!==R.createdAt&&h.jsxs("span",{className:A.metaTimestamp,children:["· Updated ",Uy(R.updatedAt)]})]})]}),je>0&&h.jsxs("div",{className:A.progressBarContainer,"data-testid":"progress-bar",children:[h.jsx("div",{className:A.progressBar,children:h.jsx("div",{className:A.progressFill,style:{width:`${G}%`}})}),h.jsxs("span",{className:A.progressLabel,children:[ne,"/",je]})]}),h.jsxs("div",{className:A.tabBar,role:"tablist","aria-label":"Project view",children:[h.jsx("button",{role:"tab","aria-selected":m==="graph",className:`${A.tab} ${m==="graph"?A.active:""}`,onClick:()=>p("graph"),children:"Graph"}),h.jsx("button",{role:"tab","aria-selected":m==="tasks",className:`${A.tab} ${m==="tasks"?A.active:""}`,onClick:()=>p("tasks"),children:"Tasks"})]}),m==="tasks"&&je>0&&h.jsxs("div",{className:A.projectSummary,children:[h.jsx("span",{className:A.projectSummaryTitle,children:`${ne}/${je} tasks complete`}),h.jsx("span",{className:A.projectSummarySubtitle,children:"Select a task or click + to create one"})]}),m==="tasks"&&je===0&&h.jsxs("div",{className:A.emptyCta,children:[h.jsx("button",{className:A.ctaButton,onClick:()=>s(ki(n)),children:"Create Task"}),h.jsx("div",{className:A.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),m==="graph"&&h.jsx(Zk,{projectId:n}),h.jsx(lc,{isOpen:v,title:"Archive Project?",description:"This will hide the project from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{R&&(d(R.id),s("/",{replace:!0})),y(!1)},onCancel:()=>y(!1)})]})}const Qk="_container_yc33j_1",Fk="_header_yc33j_8",Jk="_headerTitle_yc33j_35",Wk="_badge_yc33j_44",eR="_headerActions_yc33j_54",tR="_body_yc33j_61",nR="_formContent_yc33j_68",aR="_section_yc33j_75",sR="_label_yc33j_81",iR="_titleInput_yc33j_88",lR="_descriptionTextarea_yc33j_121",oR="_parentContext_yc33j_157",rR="_parentLabel_yc33j_165",cR="_parentName_yc33j_172",uR="_depList_yc33j_210",dR="_depItem_yc33j_216",fR="_depItemSelected_yc33j_238",hR="_noDeps_yc33j_242",mR="_btnPrimary_yc33j_248",pR="_btnGhost_yc33j_279",ut={container:Qk,header:Fk,headerTitle:Jk,badge:Wk,headerActions:eR,body:tR,formContent:nR,section:aR,label:sR,titleInput:iR,descriptionTextarea:lR,parentContext:oR,parentLabel:rR,parentName:cR,depList:uR,depItem:dR,depItemSelected:fR,noDeps:hR,btnPrimary:mR,btnGhost:pR};function Fb({mode:n,taskId:s,projectId:l,parentTaskId:o}){const{tasks:c,createTask:d,updateTask:f}=Ft(),{showToast:m}=to(),p=oa(),v=n==="edit",y=v&&s?c.find(R=>R.id===s):void 0,b=v?(y==null?void 0:y.projectId)??"":l??"",_=v?(y==null?void 0:y.parentTaskId)??"":o??"",T=_?c.find(R=>R.id===_):void 0,[N,D]=S.useState((y==null?void 0:y.title)??""),[w,j]=S.useState((y==null?void 0:y.description)??""),[V,M]=S.useState((y==null?void 0:y.dependsOn)??[]),$=S.useRef(!1);S.useEffect(()=>{v&&y&&!$.current&&($.current=!0,D(y.title),j(y.description),M(y.dependsOn))},[v,y]);const H=c.filter(R=>R.projectId===b&&(!v||R.id!==s)&&R.id!==_),J=N.trim().length>0&&(!v||y!==void 0)&&(v||b.length>0),te=R=>{M(ge=>ge.includes(R)?ge.filter(ne=>ne!==R):[...ge,R])},K=()=>{J&&(v&&y===void 0||(v&&s?(f(s,N.trim(),w,V),m("Task updated","success"),p(Di(s),{replace:!0})):(d(b,N.trim(),w,V.length>0?V:void 0,_||void 0),m("Task created","success"),p($l(b),{replace:!0}))))},W=()=>{p(v&&s?Di(s):$l(b))},he=v?"edit task":_?"child task":"new task";return h.jsxs("div",{className:ut.container,children:[h.jsxs("div",{className:ut.header,children:[h.jsxs("div",{className:ut.headerTitle,children:[h.jsx("span",{className:ut.badge,children:he}),T&&h.jsxs("span",{className:ut.parentContext,children:[h.jsx("span",{className:ut.parentLabel,children:"Child of"}),h.jsx("span",{className:ut.parentName,children:T.title})]})]}),h.jsxs("div",{className:ut.headerActions,children:[h.jsx("button",{onClick:K,disabled:!J,className:ut.btnPrimary,"data-testid":"task-edit-save",children:v?"Save Changes":"Create"}),h.jsx("button",{onClick:W,className:ut.btnGhost,children:"Cancel"})]})]}),h.jsx("div",{className:ut.body,children:h.jsxs("div",{className:ut.formContent,children:[h.jsxs("div",{className:ut.section,children:[h.jsx("label",{className:ut.label,htmlFor:"task-edit-title",children:"Title"}),h.jsx("input",{id:"task-edit-title",type:"text",value:N,onChange:R=>D(R.target.value),placeholder:"Task title...",autoFocus:!0,className:ut.titleInput,"data-testid":"task-edit-title",onKeyDown:R=>{R.key==="Enter"&&J&&K()}})]}),h.jsxs("div",{className:ut.section,children:[h.jsx("label",{className:ut.label,htmlFor:"task-edit-description",children:"Description"}),h.jsx("textarea",{id:"task-edit-description",value:w,onChange:R=>j(R.target.value),placeholder:"Describe the task... (markdown supported)",className:ut.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),h.jsxs("div",{className:ut.section,children:[h.jsx("div",{className:ut.label,children:"Dependencies"}),H.length===0?h.jsx("div",{className:ut.noDeps,children:"No other tasks in this project"}):h.jsx("div",{className:ut.depList,children:H.map(R=>{const ge=V.includes(R.id);return h.jsxs("label",{className:`${ut.depItem} ${ge?ut.depItemSelected:""}`,"data-testid":`dep-option-${R.id}`,children:[h.jsx("input",{type:"checkbox",checked:ge,onChange:()=>te(R.id)}),R.title,h.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",R.status,")"]})]},R.id)})})]})]})})]})}function gR(){const[n]=Sf(),s=n.get("project")??"",l=n.get("parent")??void 0;return s?h.jsx(Fb,{mode:"new",projectId:s,parentTaskId:l}):h.jsx(Mr,{to:"/",replace:!0})}function vR(){const{taskId:n}=Jr();return h.jsx(Fb,{mode:"edit",taskId:n})}const yR="_container_u6n1v_1",bR="_emptyState_u6n1v_8",SR="_card_u6n1v_14",xR="_cardHeader_u6n1v_34",_R="_categoryBadge_u6n1v_41",TR="_findingTitle_u6n1v_49",ER="_findingDate_u6n1v_55",jR="_findingContent_u6n1v_61",CR="_tags_u6n1v_67",AR="_tag_u6n1v_67",na={container:yR,emptyState:bR,card:SR,cardHeader:xR,categoryBadge:_R,findingTitle:TR,findingDate:ER,findingContent:jR,tags:CR,tag:AR};function NR(n){const s=new Date(n),l=new Date,o=l.getTime()-s.getTime(),c=Math.floor(o/1e3),d=Math.floor(c/60),f=Math.floor(d/60),m=Math.floor(f/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(f<24)return`${f}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const p=s.getFullYear()===l.getFullYear(),v=s.toLocaleString("en-US",{month:"short"}),y=s.getDate();return p?`${v} ${y}`:`${v} ${y} ${s.getFullYear()}`}const zy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function wR({projectId:n}){const{findings:s}=Ft(),l=s.filter(o=>o.projectId===n);return l.length===0?h.jsx("div",{className:na.emptyState,children:"No findings yet. Agents will post discoveries here."}):h.jsx("div",{className:na.container,children:l.map((o,c)=>{const d=zy[o.category]||zy.general;return h.jsxs(la.div,{className:na.card,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:c*.05,duration:.2},children:[h.jsxs("div",{className:na.cardHeader,children:[h.jsx("span",{className:na.categoryBadge,style:{background:d.bg,color:d.text},children:o.category}),h.jsx("span",{className:na.findingTitle,children:o.title}),h.jsx("span",{className:na.findingDate,title:o.createdAt,children:NR(o.createdAt)})]}),h.jsx("div",{className:na.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&h.jsx("div",{className:na.tags,children:o.tags.map(f=>h.jsx("span",{className:na.tag,style:{color:d.text,textShadow:`0 0 8px ${d.text}`},children:f},f))})]},o.id)})})}function Dr(n){if(!n)return"—";const s=new Date(n);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ld(n,s){if(!n||!s)return;const l=new Date(s).getTime()-new Date(n).getTime();if(isNaN(l)||l<0)return;const o=Math.floor(l/6e4),c=Math.floor(l%6e4/1e3);if(o===0)return`${c}s`;const d=Math.floor(o/60),f=o%60;return d===0?`${o}m ${c}s`:`${d}h ${f}m`}function DR(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?A.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?A.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?A.envDotRed:A.envDotGray}function kR({status:n}){const s={not_started:"Not Started",working:"Working",paused:"Paused",complete:"Complete",failed:"Failed"},l={not_started:A.statusPending,working:A.statusInProgress,paused:A.statusWaitingInput,complete:A.statusDone,failed:A.statusFailed};return h.jsx("span",{className:`${A.statusBadge} ${l[n]??A.statusPending}`,children:s[n]??n})}function RR({task:n,tasksById:s,environments:l,projects:o,taskSessions:c}){const d=c.length>0?c[c.length-1]:void 0,f=(d==null?void 0:d.environmentId)??"",m=f?l.find(y=>y.id===f):void 0,p=o.find(y=>y.id===n.projectId),v=n.branch&&(p!=null&&p.repoUrl)?`${p.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(n.branch)}`:void 0;return h.jsxs("div",{className:A.overviewDashboard,children:[h.jsxs("div",{className:A.overviewHero,children:[h.jsx(kR,{status:n.status}),n.branch&&h.jsx("span",{className:A.overviewBranchPill,children:v?h.jsxs("a",{href:v,target:"_blank",rel:"noreferrer noopener",className:A.branchLink,children:["🔗"," ",n.branch]}):h.jsxs("span",{children:["🔗"," ",n.branch]})})]}),typeof n.description=="string"&&n.description&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Description"}),h.jsx("div",{className:A.overviewMarkdown,children:h.jsx(uf,{remarkPlugins:[df],children:n.description})})]}),f&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Environment"}),h.jsxs("div",{className:A.envRow,children:[m&&h.jsx("span",{className:`${A.envDot} ${DR(m.status)}`,title:m.status,"aria-label":`Status: ${m.status}`,role:"img"}),h.jsx("span",{className:A.overviewValue,children:(m==null?void 0:m.displayName)??f})]})]}),h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Dependencies"}),n.dependsOn.length===0?h.jsx("div",{className:A.overviewMuted,children:"None"}):h.jsx("div",{className:A.depList,children:n.dependsOn.map(y=>{const b=s.get(y),_=(b==null?void 0:b.status)==="complete";return h.jsxs("div",{className:`${A.depItem} ${_?A.depDone:A.depBlocked}`,children:[h.jsx("span",{children:_?"✓":"○"}),h.jsx("span",{children:(b==null?void 0:b.title)??y})]},y)})})]}),h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Timeline"}),h.jsxs("div",{className:A.timeline,children:[n.createdAt&&h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Created"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.createdAt)})]}),n.assignedAt&&(()=>{const y=Ld(n.createdAt,n.assignedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Assigned"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.assignedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),n.startedAt&&(()=>{const y=Ld(n.assignedAt??n.createdAt,n.startedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Started"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.startedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),n.completedAt&&(()=>{const y=Ld(n.startedAt,n.completedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Completed"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.completedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),!n.createdAt&&!n.assignedAt&&!n.startedAt&&!n.completedAt&&h.jsx("div",{className:A.overviewMuted,children:"No timing data"})]})]}),n.reviewNotes&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Review Notes"}),h.jsx("div",{className:A.reviewNotes,children:n.reviewNotes})]})]})}function MR({eventsDropped:n}){return n<=0?h.jsx(h.Fragment,{}):h.jsxs("div",{className:A.eventOverflowWarning,role:"alert",children:["⚠ ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown."]})}function OR({task:n,sessionId:s,isBlocked:l,onStart:o,onResume:c,onStop:d,onComplete:f,onDelete:m,onEdit:p}){if(n.status==="not_started")return l?h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:p,className:A.btnGhost,children:"Edit"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]}):h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:o,className:A.btnPrimary,children:"Start"}),h.jsx("button",{onClick:p,className:A.btnGhost,children:"Edit"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]});if(n.status==="working")return h.jsx("div",{className:A.headerActions,children:h.jsx("button",{onClick:d,disabled:!s,className:A.btnDanger,children:"Stop"})});if(n.status==="paused")return h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:f,className:A.btnPrimary,children:"Complete"}),h.jsx("button",{onClick:c,className:A.btnGhost,children:"Resume"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]});if(n.status==="complete")return h.jsx("div",{className:A.headerActions,children:h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})});if(n.status==="failed")return h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:o,className:A.btnPrimary,children:"Retry"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]})}function BR({taskSessions:n,selectedSessionId:s,onSelect:l}){if(!(n.length<2))return h.jsxs("div",{className:A.attemptSelector,"data-testid":"attempt-selector",children:[h.jsx("span",{className:A.attemptLabel,children:"Attempts:"}),n.map((o,c)=>{const d=o.id===s,f=o.status==="completed"?"✓":o.status==="failed"?"✗":o.status==="running"||o.status==="idle"?"●":"";return h.jsxs("button",{className:`${A.attemptButton} ${d?A.attemptActive:""}`,onClick:()=>l(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":d,"data-testid":`attempt-${c+1}`,children:["#",c+1,f&&h.jsx("span",{className:A.attemptStatus,children:f})]},o.id)})]})}function Ud(){const{taskId:n}=Jr(),s=an(),l=oa(),{events:o,eventsDropped:c,tasks:d,environments:f,loadSessionEvents:m,loadFindings:p,kill:v,startTask:y,resumeTask:b,completeTask:_,deleteTask:T,projects:N,taskSessions:D,loadTaskSessions:w}=Ft(),j=S.useRef(null),V=S.useRef(void 0),M=S.useRef(void 0),$=S.useRef(void 0),H=S.useRef(void 0),J=S.useRef(void 0),te=s.pathname.endsWith("/stream")?"stream":s.pathname.endsWith("/findings")?"findings":"overview",[K,W]=S.useState(te),[he,R]=S.useState(!1),[ge,ne]=S.useState(void 0),je=S.useRef(te);te!==je.current&&(je.current=te,te!==K&&W(te));const G=d.find(ce=>ce.id===n),U=(G==null?void 0:G.projectId)||void 0,X=G?D[G.id]??[]:[];let ee;ge&&X.some(ce=>ce.id===ge)?ee=ge:ee=(G==null?void 0:G.latestSessionId)||void 0;const Ae=()=>{R(!0)},Ee=()=>{G&&(T(G.id),R(!1),l($l(G.projectId),{replace:!0}))};if((G==null?void 0:G.id)!==M.current&&(M.current=G==null?void 0:G.id,ge!==void 0&&ne(void 0)),S.useEffect(()=>{if(!(G!=null&&G.id))return;const ce=G.id!==H.current,Ie=G.latestSessionId!==J.current;(ce||Ie)&&(H.current=G.id,J.current=G.latestSessionId,w(G.id))},[G==null?void 0:G.id,G==null?void 0:G.latestSessionId,w]),(G==null?void 0:G.status)!==$.current){$.current=G==null?void 0:G.status;const ce=(G==null?void 0:G.status)==="not_started"?"overview":(G==null?void 0:G.status)==="working"||(G==null?void 0:G.status)==="paused"?"stream":(G==null?void 0:G.status)==="complete"?"findings":void 0;ce&&ce!==K&&W(ce)}const Ge=S.useMemo(()=>new Map(d.map(ce=>[ce.id,ce])),[d]),we=S.useMemo(()=>{const ce=ee?o.filter(Ie=>Ie.sessionId===ee):[];return Qb($b(ce))},[o,ee]),_e=G?G.dependsOn.some(ce=>{const Ie=Ge.get(ce);return Ie!==void 0&&Ie.status!=="complete"}):!1,Ce=S.useMemo(()=>bk(n,N,Ge),[n,N,Ge]);S.useEffect(()=>{ee&&ee!==V.current&&(V.current=ee,m(ee))},[ee,m]),S.useEffect(()=>{K==="findings"&&U&&p(U)},[K,U,p]),S.useEffect(()=>{j.current&&K==="stream"&&(j.current.scrollTop=j.current.scrollHeight)},[we.length,K]);const Q=ce=>{W(ce),l(Di(n,ce==="overview"?void 0:ce))};return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:Ce}),h.jsxs("div",{className:A.header,children:[h.jsxs("span",{className:A.headerTitle,children:[h.jsx("span",{"data-testid":"task-title",children:(G==null?void 0:G.title)||n}),G&&h.jsx("span",{className:A.taskStatusBadge,"data-testid":"task-status",children:G.status}),(G==null?void 0:G.branch)&&h.jsx("span",{className:A.taskBranch,children:G.branch}),_e&&h.jsx("span",{className:A.taskBlockedBadge,children:"blocked"})]}),G&&h.jsx(OR,{task:G,sessionId:ee,isBlocked:_e,onStart:()=>y(G.id),onResume:()=>b(G.id),onStop:()=>ee&&v(ee),onComplete:()=>_(G.id),onDelete:Ae,onEdit:()=>l(kT(G.id))})]}),h.jsxs("div",{className:A.tabBar,role:"tablist","aria-label":"Task view",children:[h.jsx("button",{role:"tab","aria-selected":K==="overview",className:`${A.tab} ${K==="overview"?A.active:""}`,onClick:()=>Q("overview"),children:"Overview"}),h.jsx("button",{role:"tab","aria-selected":K==="stream",className:`${A.tab} ${K==="stream"?A.active:""}`,onClick:()=>Q("stream"),children:"Stream"}),h.jsx("button",{role:"tab","aria-selected":K==="findings",className:`${A.tab} ${K==="findings"?A.active:""}`,onClick:()=>Q("findings"),children:"Findings"})]}),h.jsxs(Ui,{mode:"wait",children:[K==="overview"&&h.jsx(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:A.overviewContent,children:G?h.jsx(RR,{task:G,tasksById:Ge,environments:f,projects:N,taskSessions:X}):h.jsx("div",{className:A.waitingMessage,children:"No additional details"})},"overview"),K==="stream"&&h.jsxs(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[h.jsx(BR,{taskSessions:X,selectedSessionId:ee,onSelect:ce=>ne(ce)}),h.jsxs("div",{ref:j,className:A.eventScroll,children:[!ee&&G&&h.jsxs("div",{className:A.emptyCta,children:[h.jsx("button",{className:A.ctaButton,onClick:()=>y(G.id),children:"Start Task"}),h.jsx("div",{className:A.ctaDescription,children:"Click to begin agent execution"})]}),ee&&we.length===0&&h.jsx("div",{className:A.waitingMessage,children:"Waiting for events..."}),h.jsx(MR,{eventsDropped:c}),we.map((ce,Ie)=>h.jsx(qb,{event:ce,toolUseCtx:ce.toolUseCtx},`${ce.sessionId}-${ce.timestamp}-${Ie}`))]})]},"stream"),K==="findings"&&h.jsx(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:A.tabContent,children:U?h.jsx(wR,{projectId:U}):h.jsx("div",{className:A.noContext,children:"Navigate to a task within a project to view findings"})},"findings")]}),G&&h.jsx(lc,{isOpen:he,title:"Delete Task?",description:`"${G.title}" will be permanently removed.`,onConfirm:Ee,onCancel:()=>R(!1)})]})}function LR(){const n=pk();return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:n}),h.jsx("div",{className:A.emptyState,children:"Configure the new environment below"})]})}const UR="_layout_1sbe4_1",zR="_content_1sbe4_8",Vy={layout:UR,content:zR},VR={environments:"Environments",credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About"};function HR(){const s=an().pathname.replace(/^\/settings\/?/,"").split("/")[0],l=VR[s],o=mk(l);return h.jsxs("div",{className:Vy.layout,children:[h.jsx(Hi,{segments:o}),h.jsx("div",{className:Vy.content,children:h.jsx(r0,{})})]})}const IR="_nav_29xjr_1",GR="_tab_29xjr_30",PR="_tabIcon_29xjr_56",qR="_tabActive_29xjr_62",kr={nav:IR,tab:GR,tabIcon:PR,tabActive:qR},Aa=[{path:"environments",label:"Environments",icon:"🖥️"},{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"about",label:"About",icon:"ℹ️"}];function YR(){var f;const n=an(),s=oa(),l=S.useRef(null),o=((f=Aa.find(m=>n.pathname===`${wi}/${m.path}`))==null?void 0:f.path)??Aa[0].path,c=S.useCallback(m=>{s(`${wi}/${m}`)},[s]),d=S.useCallback(m=>{var T,N;const p=(T=l.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!p)return;const v=Array.from(p).findIndex(D=>D===document.activeElement),y=v>=0?v:Aa.findIndex(D=>D.path===o);let b=y;if(m.key==="ArrowDown")m.preventDefault(),b=(y+1)%Aa.length;else if(m.key==="ArrowUp")m.preventDefault(),b=(y-1+Aa.length)%Aa.length;else if(m.key==="Home")m.preventDefault(),b=0;else if(m.key==="End")m.preventDefault(),b=Aa.length-1;else return;const _=Aa[b].path;s(`${wi}/${_}`),(N=p[b])==null||N.focus()},[o,s]);return h.jsx("nav",{className:kr.nav,ref:l,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Aa.map(m=>{const p=m.path===o;return h.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${kr.tab} ${p?kr.tabActive:""}`,onClick:()=>c(m.path),children:[h.jsx("span",{className:kr.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}const KR="_container_1nk8c_1",ZR="_header_1nk8c_5",XR="_headerLabel_1nk8c_12",$R="_addButton_1nk8c_20",QR="_envRow_1nk8c_55",FR="_targeted_1nk8c_69",JR="_expanded_1nk8c_72",WR="_statusDot_1nk8c_76",eM="_pulse_1nk8c_79",tM="_envName_1nk8c_83",nM="_envActions_1nk8c_87",aM="_idleLabel_1nk8c_94",sM="_newChatButton_1nk8c_99",iM="_envActionsRow_1nk8c_126",lM="_connectButton_1nk8c_134",oM="_stopButton_1nk8c_160",rM="_deleteButton_1nk8c_186",cM="_provisionMessage_1nk8c_213",uM="_errorMessage_1nk8c_220",dM="_sessionRow_1nk8c_227",fM="_selected_1nk8c_243",hM="_sessionDot_1nk8c_248",mM="_sessionSummaryRow_1nk8c_252",pM="_sessionExpandArrow_1nk8c_272",gM="_sessionSummaryText_1nk8c_283",vM="_sessionCountBadge_1nk8c_290",yM="_emptyCta_1nk8c_313",bM="_ctaDescription_1nk8c_326",SM="_ctaButton_1nk8c_332",Ke={container:KR,header:ZR,headerLabel:XR,addButton:$R,envRow:QR,targeted:FR,expanded:JR,statusDot:WR,pulse:eM,envName:tM,envActions:nM,idleLabel:aM,newChatButton:sM,envActionsRow:iM,connectButton:lM,stopButton:oM,deleteButton:rM,provisionMessage:cM,errorMessage:uM,sessionRow:dM,selected:fM,sessionDot:hM,sessionSummaryRow:mM,sessionExpandArrow:pM,sessionSummaryText:gM,sessionCountBadge:vM,emptyCta:yM,ctaDescription:bM,ctaButton:SM},xM={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"},_M={running:"running",idle:"awaiting input",failed:"failed",interrupted:"interrupted",completed:"completed"},Hy=["running","idle","failed","interrupted","completed"],TM=.2;function EM(n){const s={};for(const d of n)s[d.status]=(s[d.status]||0)+1;const l=Hy.filter(d=>s[d]>0).map(d=>`${s[d]} ${_M[d]||d}`),o=new Set(Hy),c=Object.keys(s).filter(d=>!o.has(d)).sort().map(d=>`${s[d]} ${d}`);return[...l,...c].join(", ")}function jM({status:n}){const s=n==="running"?"var(--accent-green)":n==="idle"?"var(--accent-yellow)":n==="completed"?"var(--text-secondary)":n==="failed"||n==="interrupted"?"var(--accent-red)":"var(--text-tertiary)";return h.jsx("span",{className:Ke.sessionDot,style:{color:s},children:"●"})}function CM({env:n,envSessions:s,selectedSessionId:l,isNewChatTarget:o,expanded:c,onToggleExpand:d,sessionsExpanded:f,onToggleSessionsExpand:m,provisionProgress:p,onProvision:v,onStop:y,onRemove:b,navigate:_}){const[T,N]=S.useState(!1),D=xM[n.status]||"var(--text-tertiary)",w=n.status==="connected",j=n.status==="connecting",V=n.status==="disconnected"||n.status==="error";return h.jsxs("div",{children:[h.jsx(lc,{isOpen:T,title:"Delete Environment?",description:`"${n.displayName||n.id}" will be permanently removed. This destroys the workspace and removes all data.`,onConfirm:()=>{b(n.id),N(!1)},onCancel:()=>N(!1)}),h.jsxs("div",{className:`${Ke.envRow} ${o?Ke.targeted:""} ${c?Ke.expanded:""}`,"data-testid":"env-row",onClick:d,children:[h.jsx("span",{className:`${Ke.statusDot} ${w?Ke.pulse:""}`,style:{color:D},children:"●"}),h.jsx("span",{className:Ke.envName,title:n.displayName||n.id,children:n.displayName||n.id}),h.jsxs("span",{className:Ke.envActions,children:[s.length===0&&!o&&!c&&h.jsx("span",{className:Ke.idleLabel,children:"(idle)"}),w&&h.jsx("button",{onClick:M=>{M.stopPropagation(),_(m0(n.id,n.defaultRuntime||"claude-code"))},title:"New chat",className:Ke.newChatButton,children:"+"})]})]}),c&&h.jsxs("div",{className:Ke.envActionsRow,children:[j&&p&&h.jsx("span",{className:Ke.provisionMessage,children:p.message}),n.status==="error"&&(p==null?void 0:p.stage)==="error"&&h.jsx("span",{className:Ke.errorMessage,children:p.message}),V&&h.jsx("button",{onClick:M=>{M.stopPropagation(),v(n.id)},className:Ke.connectButton,children:n.status==="error"?"Retry":"Connect"}),w&&h.jsx("button",{onClick:M=>{M.stopPropagation(),y(n.id)},className:Ke.stopButton,children:"Stop"}),!j&&h.jsx("button",{onClick:M=>{M.stopPropagation(),N(!0)},className:Ke.deleteButton,children:"Delete"})]}),s.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Ke.sessionSummaryRow,"data-testid":"session-summary-row",role:"button",tabIndex:0,"aria-expanded":f,"aria-label":f?"Collapse sessions":"Expand sessions",onClick:m,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),m())},children:[h.jsx("span",{className:`${Ke.sessionExpandArrow} ${f?Ke.expanded:""}`,children:"▸"}),h.jsx("span",{className:Ke.sessionSummaryText,children:EM(s)}),h.jsx("span",{className:Ke.sessionCountBadge,children:s.length})]}),h.jsx(Ui,{children:f&&h.jsx(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:TM,ease:"easeInOut"},style:{overflow:"hidden"},children:s.map(M=>h.jsxs("div",{onClick:$=>{$.stopPropagation(),_(h0(M.id))},className:`${Ke.sessionRow} ${l===M.id?Ke.selected:""}`,title:M.prompt,"data-testid":"session-row",children:[h.jsx(jM,{status:M.status})," ",M.prompt.length>24?M.prompt.slice(0,24)+"...":M.prompt]},M.id))})})]})]})}function AM(){const{environments:n,sessions:s,provisionStatus:l,provisionEnvironment:o,stopEnvironment:c,removeEnvironment:d}=Ft(),f=oa(),[m,p]=S.useState(null),[v,y]=S.useState(new Set),b=tn("/sessions/:sessionId"),_=tn("/sessions/new"),T=(b==null?void 0:b.params.sessionId)!=="new"?b==null?void 0:b.params.sessionId:void 0,[N]=Sf(),D=_?N.get("env")??void 0:void 0;return h.jsxs("div",{className:Ke.container,children:[h.jsxs("div",{className:Ke.header,children:[h.jsx("span",{className:Ke.headerLabel,children:"Environments"}),h.jsx("button",{className:Ke.addButton,onClick:()=>f(cv),title:"Add environment",children:"+ Add Environment"})]}),n.length===0&&h.jsxs("div",{className:Ke.emptyCta,children:[h.jsx("button",{className:Ke.ctaButton,onClick:()=>f(cv),children:"Add Environment"}),h.jsx("div",{className:Ke.ctaDescription,children:"Connect an environment to run agents"})]}),n.map(w=>{const j=s.filter(V=>V.environmentId===w.id);return h.jsx(CM,{env:w,envSessions:j,selectedSessionId:T,isNewChatTarget:D===w.id,expanded:m===w.id,onToggleExpand:()=>p(m===w.id?null:w.id),sessionsExpanded:v.has(w.id),onToggleSessionsExpand:()=>{y(V=>{const M=new Set(V);return M.has(w.id)?M.delete(w.id):M.add(w.id),M})},provisionProgress:l[w.id],onProvision:o,onStop:c,onRemove:d,navigate:f},w.id)})]})}function NM(){return h.jsx(AM,{})}const wM="_section_1ingb_14",DM="_sectionTitle_1ingb_26",kM="_sectionDescription_1ingb_35",RM="_tokenList_1ingb_48",MM="_tokenRow_1ingb_55",OM="_tokenBadge_1ingb_68",BM="_tokenName_1ingb_83",LM="_tokenTarget_1ingb_90",UM="_deleteButton_1ingb_99",zM="_addForm_1ingb_113",VM="_formRow_1ingb_119",HM="_input_1ingb_125",IM="_select_1ingb_155",GM="_addButton_1ingb_187",PM="_emptyStateInfo_1ingb_221",qM="_themeOptions_1ingb_229",YM="_themeOption_1ingb_229",KM="_themeOptionSelected_1ingb_254",ZM="_themeOptionHeader_1ingb_259",XM="_themeOptionLabel_1ingb_266",$M="_themeOptionDesc_1ingb_273",QM="_variantToggle_1ingb_279",FM="_variantButton_1ingb_286",JM="_variantActive_1ingb_305",WM="_themeSwatches_1ingb_311",e3="_themeSwatch_1ingb_311",t3="_systemToggle_1ingb_325",n3="_systemToggleHint_1ingb_341",a3="_themeActive_1ingb_348",s3="_aboutGrid_1ingb_354",i3="_aboutItem_1ingb_360",l3="_aboutLabel_1ingb_373",o3="_aboutValue_1ingb_379",r3="_aboutDot_1ingb_387",c3="_aboutDotConnected_1ingb_394",u3="_aboutDotDisconnected_1ingb_398",fe={section:wM,sectionTitle:DM,sectionDescription:kM,tokenList:RM,tokenRow:MM,tokenBadge:OM,tokenName:BM,tokenTarget:LM,deleteButton:UM,addForm:zM,formRow:VM,input:HM,select:IM,addButton:GM,emptyStateInfo:PM,themeOptions:qM,themeOption:YM,themeOptionSelected:KM,themeOptionHeader:ZM,themeOptionLabel:XM,themeOptionDesc:$M,variantToggle:QM,variantButton:FM,variantActive:JM,themeSwatches:WM,themeSwatch:e3,systemToggle:t3,systemToggleHint:n3,themeActive:a3,aboutGrid:s3,aboutItem:i3,aboutLabel:l3,aboutValue:o3,aboutDot:r3,aboutDotConnected:c3,aboutDotDisconnected:u3},d3=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function f3(){const{credentialProviders:n,updateCredentialProviders:s}=Ft(),l=(o,c)=>{const d={...n};o==="claude"?d.claude=c:d[o]=c,s(d)};return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),h.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),h.jsx("div",{className:fe.tokenList,children:d3.map(o=>h.jsxs("div",{className:fe.tokenRow,children:[h.jsx("span",{className:fe.tokenName,children:o.label}),h.jsx("span",{className:fe.tokenTarget,children:o.description}),h.jsx("select",{className:fe.select,value:n[o.key],onChange:c=>l(o.key,c.target.value),children:o.options.map(c=>h.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const h3=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function m3(){const{tokens:n,setToken:s,deleteToken:l}=Ft(),{showToast:o}=to(),[c,d]=S.useState(""),[f,m]=S.useState(""),[p,v]=S.useState("env_var"),[y,b]=S.useState(""),[_,T]=S.useState(null),N=j=>{if(j.preventDefault(),!c||!f)return;const V=p==="env_var"?y||c.toUpperCase()+"_TOKEN":"";s(c,f,p,V,p==="file"?y:""),o("Token saved successfully","success"),d(""),m(""),b("")},D=j=>{T(j)},w=()=>{_&&(l(_),o("Token deleted","info")),T(null)};return h.jsxs(h.Fragment,{children:[h.jsx(lc,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>T(null)}),h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),h.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),n.length===0?h.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):h.jsx("div",{className:fe.tokenList,children:n.map(j=>h.jsxs("div",{className:fe.tokenRow,children:[h.jsx("span",{className:fe.tokenBadge,children:j.tokenType}),h.jsx("span",{className:fe.tokenName,children:j.name}),h.jsx("span",{className:fe.tokenTarget,children:j.tokenType==="env_var"?j.envVar:j.filePath}),h.jsx("button",{className:fe.deleteButton,onClick:()=>D(j.name),title:`Delete ${j.name}`,children:"×"})]},j.name))}),h.jsxs("form",{className:fe.addForm,onSubmit:N,children:[h.jsxs("div",{className:fe.formRow,children:[h.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:j=>d(j.target.value)}),h.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:f,onChange:j=>m(j.target.value)})]}),h.jsxs("div",{className:fe.formRow,children:[h.jsx("select",{className:fe.select,value:p,onChange:j=>v(j.target.value),children:h3.map(j=>h.jsx("option",{value:j.value,children:j.label},j.value))}),h.jsx("input",{className:fe.input,type:"text",placeholder:p==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:y,onChange:j=>b(j.target.value)}),h.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}function p3(){return h.jsxs(h.Fragment,{children:[h.jsx(f3,{}),h.jsx(m3,{})]})}const g3="_container_1xcp7_1",v3="_header_1xcp7_7",y3="_form_1xcp7_19",b3="_formActions_1xcp7_87",S3="_list_1xcp7_93",x3="_card_1xcp7_99",_3="_active_1xcp7_109",T3="_cardHeader_1xcp7_113",E3="_cardActions_1xcp7_123",j3="_description_1xcp7_128",C3="_meta_1xcp7_134",A3="_promptDetails_1xcp7_151",N3="_promptText_1xcp7_163",w3="_empty_1xcp7_180",D3="_btnPrimary_1xcp7_186",k3="_btnSecondary_1xcp7_220",R3="_btnSmall_1xcp7_247",M3="_btnDanger_1xcp7_273",Et={container:g3,header:v3,form:y3,formActions:b3,list:S3,card:x3,active:_3,cardHeader:T3,cardActions:E3,description:j3,meta:C3,promptDetails:A3,promptText:N3,empty:w3,btnPrimary:D3,btnSecondary:k3,btnSmall:R3,btnDanger:M3};function O3(){const{personas:n,createPersona:s,updatePersona:l,deletePersona:o}=Ft(),[c,d]=S.useState(null),[f,m]=S.useState(!1),[p,v]=S.useState(null),[y,b]=S.useState(""),[_,T]=S.useState(""),[N,D]=S.useState(""),[w,j]=S.useState(""),[V,M]=S.useState(""),[$,H]=S.useState(0),J=()=>{b(""),T(""),D(""),j(""),M(""),H(0)},te=()=>{J(),d(null),m(!0)},K=ne=>{b(ne.name),T(ne.description),D(ne.systemPrompt),j(ne.runtime),M(ne.model),H(ne.maxTurns),d(ne),m(!1)},W=ne=>{ne.preventDefault(),!(!y.trim()||!N.trim())&&(c?(l(c.id,y,_,N,w,V,$),d(null)):(s(y,_,N,w,V,$),m(!1)),J())},he=ne=>{o(ne),v(null),(c==null?void 0:c.id)===ne&&(d(null),J())},R=()=>{d(null),m(!1),J()},ge=()=>h.jsxs("form",{onSubmit:W,className:Et.form,children:[h.jsx("h3",{children:c?"Edit Persona":"Create Persona"}),h.jsxs("label",{children:["Name",h.jsx("input",{type:"text",value:y,onChange:ne=>b(ne.target.value),placeholder:"e.g. Frontend Engineer",required:!0})]}),h.jsxs("label",{children:["Description",h.jsx("input",{type:"text",value:_,onChange:ne=>T(ne.target.value),placeholder:"Brief description..."})]}),h.jsxs("label",{children:["Runtime",h.jsxs("select",{value:w,onChange:ne=>j(ne.target.value),children:[h.jsx("option",{value:"",children:"Default"}),h.jsx("option",{value:"claude-code",children:"claude-code"}),h.jsx("option",{value:"codex",children:"codex"}),h.jsx("option",{value:"copilot",children:"copilot"})]})]}),h.jsxs("label",{children:["Model",h.jsx("input",{type:"text",value:V,onChange:ne=>M(ne.target.value),placeholder:"e.g. sonnet"})]}),h.jsxs("label",{children:["Max Turns",h.jsx("input",{type:"number",value:$,onChange:ne=>H(parseInt(ne.target.value,10)||0),min:0})]}),h.jsxs("label",{children:["System Prompt",h.jsx("textarea",{value:N,onChange:ne=>D(ne.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0})]}),h.jsxs("div",{className:Et.formActions,children:[h.jsx("button",{type:"submit",className:Et.btnPrimary,children:c?"Save":"Create"}),h.jsx("button",{type:"button",onClick:R,className:Et.btnSecondary,children:"Cancel"})]})]});return h.jsxs("div",{className:Et.container,children:[h.jsxs("div",{className:Et.header,children:[h.jsx("h2",{children:"Personas"}),h.jsx("button",{onClick:te,className:Et.btnPrimary,children:"+ New Persona"})]}),(f||c)&&ge(),n.length===0&&!f?h.jsx("p",{className:Et.empty,children:"No personas yet. Create one to get started."}):h.jsx("div",{className:Et.list,children:n.map(ne=>h.jsxs("div",{className:`${Et.card} ${(c==null?void 0:c.id)===ne.id?Et.active:""}`,children:[h.jsxs("div",{className:Et.cardHeader,children:[h.jsx("strong",{children:ne.name}),h.jsxs("div",{className:Et.cardActions,children:[h.jsx("button",{onClick:()=>K(ne),className:Et.btnSmall,children:"Edit"}),p===ne.id?h.jsxs(h.Fragment,{children:[h.jsx("button",{onClick:()=>he(ne.id),className:Et.btnDanger,children:"Confirm"}),h.jsx("button",{onClick:()=>v(null),className:Et.btnSmall,children:"Cancel"})]}):h.jsx("button",{onClick:()=>v(ne.id),className:Et.btnSmall,children:"Delete"})]})]}),ne.description&&h.jsx("p",{className:Et.description,children:ne.description}),h.jsxs("div",{className:Et.meta,children:[ne.runtime&&h.jsxs("span",{children:["Runtime: ",ne.runtime]}),ne.model&&h.jsxs("span",{children:["Model: ",ne.model]}),ne.maxTurns>0&&h.jsxs("span",{children:["Max turns: ",ne.maxTurns]})]}),h.jsxs("details",{className:Et.promptDetails,children:[h.jsx("summary",{children:"System Prompt"}),h.jsx("pre",{className:Et.promptText,children:ne.systemPrompt})]})]},ne.id))})]})}function B3(){return h.jsx(O3,{})}function L3(){const{themeId:n,resolvedThemeId:s,setTheme:l,preferSystem:o,setPreferSystem:c}=Zy();return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),h.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),h.jsx("div",{className:fe.themeOptions,children:Xr.filter(d=>!d.hidden).map(d=>{const f=!!(d.variantLightId&&d.variantDarkId),m=f?n===d.id||n===d.variantLightId||n===d.variantDarkId:n===d.id,p=f&&s===d.variantLightId;return h.jsxs("button",{type:"button",className:`${fe.themeOption} ${m?fe.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>l(d.id),children:[h.jsxs("span",{className:fe.themeOptionHeader,children:[h.jsxs("span",{children:[h.jsx("span",{className:fe.themeOptionLabel,children:d.label}),h.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),f&&h.jsxs("span",{className:fe.variantToggle,children:[h.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${m&&p?fe.variantActive:""}`,onClick:v=>{v.stopPropagation(),c(!1),l(d.variantLightId)},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),v.stopPropagation(),c(!1),l(d.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&p,children:"☼"}),h.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${m&&!p?fe.variantActive:""}`,onClick:v=>{v.stopPropagation(),c(!1),l(d.variantDarkId)},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),v.stopPropagation(),c(!1),l(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!p,children:"☾"})]})]}),d.swatches&&h.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((v,y)=>h.jsx("span",{className:fe.themeSwatch,style:{background:v}},y))})]},d.id)})}),h.jsxs("label",{className:fe.systemToggle,children:[h.jsx("input",{type:"checkbox",checked:o,onChange:d=>c(d.target.checked)}),h.jsx("span",{children:"Match system light/dark preference"})]}),h.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),h.jsxs("p",{className:fe.themeActive,children:["Active theme: ",h.jsx("strong",{children:s})]})]})}function U3(){return h.jsx(L3,{})}function z3(){const{connected:n,environments:s,sessions:l}=Ft(),o=s.filter(f=>f.status==="connected").length,c=s.length,d=l.filter(f=>["running","idle"].includes(f.status)).length;return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"About"}),h.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),h.jsxs("div",{className:fe.aboutGrid,children:[h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Connection"}),h.jsxs("span",{className:fe.aboutValue,children:[h.jsx("span",{className:`${fe.aboutDot} ${n?fe.aboutDotConnected:fe.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Environments"}),h.jsxs("span",{className:fe.aboutValue,children:[o,"/",c," connected"]})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),h.jsx("span",{className:fe.aboutValue,children:d})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Version"}),h.jsx("span",{className:fe.aboutValue,children:"0.27.0"})]})]})]})}function V3(){return h.jsx(z3,{})}const H3="_root_cdda9_1",I3="_body_cdda9_7",G3="_main_cdda9_13",zd={root:H3,body:I3,main:G3},P3=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function q3(){const{lastSpawnedId:n,environments:s}=Ft(),{showToast:l}=to();jw(s,l);const o=oa(),c=an(),d=c.pathname.startsWith(wi);return S.useEffect(()=>{n&&!c.pathname.startsWith("/tasks/")&&o(h0(n),{replace:!0})},[n,o,c.pathname]),h.jsxs("div",{className:zd.root,children:[h.jsx(VT,{}),h.jsxs("div",{className:zd.body,children:[d?h.jsx(YR,{}):h.jsx(KN,{}),h.jsxs("div",{className:zd.main,children:[h.jsx(r0,{}),h.jsx(dw,{})]})]}),h.jsx(Ew,{})]})}function Y3(){return h.jsx(Q_,{children:h.jsxs(jt,{element:h.jsx(q3,{}),children:[h.jsx(jt,{index:!0,element:h.jsx(fk,{})}),h.jsx(jt,{path:"sessions/new",element:h.jsx(Sk,{})}),h.jsx(jt,{path:"sessions/:sessionId",element:h.jsx(Ek,{})}),h.jsx(jt,{path:"projects/:projectId",element:h.jsx($k,{})}),h.jsx(jt,{path:"tasks/new",element:h.jsx(gR,{})}),h.jsx(jt,{path:"tasks/:taskId",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/stream",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/findings",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/edit",element:h.jsx(vR,{})}),h.jsx(jt,{path:"environments/new",element:h.jsx(LR,{})}),h.jsxs(jt,{path:"settings",element:h.jsx(HR,{}),children:[h.jsx(jt,{index:!0,element:h.jsx(Mr,{to:"environments",replace:!0})}),h.jsx(jt,{path:"environments",element:h.jsx(NM,{})}),h.jsx(jt,{path:"credentials",element:h.jsx(p3,{})}),h.jsx(jt,{path:"tokens",element:h.jsx(Mr,{to:"../credentials",replace:!0})}),h.jsx(jt,{path:"personas",element:h.jsx(B3,{})}),h.jsx(jt,{path:"appearance",element:h.jsx(U3,{})}),h.jsx(jt,{path:"about",element:h.jsx(V3,{})})]}),h.jsx(jt,{path:"*",element:h.jsx(Mr,{to:"/",replace:!0})})]})})}function K3(){const n=P3?K1:U1;return h.jsx(J1,{children:h.jsx(X1,{children:h.jsx(n,{children:h.jsx(xT,{children:h.jsx(Y3,{})})})})})}_1.createRoot(document.getElementById("root")).render(h.jsx(S.StrictMode,{children:h.jsx(K3,{})}));
91
+ `),y=((l==null?void 0:l.tool)??"")||(d?"Tool error":"Tool output"),b=l?KA(l.tool,l.args):"",_=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:d?ht.toolResultIndicatorError:ht.toolResultIndicatorOk,"aria-label":d?"error":"success",children:d?"✗":"✓"}),h.jsx("span",{className:ht.toolResultLabel,children:y}),m&&h.jsx("span",{className:ht.toolResultToggle,"aria-hidden":"true",children:o?"▾":"▸"})]});return h.jsxs("div",{className:ht.toolResultEvent,children:[m?h.jsx("button",{className:ht.toolResultHeader,onClick:()=>{c(T=>!T)},"aria-expanded":o,children:_}):h.jsx("div",{className:ht.toolResultHeader,children:_}),b&&h.jsx("div",{className:ht.toolResultCommand,children:b}),h.jsxs("pre",{className:ht.toolResultPre,children:[p,!o&&m&&h.jsx("span",{className:ht.toolResultEllipsis,children:"…"})]})]})}function XA({content:n}){return h.jsxs("div",{className:ht.errorEvent,children:["Error: ",n]})}function $A({content:n}){return h.jsxs("div",{className:ht.statusEvent,children:["--- ",n," ---"]})}function QA({content:n}){return h.jsx("div",{className:ht.userInputEvent,children:h.jsx("span",{className:ht.userInputContent,children:n})})}function FA({content:n}){return h.jsx("div",{className:ht.defaultEvent,children:n})}function qb({event:n,toolUseCtx:s}){const l=new Date(n.timestamp).toLocaleTimeString();switch(n.eventType){case"system":return h.jsx(PA,{time:l,content:n.content});case"text":case"output":return h.jsx(qA,{content:n.content});case"tool_use":return h.jsx(YA,{content:n.content});case"tool_result":return h.jsx(ZA,{content:n.content,raw:n.raw,toolUseCtx:s});case"error":return h.jsx(XA,{content:n.content});case"status":return h.jsx($A,{content:n.content});case"user_input":return h.jsx(QA,{content:n.content});default:return h.jsx(FA,{content:n.content})}}const JA="_overlay_cmicx_1",WA="_dialog_cmicx_11",eN="_title_cmicx_30",tN="_description_cmicx_38",nN="_actions_cmicx_45",aN="_cancelButton_cmicx_52",sN="_confirmButton_cmicx_79",ws={overlay:JA,dialog:WA,title:eN,description:tN,actions:nN,cancelButton:aN,confirmButton:sN};function lc({isOpen:n,title:s,description:l,confirmLabel:o="Delete",onConfirm:c,onCancel:d}){const f=S.useId(),m=S.useId();return h.jsx(Ui,{children:n&&h.jsx(la.div,{className:ws.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:d,onKeyDown:p=>{p.key==="Escape"&&d()},role:"dialog","aria-modal":"true","aria-labelledby":f,"aria-describedby":l?m:void 0,children:h.jsxs(la.div,{className:ws.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:p=>p.stopPropagation(),children:[h.jsx("h3",{id:f,className:ws.title,children:s}),l&&h.jsx("p",{id:m,className:ws.description,children:l}),h.jsxs("div",{className:ws.actions,children:[h.jsx("button",{type:"button",className:ws.cancelButton,onClick:d,autoFocus:!0,children:"Cancel"}),h.jsx("button",{type:"button",className:ws.confirmButton,onClick:c,children:o})]})]})})})}const iN="_spinner_13c8l_1",lN="_spin_13c8l_1",oN="_sm_13c8l_14",rN="_md_13c8l_20",cN="_lg_13c8l_26",Ay={spinner:iN,spin:lN,sm:oN,md:rN,lg:cN};function Ny({size:n="md",className:s,label:l="Loading",liveRegion:o=!1}){return h.jsx("span",{className:`${Ay.spinner} ${Ay[n]} ${s??""}`,role:o?"status":void 0,"aria-label":l,"aria-hidden":o?void 0:!0})}const uN="_container_7z2xb_1",dN="_header_7z2xb_5",fN="_addButton_7z2xb_17",hN="_createForm_7z2xb_44",mN="_createInput_7z2xb_50",pN="_createButton_7z2xb_81",gN="_creatingHint_7z2xb_122",vN="_projectRow_7z2xb_131",yN="_selected_7z2xb_149",bN="_expandArrow_7z2xb_154",SN="_expanded_7z2xb_161",xN="_projectName_7z2xb_165",_N="_taskCount_7z2xb_169",TN="_newTaskButton_7z2xb_175",EN="_taskRow_7z2xb_202",jN="_taskStatusIcon_7z2xb_227",CN="_taskTitle_7z2xb_231",AN="_dependencyBadge_7z2xb_238",NN="_blockedBadge_7z2xb_250",wN="_leafSpacer_7z2xb_255",DN="_childCountBadge_7z2xb_260",kN="_addChildButton_7z2xb_273",RN="_emptyCta_7z2xb_317",MN="_ctaDescription_7z2xb_330",ON="_ctaButton_7z2xb_336",BN="_emptyTaskCta_7z2xb_371",LN="_createTaskLink_7z2xb_376",Ze={container:uN,header:dN,addButton:fN,createForm:hN,createInput:mN,createButton:pN,creatingHint:gN,projectRow:vN,selected:yN,expandArrow:bN,expanded:SN,projectName:xN,taskCount:_N,newTaskButton:TN,taskRow:EN,taskStatusIcon:jN,taskTitle:CN,dependencyBadge:AN,blockedBadge:NN,leafSpacer:wN,childCountBadge:DN,addChildButton:kN,emptyCta:RN,ctaDescription:MN,ctaButton:ON,emptyTaskCta:BN,createTaskLink:LN},wy={not_started:{color:"var(--text-tertiary)",icon:"○"},working:{color:"var(--accent-green)",icon:"●"},paused:{color:"var(--accent-yellow)",icon:"◉"},complete:{color:"var(--accent-green)",icon:"✓"},failed:{color:"var(--accent-red)",icon:"✗"}};function UN(n){const s=new Map(n.map(o=>[o.id,{...o,children:[]}])),l=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):l.push(o);for(const o of s.values())o.children.sort((c,d)=>c.sortOrder-d.sortOrder);return l.sort((o,c)=>o.sortOrder-c.sortOrder)}const zN=34,VN=16;function Yb({node:n,depth:s,expandedTasks:l,toggleTask:o,selectedTaskId:c,navigate:d,projectId:f,taskStatusById:m}){const p=wy[n.status]||wy.not_started,v=n.dependsOn.length>0&&n.dependsOn.some(N=>m.get(N)!=="complete"),y=l.has(n.id),b=n.children.length>0,_=c===n.id,T=zN+s*VN;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{onClick:()=>d(Di(n.id)),className:`${Ze.taskRow} ${_?Ze.selected:""}`,style:{paddingLeft:T},"data-task-id":n.id,children:[b&&h.jsx("span",{className:`${Ze.expandArrow} ${y?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":y?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),o(n.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),o(n.id))},children:"▸"}),!b&&h.jsx("span",{className:Ze.leafSpacer}),h.jsx("span",{className:Ze.taskStatusIcon,style:{color:p.color},children:p.icon}),h.jsx("span",{className:Ze.taskTitle,title:n.title,children:n.title}),b&&h.jsxs("span",{className:Ze.childCountBadge,children:[n.children.filter(N=>N.status==="complete").length,"/",n.children.length]}),n.dependsOn.length>0&&h.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${n.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<fA&&h.jsx("button",{onClick:N=>{N.stopPropagation(),d(ki(f,n.id))},title:"Add child task","aria-label":"Add child task",className:Ze.addChildButton,children:"+"})]}),h.jsx(Ui,{children:b&&y&&h.jsx(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:n.children.map(N=>h.jsx(Yb,{node:N,depth:s+1,expandedTasks:l,toggleTask:o,selectedTaskId:c,navigate:d,projectId:f,taskStatusById:m},N.id))})})]})}function HN(){const{projects:n,tasks:s,loadTasks:l,createProject:o,projectCreating:c}=Ft(),d=oa(),[f,m]=S.useState(new Set),[p,v]=S.useState(new Set),[y,b]=S.useState(new Set),[_,T]=S.useState(!1),[N,D]=S.useState(""),w=tn("/tasks/:taskId/*"),j=tn("/projects/:projectId"),V=(w==null?void 0:w.params.taskId)!=="new"?w==null?void 0:w.params.taskId:void 0,M=j==null?void 0:j.params.projectId,$=S.useRef(f);$.current=f;const H=S.useMemo(()=>new Map(s.map(W=>[W.id,W.status])),[s]),J=W=>{m(he=>{const R=new Set(he);return R.has(W)?R.delete(W):(R.add(W),l(W)),R})},te=W=>{v(he=>{const R=new Set(he);return R.has(W)?(R.delete(W),b(ge=>new Set(ge).add(W))):(R.add(W),b(ge=>{const ne=new Set(ge);return ne.delete(W),ne})),R})};S.useEffect(()=>{const W=new Set(s.filter(he=>he.parentTaskId).map(he=>he.parentTaskId));W.size>0&&v(he=>{const R=new Set(he);for(const ge of W)y.has(ge)||R.add(ge);return R})},[s,y]),S.useEffect(()=>{M&&!$.current.has(M)&&(m(W=>new Set(W).add(M)),l(M))},[M,l]);const K=()=>{!N.trim()||c||(o(N.trim()),D(""),T(!1))};return h.jsxs("div",{className:Ze.container,children:[h.jsxs("div",{className:Ze.header,children:[h.jsx("span",{children:"Projects"}),h.jsx("button",{className:Ze.addButton,onClick:()=>T(!_),"aria-label":"Create project",title:"Create project",children:"+"})]}),_&&h.jsxs("div",{className:Ze.createForm,children:[h.jsx("input",{type:"text",value:N,onChange:W=>D(W.target.value),onKeyDown:W=>W.key==="Enter"&&K(),placeholder:"Project name...",autoFocus:!0,disabled:c,className:Ze.createInput}),h.jsx("button",{onClick:K,className:Ze.createButton,disabled:c,children:c?h.jsx(Ny,{size:"sm",label:"Creating project"}):"OK"})]}),c&&h.jsxs("div",{className:Ze.creatingHint,children:[h.jsx(Ny,{size:"sm",label:"Creating project"}),"Creating project…"]}),n.length===0&&!_&&h.jsxs("div",{className:Ze.emptyCta,children:[h.jsx("button",{className:Ze.ctaButton,onClick:()=>T(!0),children:"Create Project"}),h.jsx("div",{className:Ze.ctaDescription,children:"Organize your work into projects"})]}),n.map(W=>{const he=f.has(W.id),R=s.filter(je=>je.projectId===W.id),ge=M===W.id,ne=he?UN(R):[];return h.jsxs("div",{children:[h.jsxs("div",{onClick:()=>{ge?J(W.id):(he||J(W.id),d($l(W.id)))},className:`${Ze.projectRow} ${ge?Ze.selected:""}`,children:[h.jsx("span",{className:`${Ze.expandArrow} ${he?Ze.expanded:""}`,children:"▸"}),h.jsx("span",{className:Ze.projectName,title:W.name,children:W.name}),h.jsx("span",{className:Ze.taskCount,children:R.length>0&&`${R.filter(je=>je.status==="complete").length}/${R.length}`}),h.jsx("button",{onClick:je=>{je.stopPropagation(),d(ki(W.id))},title:"New task",className:Ze.newTaskButton,children:"+"})]}),h.jsx(Ui,{children:he&&h.jsxs(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},style:{overflow:"hidden"},children:[ne.map(je=>h.jsx(Yb,{node:je,depth:0,expandedTasks:p,toggleTask:te,selectedTaskId:V,navigate:d,projectId:W.id,taskStatusById:H},je.id)),R.length===0&&h.jsx("div",{className:Ze.emptyTaskCta,children:h.jsx("button",{className:Ze.createTaskLink,onClick:()=>d(ki(W.id)),children:"+ Create Task"})})]})})]},W.id)})]})}const IN="_container_1purk_1",GN="_content_1purk_30",Dy={container:IN,content:GN},PN=320,Kb=220,Zb=600,Xb="grackle-sidebar-width";function qN(){try{const n=localStorage.getItem(Xb);if(n!==null){const s=Number(n);if(Number.isFinite(s)&&s>=Kb&&s<=Zb)return s}}catch{}return PN}function YN(n){try{localStorage.setItem(Xb,String(n))}catch{}}function KN(){const[n]=S.useState(qN),s=S.useRef(null);return S.useEffect(()=>{const l=s.current;if(!l)return;const o=new ResizeObserver(c=>{for(const d of c){const f=d.borderBoxSize[0];if(f){const m=Math.round(f.inlineSize);m>=Kb&&m<=Zb&&YN(m)}}});return o.observe(l),()=>{o.disconnect()}},[]),h.jsx("div",{className:Dy.container,ref:s,"data-testid":"sidebar",style:{width:n},children:h.jsx("div",{className:Dy.content,children:h.jsx(HN,{})})})}const ZN="_bar_teqep_1",XN="_barColumn_teqep_26",$N="_barRow_teqep_52",QN="_input_teqep_58",FN="_inputSmall_teqep_87",JN="_select_teqep_150",WN="_btnPrimary_teqep_180",ew="_btnDanger_teqep_211",tw="_btnGhost_teqep_250",nw="_badge_teqep_278",aw="_statusText_teqep_288",sw="_statusCompleted_teqep_293",iw="_statusFailed_teqep_297",lw="_statusBlocked_teqep_301",ow="_hintText_teqep_306",rw="_creatingHint_teqep_311",cw="_errorHint_teqep_319",uw="_disconnectHint_teqep_325",de={bar:ZN,barColumn:XN,barRow:$N,input:QN,inputSmall:FN,select:JN,btnPrimary:WN,btnDanger:ew,btnGhost:tw,badge:nw,statusText:aw,statusCompleted:sw,statusFailed:iw,statusBlocked:lw,hintText:ow,creatingHint:rw,errorHint:cw,disconnectHint:uw};function ky({value:n,onChange:s,testId:l}){return h.jsxs("select",{"data-testid":l,value:n,onChange:o=>s(o.target.value),className:de.select,children:[h.jsx("option",{value:"claude-code",children:"claude-code"}),h.jsx("option",{value:"codex",children:"codex"}),h.jsx("option",{value:"copilot",children:"copilot"}),h.jsx("option",{value:"stub",children:"stub"})]})}function Ry(n,s){if(!n)return!1;const l=s.find(o=>o.id===n);return l!==void 0&&(l.status==="disconnected"||l.status==="error")}function My({environmentId:n,onReconnect:s}){return h.jsxs(h.Fragment,{children:[h.jsx("span",{className:de.disconnectHint,"data-testid":"env-disconnect-hint",children:"Environment unavailable"}),h.jsx("button",{type:"button",onClick:()=>s(n),className:de.btnGhost,"data-testid":"reconnect-btn",title:"Reconnect the environment to resume messaging",children:"Reconnect"})]})}function dw(){const{spawn:n,sendInput:s,kill:l,sessions:o,tasks:c,environments:d,personas:f,addEnvironment:m,provisionEnvironment:p,codespaces:v,codespaceError:y,codespaceListError:b,codespaceCreating:_,listCodespaces:T,createCodespace:N}=Ft(),{showToast:D}=to(),w=oa(),[j]=Sf(),V=tn("/sessions/:sessionId"),M=tn("/tasks/:taskId"),$=tn("/tasks/:taskId/stream"),H=tn("/tasks/:taskId/findings"),J=tn("/tasks/:taskId/edit"),te=tn("/sessions/new"),K=tn("/environments/new"),W=tn("/projects/:projectId"),he=tn("/tasks/new"),R=tn("/"),ge=tn("/settings/*"),ne=V==null?void 0:V.params.sessionId,je=(M==null?void 0:M.params.taskId)??($==null?void 0:$.params.taskId)??(H==null?void 0:H.params.taskId),G=!!te,U=!!K,X=!!W,ee=!!he,Ae=!!J,Ee=!!R&&!G&&!U&&!X&&!ee,Ge=!!ge,we=G?j.get("env")??"":"",_e=G?j.get("runtime")??"claude-code":"claude-code",[Ce,Q]=S.useState(""),[ce,Ie]=S.useState(G?_e:"claude-code"),[F,sn]=S.useState(""),Qn=pe=>{if(sn(pe),pe){const le=f.find(Te=>Te.id===pe);le!=null&&le.runtime&&Ie(le.runtime)}},[ln,jn]=S.useState(""),[dt,Jt]=S.useState("local"),[Hn,In]=S.useState("claude-code"),[mn,Gn]=S.useState(""),[Yt,Pn]=S.useState(""),[Z,se]=S.useState(""),[oe,ue]=S.useState(""),[Se,xe]=S.useState(""),[Xe,Re]=S.useState(""),[nt,xt]=S.useState(""),[pt,At]=S.useState(""),[at,gt]=S.useState(""),[Wt,ft]=S.useState("pick");S.useEffect(()=>{G&&Ie(_e)},[G,_e]);const Lt=ne?o.find(pe=>pe.id===ne):void 0,Ut=je?c.find(pe=>pe.id===je):void 0,cs=(Ut==null?void 0:Ut.latestSessionId)||void 0,qn=cs?o.find(pe=>pe.id===cs):void 0,ae=Ut?Ut.dependsOn.some(pe=>{const le=c.find(Te=>Te.id===pe);return le&&le.status!=="complete"}):!1;if(Ee||Ge)return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Select a session or click + to start"})});if(Ae||ee)return h.jsx(h.Fragment,{});if(U){const pe=P=>{if(!P.trim())return!0;const Fe=Number(P);return Number.isInteger(Fe)&&Fe>=1&&Fe<=65535},le=()=>!(!ln.trim()||dt==="ssh"&&!mn.trim()||dt==="codespace"&&!Xe.trim()||(dt==="local"||dt==="ssh")&&!pe(Yt)),Te=()=>{if(!le())return;const P={};if(dt==="local"){if(mn.trim()&&(P.host=mn.trim()),Yt.trim()){const Fe=Number(Yt);Number.isInteger(Fe)&&(P.port=Fe)}}else if(dt==="ssh"){if(P.host=mn.trim(),Z.trim()&&(P.user=Z.trim()),Yt.trim()){const Fe=Number(Yt);Number.isInteger(Fe)&&(P.sshPort=Fe)}nt.trim()&&(P.identityFile=nt.trim())}else dt==="docker"?(oe.trim()&&(P.image=oe.trim()),Se.trim()&&(P.repo=Se.trim())):dt==="codespace"&&(P.codespaceName=Xe.trim());m(ln.trim(),dt,P,Hn),D("Environment added successfully","success"),jn(""),Jt("local"),In("claude-code"),Gn(""),Pn(""),se(""),ue(""),xe(""),Re(""),xt(""),At(""),gt(""),ft("pick"),w(wi,{replace:!0})};return h.jsxs("div",{className:de.barColumn,children:[h.jsxs("div",{className:de.barRow,children:[h.jsx("span",{className:de.badge,children:"new env"}),h.jsx("input",{type:"text",value:ln,onChange:P=>jn(P.target.value),placeholder:"Environment name...",autoFocus:!0,className:de.input}),h.jsxs("select",{value:dt,onChange:P=>{Jt(P.target.value),P.target.value==="codespace"&&(T(),ft("pick"),Re(""))},className:de.select,children:[h.jsx("option",{value:"local",children:"local"}),h.jsx("option",{value:"ssh",children:"ssh"}),h.jsx("option",{value:"docker",children:"docker"}),h.jsx("option",{value:"codespace",children:"codespace"})]}),h.jsx(ky,{value:Hn,onChange:In,testId:"new-environment-runtime-select"}),h.jsx("button",{onClick:Te,disabled:!le(),className:de.btnPrimary,children:"Add"})]}),h.jsxs("div",{className:de.barRow,children:[dt==="local"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:mn,onChange:P=>Gn(P.target.value),placeholder:"Host (optional)...",className:de.inputSmall}),h.jsx("input",{type:"number",min:1,max:65535,value:Yt,onChange:P=>Pn(P.target.value),placeholder:"Port (optional)...",className:de.inputSmall})]}),dt==="ssh"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:mn,onChange:P=>Gn(P.target.value),placeholder:"Host (required)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:Z,onChange:P=>se(P.target.value),placeholder:"User (optional)...",className:de.inputSmall}),h.jsx("input",{type:"number",min:1,max:65535,value:Yt,onChange:P=>Pn(P.target.value),placeholder:"SSH port (optional)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:nt,onChange:P=>xt(P.target.value),placeholder:"Identity file (optional)...",className:de.inputSmall})]}),dt==="docker"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:oe,onChange:P=>ue(P.target.value),placeholder:"Image (optional)...",className:de.inputSmall}),h.jsx("input",{type:"text",value:Se,onChange:P=>xe(P.target.value),placeholder:"Repo (optional)...",className:de.inputSmall})]}),dt==="codespace"&&Wt==="pick"&&h.jsxs(h.Fragment,{children:[!b&&h.jsxs("select",{value:Xe,onChange:P=>{P.target.value==="__create__"?(ft("create"),Re("")):(Re(P.target.value),P.target.value&&!ln.trim()&&jn(P.target.value))},disabled:_,className:de.select,children:[h.jsx("option",{value:"",children:"Select a codespace..."}),v.map(P=>h.jsxs("option",{value:P.name,children:[P.name," (",P.repository,") — ",P.state]},P.name)),h.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),_&&h.jsx("span",{className:de.creatingHint,children:"Creating codespace..."}),b&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:de.errorHint,children:b}),h.jsx("input",{type:"text",value:Xe,onChange:P=>Re(P.target.value),placeholder:"Or enter codespace name manually...",className:de.inputSmall})]}),y&&!b&&h.jsx("span",{className:de.errorHint,children:y})]}),dt==="codespace"&&Wt==="create"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"text",value:pt,onChange:P=>At(P.target.value),placeholder:"owner/repo",className:de.inputSmall}),h.jsx("input",{type:"text",value:at,onChange:P=>gt(P.target.value),placeholder:"Machine type (optional)...",className:de.inputSmall}),h.jsx("button",{onClick:()=>{pt.trim()&&(N(pt.trim(),at.trim()||void 0),ft("pick"),At(""),gt(""))},disabled:!pt.trim(),className:de.btnPrimary,children:"Create"}),h.jsx("button",{onClick:()=>{ft("pick"),At(""),gt("")},className:de.btnGhost,children:"Cancel"})]})]})]})}if(X)return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Select a task or click + to create one"})});if(je&&Ut){if(Ut.status==="not_started"){const pe=ae?Ut.dependsOn.map(le=>c.find(Te=>Te.id===le)).filter(le=>le&&le.status!=="complete").map(le=>le.title):[];return h.jsx("div",{className:de.bar,children:ae?h.jsxs("span",{className:de.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):h.jsx("span",{className:de.hintText,children:"Use the buttons above to start or manage this task"})})}if(Ut.status==="working"||Ut.status==="paused"){if((qn==null?void 0:qn.status)==="idle"){const le=qn.environmentId,Te=Ry(le,d),P=Fe=>{Fe.preventDefault();const on=Ut.latestSessionId||cs;!Ce.trim()||!on||Te||(s(on,Ce),Q(""))};return h.jsxs("form",{onSubmit:P,className:de.bar,children:[Te&&le&&h.jsx(My,{environmentId:le,onReconnect:p}),h.jsx("input",{type:"text",value:Ce,onChange:Fe=>Q(Fe.target.value),placeholder:"Type a message...",autoFocus:!Te,disabled:Te,className:de.input}),h.jsx("span",{title:Te?"Environment is unavailable — reconnect first":void 0,children:h.jsx("button",{type:"submit",disabled:!Ce.trim()||Te,className:de.btnPrimary,children:"Send"})})]})}return h.jsx("div",{className:de.bar,children:h.jsx("input",{type:"text",disabled:!0,placeholder:"Agent is working...",className:de.input})})}if(Ut.status==="complete")return h.jsxs("div",{className:de.bar,children:[h.jsx("span",{className:`${de.statusText} ${de.statusCompleted}`,children:"Task completed"}),h.jsx("button",{onClick:()=>w(ki(Ut.projectId)),className:de.btnPrimary,children:"+ New Task"})]});if(Ut.status==="failed")return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:`${de.statusText} ${de.statusFailed}`,children:"Task failed"})})}if(G){const pe=le=>{le.preventDefault(),!(!Ce.trim()||!we)&&(n(we,Ce,void 0,ce,F),D("Session started","success"),Q(""),sn(""))};return h.jsxs("form",{onSubmit:pe,className:de.bar,children:[h.jsx("span",{className:de.badge,children:"new chat"}),h.jsx("input",{type:"text",value:Ce,onChange:le=>Q(le.target.value),placeholder:"Enter prompt...",autoFocus:!0,className:de.input}),h.jsx(ky,{value:ce,onChange:Ie,testId:"new-chat-runtime-select"}),h.jsxs("select",{value:F,onChange:le=>Qn(le.target.value),className:de.select,children:[h.jsx("option",{value:"",children:"No persona"}),f.map(le=>h.jsx("option",{value:le.id,children:le.name},le.id))]}),h.jsx("button",{type:"submit",disabled:!Ce.trim()||!we,className:de.btnPrimary,children:"Go"})]})}if(ne){const pe=(Lt==null?void 0:Lt.status)==="running",le=(Lt==null?void 0:Lt.status)==="idle",Te=Lt!==void 0&&["completed","failed","interrupted"].includes(Lt.status);if(pe)return h.jsxs("div",{className:de.bar,children:[h.jsx("input",{type:"text",disabled:!0,placeholder:"Agent is working...",className:de.input}),h.jsx("button",{onClick:()=>l(ne),className:de.btnDanger,title:"Stop session",children:"Stop"})]});if(le){const P=Ry(Lt.environmentId,d),Fe=on=>{on.preventDefault(),!(!Ce.trim()||P)&&(s(ne,Ce),Q(""))};return h.jsxs("form",{onSubmit:Fe,className:de.bar,children:[P&&Lt.environmentId&&h.jsx(My,{environmentId:Lt.environmentId,onReconnect:p}),h.jsx("input",{type:"text",value:Ce,onChange:on=>Q(on.target.value),placeholder:"Type a message...",autoFocus:!P,disabled:P,className:de.input}),h.jsx("span",{title:P?"Environment is unavailable — reconnect first":void 0,children:h.jsx("button",{type:"submit",disabled:!Ce.trim()||P,className:de.btnPrimary,children:"Send"})}),h.jsx("button",{type:"button",onClick:()=>l(ne),className:de.btnDanger,title:"Stop session",children:"Stop"})]})}if(Te)return h.jsxs("div",{className:de.bar,children:[h.jsxs("span",{className:`${de.statusText} ${de.hintText}`,children:["Session ",Lt.status]}),h.jsx("button",{onClick:()=>w(m0(Lt.environmentId,Lt.runtime)),className:de.btnPrimary,children:"+ New Chat"})]})}return h.jsx("div",{className:de.bar,children:h.jsx("span",{className:de.hintText,children:"Loading..."})})}const fw="_toast_da8ll_1",hw="_success_da8ll_18",mw="_icon_da8ll_22",pw="_error_da8ll_25",gw="_warning_da8ll_32",vw="_info_da8ll_38",yw="_message_da8ll_53",bw="_close_da8ll_60",Ll={toast:fw,success:hw,icon:mw,error:pw,warning:gw,info:vw,message:yw,close:bw},Sw={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function xw({toast:n,onDismiss:s}){return S.useEffect(()=>{const l=setTimeout(()=>s(n.id),n.duration);return()=>clearTimeout(l)},[n.id,n.duration,s]),h.jsxs(la.div,{className:`${Ll.toast} ${Ll[n.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[h.jsx("span",{className:Ll.icon,"aria-hidden":"true",children:Sw[n.variant]}),h.jsx("span",{className:Ll.message,children:n.message}),h.jsx("button",{type:"button",className:Ll.close,onClick:()=>s(n.id),"aria-label":"Dismiss notification",children:"×"})]})}const _w="_container_qqse2_1",Tw={container:_w};function Ew(){const{toasts:n,dismissToast:s}=to();return h.jsx("div",{className:Tw.container,"data-testid":"toast-container",children:h.jsx(Ui,{children:n.map(l=>h.jsx(xw,{toast:l,onDismiss:s},l.id))})})}function jw(n,s){const l=S.useRef(null);S.useEffect(()=>{const o=l.current;if(l.current=n,o===null)return;const c=new Map;for(const f of o)c.set(f.id,f);const d=new Set;for(const f of n){d.add(f.id);const m=c.get(f.id);m&&m.status!==f.status&&(f.status==="connecting"||f.status==="sleeping"||(f.status==="connected"?s("Environment connected","success"):f.status==="error"?s("Environment provision failed","error"):f.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))))}for(const f of o)d.has(f.id)||s("Environment removed","info")},[n,s])}const Cw="_panelContainer_1blx0_1",Aw="_emptyState_1blx0_8",Nw="_projectSummary_1blx0_17",ww="_projectSummaryTitle_1blx0_28",Dw="_projectSummarySubtitle_1blx0_32",kw="_header_1blx0_36",Rw="_headerInfo_1blx0_63",Mw="_killButton_1blx0_69",Ow="_headerTitle_1blx0_98",Bw="_headerActions_1blx0_108",Lw="_taskStatusBadge_1blx0_115",Uw="_taskBranch_1blx0_124",zw="_taskBlockedBadge_1blx0_130",Vw="_btnPrimary_1blx0_138",Hw="_btnDanger_1blx0_169",Iw="_btnGhost_1blx0_208",Gw="_tabBar_1blx0_264",Pw="_tab_1blx0_264",qw="_active_1blx0_285",Yw="_eventScroll_1blx0_290",Kw="_tabContent_1blx0_296",Zw="_noContext_1blx0_301",Xw="_overviewContent_1blx0_307",$w="_overviewDashboard_1blx0_316",Qw="_overviewHero_1blx0_322",Fw="_statusBadge_1blx0_329",Jw="_statusPending_1blx0_341",Ww="_statusInProgress_1blx0_351",eD="_statusDone_1blx0_361",tD="_statusFailed_1blx0_366",nD="_statusWaitingInput_1blx0_371",aD="_overviewBranchPill_1blx0_376",sD="_branchLink_1blx0_391",iD="_overviewSection_1blx0_402",lD="_overviewLabel_1blx0_408",oD="_overviewValue_1blx0_415",rD="_overviewMuted_1blx0_420",cD="_overviewMarkdown_1blx0_426",uD="_envRow_1blx0_495",dD="_envDot_1blx0_501",fD="_envDotGreen_1blx0_508",hD="_envDotYellow_1blx0_512",mD="_envDotRed_1blx0_516",pD="_envDotGray_1blx0_520",gD="_depList_1blx0_524",vD="_depItem_1blx0_530",yD="_depBlocked_1blx0_537",bD="_depDone_1blx0_541",SD="_timeline_1blx0_545",xD="_timelineRow_1blx0_551",_D="_timelineKey_1blx0_558",TD="_timelineValue_1blx0_564",ED="_timelineDelta_1blx0_568",jD="_reviewNotes_1blx0_579",CD="_waitingMessage_1blx0_596",AD="_errorMessage_1blx0_600",ND="_eventOverflowWarning_1blx0_604",wD="_attemptSelector_1blx0_618",DD="_attemptLabel_1blx0_629",kD="_attemptButton_1blx0_633",RD="_attemptActive_1blx0_650",MD="_attemptStatus_1blx0_656",OD="_emptyCta_1blx0_662",BD="_ctaTitle_1blx0_674",LD="_ctaDescription_1blx0_680",UD="_ctaButton_1blx0_687",zD="_projectHeader_1blx0_736",VD="_projectName_1blx0_761",HD="_projectMeta_1blx0_774",ID="_metaRow_1blx0_782",GD="_metaLabel_1blx0_789",PD="_metaValue_1blx0_799",qD="_metaPlaceholder_1blx0_809",YD="_editButton_1blx0_814",KD="_editInput_1blx0_830",ZD="_editTextarea_1blx0_862",XD="_editSelect_1blx0_898",$D="_archiveButton_1blx0_931",QD="_repoLink_1blx0_961",FD="_metaValueClickable_1blx0_971",JD="_editHint_1blx0_990",WD="_editError_1blx0_999",ek="_editInputInvalid_1blx0_1006",tk="_unsavedDot_1blx0_1011",nk="_metaToggle_1blx0_1019",ak="_metaToggleArrow_1blx0_1040",sk="_metaToggleArrowOpen_1blx0_1045",ik="_progressBarContainer_1blx0_1049",lk="_progressBar_1blx0_1049",ok="_progressFill_1blx0_1065",rk="_progressLabel_1blx0_1072",ck="_metaTimestamps_1blx0_1079",uk="_metaTimestamp_1blx0_1079",dk="_editFieldWrapper_1blx0_1095",A={panelContainer:Cw,emptyState:Aw,projectSummary:Nw,projectSummaryTitle:ww,projectSummarySubtitle:Dw,header:kw,headerInfo:Rw,killButton:Mw,headerTitle:Ow,headerActions:Bw,taskStatusBadge:Lw,taskBranch:Uw,taskBlockedBadge:zw,btnPrimary:Vw,btnDanger:Hw,btnGhost:Iw,tabBar:Gw,tab:Pw,active:qw,eventScroll:Yw,tabContent:Kw,noContext:Zw,overviewContent:Xw,overviewDashboard:$w,overviewHero:Qw,statusBadge:Fw,statusPending:Jw,statusInProgress:Ww,statusDone:eD,statusFailed:tD,statusWaitingInput:nD,overviewBranchPill:aD,branchLink:sD,overviewSection:iD,overviewLabel:lD,overviewValue:oD,overviewMuted:rD,overviewMarkdown:cD,envRow:uD,envDot:dD,envDotGreen:fD,envDotYellow:hD,envDotRed:mD,envDotGray:pD,depList:gD,depItem:vD,depBlocked:yD,depDone:bD,timeline:SD,timelineRow:xD,timelineKey:_D,timelineValue:TD,timelineDelta:ED,reviewNotes:jD,waitingMessage:CD,errorMessage:AD,eventOverflowWarning:ND,attemptSelector:wD,attemptLabel:DD,attemptButton:kD,attemptActive:RD,attemptStatus:MD,emptyCta:OD,ctaTitle:BD,ctaDescription:LD,ctaButton:UD,projectHeader:zD,projectName:VD,projectMeta:HD,metaRow:ID,metaLabel:GD,metaValue:PD,metaPlaceholder:qD,editButton:YD,editInput:KD,editTextarea:ZD,editSelect:XD,archiveButton:$D,repoLink:QD,metaValueClickable:FD,editHint:JD,editError:WD,editInputInvalid:ek,unsavedDot:tk,metaToggle:nk,metaToggleArrow:ak,metaToggleArrowOpen:sk,progressBarContainer:ik,progressBar:lk,progressFill:ok,progressLabel:rk,metaTimestamps:ck,metaTimestamp:uk,editFieldWrapper:dk};function fk(){const{projects:n,createProject:s}=Ft();return n.length===0?h.jsxs("div",{className:A.emptyCta,children:[h.jsx("div",{className:A.ctaTitle,children:"Welcome to Grackle"}),h.jsx("div",{className:A.ctaDescription,children:"Organize your work into projects and let agents tackle the tasks."}),h.jsx("button",{className:A.ctaButton,onClick:()=>{const l=window.prompt("Project name:");l!=null&&l.trim()&&s(l.trim())},children:"Create Your First Project"})]}):h.jsx("div",{className:A.emptyState,children:"Select a project or task to get started"})}function hk(n,s){const l=[];let o=n;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const d=s.get(o);l.unshift(d),o=d.parentTaskId||void 0}return l}const Os={label:"Home",url:"/"};function mk(n){return n?[Os,{label:"Settings",url:"/settings"},{label:n,url:void 0}]:[Os,{label:"Settings",url:void 0}]}function pk(){return[Os,{label:"New Environment",url:void 0}]}function gk(){return[Os,{label:"New Chat",url:void 0}]}function vk(n){return[Os,{label:`Session ${n.slice(0,8)}`,url:void 0}]}function yk(n,s){const l=s.find(o=>o.id===n);return[Os,{label:(l==null?void 0:l.name)??"Project",url:void 0}]}function bk(n,s,l){const o=hk(n,l),c=l.get(n),d=c==null?void 0:c.projectId,f=d?s.find(v=>v.id===d):void 0,m=[Os];f&&m.push({label:f.name,url:$l(f.id)});for(let v=0;v<o.length-1;v++)m.push({label:o[v].title,url:Di(o[v].id)});const p=o[o.length-1];return m.push({label:(p==null?void 0:p.title)??n,url:void 0}),m}function Sk(){const n=gk();return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:n}),h.jsx("div",{className:A.emptyState,children:"Enter a prompt below to start a new session"})]})}function $b(n){const s=[];for(const l of n){const o=s[s.length-1];l.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+l.content}:s.push(l)}return s}function Qb(n){const s=new Map;for(const d of n)if(d.raw)try{s.set(d,JSON.parse(d.raw))}catch{}const l=new Map;for(const d of n){if(d.eventType!=="tool_use")continue;const f=s.get(d);if(!(!f||typeof f.id!="string"))try{const m=JSON.parse(d.content);l.set(f.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return n.map(d=>{if(d.eventType!=="tool_result")return d;const f=s.get(d);if(!f||typeof f.tool_use_id!="string")return d;const m=l.get(f.tool_use_id);return m?(o.add(f.tool_use_id),{...d,toolUseCtx:m}):d}).filter(d=>{if(d.eventType!=="tool_use")return!0;const f=s.get(d);return f&&typeof f.id=="string"?!o.has(f.id):!0})}function xk({sessionId:n,session:s,isActive:l,onKill:o}){return h.jsxs("div",{className:A.header,children:[h.jsxs("span",{children:["Session: ",n.slice(0,8),s&&` | ${s.runtime} | ${s.status}`]}),h.jsxs("span",{className:A.headerInfo,children:[s&&h.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),l&&h.jsx("button",{onClick:()=>o(n),title:"Stop session",className:A.killButton,children:"×"})]})]})}function _k({eventsDropped:n}){return n<=0?h.jsx(h.Fragment,{}):h.jsxs("div",{className:A.eventOverflowWarning,role:"alert",children:["⚠ ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Tk({sessionEvents:n,session:s,eventsDropped:l,scrollRef:o}){const c=s&&["completed","failed","interrupted"].includes(s.status),d=c?`Session ${s.status} with no events recorded.`:"Waiting for events...";return h.jsxs("div",{ref:o,className:A.eventScroll,children:[n.length===0&&h.jsx("div",{className:c?A.errorMessage:A.waitingMessage,children:d}),h.jsx(_k,{eventsDropped:l}),n.map((f,m)=>h.jsx(qb,{event:f,toolUseCtx:f.toolUseCtx},`${f.sessionId}-${f.timestamp}-${m}`))]})}function Ek(){const{sessionId:n}=Jr(),{events:s,eventsDropped:l,sessions:o,kill:c,loadSessionEvents:d}=Ft(),f=S.useRef(null),m=S.useRef(void 0),p=vk(n),v=o.find(_=>_.id===n)??void 0,y=S.useMemo(()=>{const _=n?s.filter(T=>T.sessionId===n):[];return Qb($b(_))},[s,n]);if(S.useEffect(()=>{n&&n!==m.current&&(m.current=n,d(n))},[n,d]),S.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[y.length]),!n)return h.jsx("div",{className:A.emptyState,children:"No session selected"});const b=(v==null?void 0:v.status)==="running"||(v==null?void 0:v.status)==="idle";return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:p}),h.jsx(xk,{sessionId:n,session:v,isActive:b,onKill:c}),h.jsx(Tk,{sessionEvents:y,session:v,eventsDropped:l,scrollRef:f})]})}const Oy=220,By=70,jk=40,Ck=60,Ak="hierarchy",Nk="dependency";function wk(n){return S.useMemo(()=>{if(n.length===0)return{nodes:[],edges:[]};const s=new Pg.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"TB",nodesep:jk,ranksep:Ck});const l=new Map(n.map(f=>[f.id,f])),o=new Map;for(const f of n)if(f.parentTaskId&&l.has(f.parentTaskId)){const m=o.get(f.parentTaskId)||[];m.push(f),o.set(f.parentTaskId,m)}for(const f of n)s.setNode(f.id,{width:Oy,height:By});const c=[];for(const f of n){if(f.parentTaskId&&l.has(f.parentTaskId)){const m=`hierarchy-${f.parentTaskId}-${f.id}`;s.setEdge(f.parentTaskId,f.id,{},m),c.push({id:m,source:f.parentTaskId,target:f.id,type:"smoothstep",data:{edgeType:Ak},style:{stroke:"var(--accent-green)",strokeWidth:2},animated:!1})}for(const m of f.dependsOn)if(l.has(m)){const p=`dependency-${m}-${f.id}`;s.setEdge(m,f.id,{},p),c.push({id:p,source:m,target:f.id,type:"smoothstep",data:{edgeType:Nk},style:{stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeDasharray:"6 3"},animated:!1})}}return Pg.layout(s),{nodes:n.map(f=>{const m=s.node(f.id),p=o.get(f.id)||[];return{id:f.id,type:"task",position:{x:m.x-Oy/2,y:m.y-By/2},data:{task:f,childCount:p.length,doneChildCount:p.filter(v=>v.status==="complete").length,hasDependencies:f.dependsOn.length>0}}}),edges:c}},[n])}const Dk="_dagContainer_3al6d_1",kk="_taskNode_3al6d_26",Rk="_taskNodeBorder_3al6d_48",Mk="_taskNodeContent_3al6d_54",Ok="_taskNodeHeader_3al6d_64",Bk="_taskNodeIcon_3al6d_71",Lk="_taskNodeTitle_3al6d_76",Uk="_taskNodeBadges_3al6d_84",zk="_childBadge_3al6d_89",Vk="_depBadge_3al6d_101",Hk="_handle_3al6d_113",Ik="_emptyCta_3al6d_120",Gk="_ctaDescription_3al6d_131",Pk="_ctaButton_3al6d_138",nn={dagContainer:Dk,taskNode:kk,taskNodeBorder:Rk,taskNodeContent:Mk,taskNodeHeader:Ok,taskNodeIcon:Bk,taskNodeTitle:Lk,taskNodeBadges:Uk,childBadge:zk,depBadge:Vk,handle:Hk,emptyCta:Ik,ctaDescription:Gk,ctaButton:Pk},Ly={not_started:{color:"var(--text-tertiary)",icon:"○"},working:{color:"var(--accent-green)",icon:"●"},paused:{color:"var(--accent-yellow)",icon:"◉"},complete:{color:"var(--accent-green)",icon:"✓"},failed:{color:"var(--accent-red)",icon:"✗"}};function qk({data:n}){const{task:s,childCount:l,doneChildCount:o,hasDependencies:c}=n,d=Ly[s.status]||Ly.not_started;return h.jsxs("div",{className:nn.taskNode,"data-task-id":s.id,"data-task-title":s.title,children:[h.jsx(qg,{type:"target",position:Yg.Top,className:nn.handle}),h.jsx("div",{className:nn.taskNodeBorder,style:{backgroundColor:d.color}}),h.jsxs("div",{className:nn.taskNodeContent,children:[h.jsxs("div",{className:nn.taskNodeHeader,children:[h.jsx("span",{className:nn.taskNodeIcon,style:{color:d.color},children:d.icon}),h.jsx("span",{className:nn.taskNodeTitle,children:s.title})]}),h.jsxs("div",{className:nn.taskNodeBadges,children:[l>0&&h.jsxs("span",{className:nn.childBadge,children:[o,"/",l]}),c&&h.jsx("span",{className:nn.depBadge,children:"dep"})]})]}),h.jsx(qg,{type:"source",position:Yg.Bottom,className:nn.handle})]})}const Yk={pending:"--text-tertiary",assigned:"--accent-blue",in_progress:"--accent-green",review:"--accent-yellow",done:"--accent-green",failed:"--accent-red",waiting_input:"--accent-yellow"},Kk={task:qk};function Zk({projectId:n}){const{tasks:s}=Ft(),l=oa(),{resolvedThemeId:o}=Zy(),c=S.useMemo(()=>s.filter(y=>y.projectId===n),[s,n]),{nodes:d,edges:f}=wk(c),m=S.useMemo(()=>{const y=getComputedStyle(document.documentElement),b={};for(const[_,T]of Object.entries(Yk))b[_]=y.getPropertyValue(T).trim()||"#6b7a8d";return b},[o]),p=S.useCallback((y,b)=>{l(Di(b.id))},[l]),v=S.useCallback(y=>{const b=y.data;return m[b.task.status]||m.pending},[m]);return c.length===0?h.jsxs("div",{className:nn.emptyCta,children:[h.jsx("button",{className:nn.ctaButton,onClick:()=>l(ki(n)),children:"Create Task"}),h.jsx("div",{className:nn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):h.jsx("div",{className:nn.dagContainer,children:h.jsxs(h1,{nodes:d,edges:f,nodeTypes:Kk,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[h.jsx(m1,{variant:p1.Dots,gap:24,size:1,color:"var(--text-disabled)"}),h.jsx(g1,{showInteractive:!1}),h.jsx(v1,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function Xk(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?A.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?A.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?A.envDotRed:A.envDotGray}function Uy(n){if(!n)return"";const s=new Date(n);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const d=Math.floor(c/60);if(d<24)return`${d}h ago`;const f=Math.floor(d/24);return f<30?`${f}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function $k(){const{projectId:n}=Jr(),s=oa(),{tasks:l,environments:o,projects:c,archiveProject:d,updateProject:f}=Ft(),[m,p]=S.useState("tasks"),[v,y]=S.useState(!1),[b,_]=S.useState(null),[T,N]=S.useState(""),[D,w]=S.useState(""),[j,V]=S.useState(!1),M=S.useRef(void 0),$=S.useRef(null),H=S.useRef(null),J=S.useRef(null),te=S.useRef(null),K=S.useRef(null),W=S.useRef(null),he=yk(n,c);S.useEffect(()=>{const Q=M.current;M.current=n,!(Q===void 0||Q===n)&&(b!==null||T!=="")&&(_(null),N(""))},[n,b,T]),S.useEffect(()=>{if(b===null)return;const Q=b==="name"?H.current:b==="description"?J.current:b==="repoUrl"?te.current:b==="worktreeBasePath"?W.current:K.current;if(!Q)return;const ce=window.setTimeout(()=>{Q.focus()},0);return()=>{window.clearTimeout(ce)}},[b]);const R=c.find(Q=>Q.id===n),ge=l.filter(Q=>Q.projectId===n),ne=ge.filter(Q=>Q.status==="complete").length,je=ge.length,G=je>0?Math.round(ne/je*100):0,U=100,X=(Q,ce)=>{$.current=Q,_(Q),N(ce),w("")},ee=()=>{$.current=null,_(null),N(""),w("")},Ae=(Q,ce)=>{if(Q==="name"){const Ie=ce.trim();if(!Ie)return"Name is required";if(Ie.length>U)return`Max ${U} characters`}if(Q==="repoUrl"){const Ie=ce.trim();if(Ie&&!/^https?:\/\/.+/.test(Ie))return"Must be a valid http(s) URL"}return""},Ee=Q=>{if(!R)return;const ce=T.trim(),Ie=Ae(Q,T);if(Ie){w(Ie);return}if(Q==="name"){if(ce===R.name){ee();return}f(R.id,{name:ce})}else if(Q==="description"){const F=T;if(F===R.description){ee();return}f(R.id,{description:F})}else if(Q==="repoUrl"){if(ce===R.repoUrl){ee();return}f(R.id,{repoUrl:ce})}else if(Q==="defaultEnvironmentId"){if(T===R.defaultEnvironmentId){ee();return}f(R.id,{defaultEnvironmentId:T})}else{if(ce===R.worktreeBasePath){ee();return}f(R.id,{worktreeBasePath:ce})}ee()},Ge=(Q,ce)=>{Q.key==="Escape"?ee():Q.key==="Enter"&&ce!=="description"&&Ee(ce)},we=Q=>R?Q==="name"?T.trim()!==R.name:Q==="description"?T!==R.description:Q==="repoUrl"?T.trim()!==R.repoUrl:Q==="defaultEnvironmentId"?T!==R.defaultEnvironmentId:T.trim()!==R.worktreeBasePath:!1,_e=o.find(Q=>Q.id===(R==null?void 0:R.defaultEnvironmentId)),Ce=b==="description"?"Tab to save · Esc to cancel":"Enter to save · Esc to cancel";return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:he}),h.jsxs("div",{className:A.projectHeader,children:[h.jsx("span",{className:A.projectName,"data-testid":"project-name",children:b==="name"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:H,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="name"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="name"||Ee("name")},onKeyDown:Q=>Ge(Q,"name"),maxLength:U,"aria-label":"Project name","data-testid":"edit-name-input"}),we("name")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("name",(R==null?void 0:R.name)||""),title:"Click to edit name","aria-label":`Edit project name: ${(R==null?void 0:R.name)||n}`,"data-testid":"edit-name-button",children:[(R==null?void 0:R.name)||n,h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})}),h.jsx("button",{className:A.archiveButton,onClick:()=>y(!0),title:"Archive project","data-testid":"archive-project-button",children:"Archive"})]}),h.jsxs("button",{className:A.metaToggle,onClick:()=>V(!j),"aria-expanded":!j,"aria-controls":"project-meta-panel","data-testid":"meta-toggle",children:[h.jsx("span",{className:`${A.metaToggleArrow} ${j?"":A.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!j&&h.jsxs("div",{className:A.projectMeta,"data-testid":"project-meta",id:"project-meta-panel",children:[h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Description"}),h.jsx("div",{className:A.metaValue,children:b==="description"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("textarea",{ref:J,className:A.editTextarea,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="description"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="description"||Ee("description")},onKeyDown:Q=>Ge(Q,"description"),title:"Project description","aria-label":"Project description","data-testid":"edit-description-input"}),we("description")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("description",(R==null?void 0:R.description)||""),title:"Click to edit description","aria-label":"Edit project description","data-testid":"edit-description-button",children:[R!=null&&R.description?h.jsx("span",{className:A.overviewMarkdown,children:h.jsx(uf,{remarkPlugins:[df],children:R.description})}):h.jsx("span",{className:A.metaPlaceholder,children:"No description"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Repository"}),h.jsx("div",{className:A.metaValue,children:b==="repoUrl"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:te,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="repoUrl"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="repoUrl"||Ee("repoUrl")},onKeyDown:Q=>Ge(Q,"repoUrl"),placeholder:"https://github.com/...","aria-label":"Project repository URL","data-testid":"edit-repo-input"}),we("repoUrl")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:Q=>{Q.preventDefault(),X("repoUrl",(R==null?void 0:R.repoUrl)||"")},title:"Click to edit repository URL","aria-label":"Edit project repository URL","data-testid":"edit-repo-button",children:[R!=null&&R.repoUrl&&/^https?:\/\//i.test(R.repoUrl)?h.jsx("a",{className:A.repoLink,href:R.repoUrl,target:"_blank",rel:"noopener noreferrer",onClick:Q=>Q.stopPropagation(),children:R.repoUrl}):R!=null&&R.repoUrl?h.jsx("span",{children:R.repoUrl}):h.jsx("span",{className:A.metaPlaceholder,children:"No repository"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Environment"}),h.jsx("div",{className:A.metaValue,children:b==="defaultEnvironmentId"?h.jsxs("select",{ref:K,className:A.editSelect,value:T,onChange:Q=>{$.current=null,N(Q.target.value);const ce=Q.target.value;R&&ce!==R.defaultEnvironmentId&&f(R.id,{defaultEnvironmentId:ce}),ee()},onBlur:Q=>{if($.current==="defaultEnvironmentId"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="defaultEnvironmentId"||ee()},title:"Default environment","aria-label":"Project default environment","data-testid":"edit-env-select",children:[h.jsx("option",{value:"",children:"None"}),o.map(Q=>h.jsx("option",{value:Q.id,children:Q.displayName},Q.id))]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("defaultEnvironmentId",(R==null?void 0:R.defaultEnvironmentId)||""),title:"Click to change default environment","aria-label":"Edit project default environment","data-testid":"edit-env-button",children:[_e?h.jsxs("span",{className:A.envRow,children:[h.jsx("span",{className:`${A.envDot} ${Xk(_e.status)}`}),_e.displayName]}):h.jsx("span",{className:A.metaPlaceholder,children:(R==null?void 0:R.defaultEnvironmentId)||"No default environment"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),h.jsxs("div",{className:A.metaRow,children:[h.jsx("span",{className:A.metaLabel,children:"Worktree Base"}),h.jsx("div",{className:A.metaValue,children:b==="worktreeBasePath"?h.jsxs("div",{className:A.editFieldWrapper,children:[h.jsx("input",{ref:W,className:`${A.editInput} ${D?A.editInputInvalid:""}`,value:T,onChange:Q=>{N(Q.target.value),w("")},onBlur:Q=>{if($.current==="worktreeBasePath"){$.current=null;return}Q.relatedTarget instanceof HTMLElement&&Q.relatedTarget.dataset.editAction==="worktreeBasePath"||Ee("worktreeBasePath")},onKeyDown:Q=>Ge(Q,"worktreeBasePath"),placeholder:"/workspaces/my-repo","aria-label":"Worktree base path","data-testid":"edit-worktree-base-path-input"}),we("worktreeBasePath")&&h.jsx("span",{className:A.unsavedDot,title:"Unsaved changes"}),D&&h.jsx("span",{className:A.editError,"data-testid":"edit-error",children:D}),h.jsx("span",{className:A.editHint,children:Ce})]}):h.jsxs("button",{type:"button",className:A.metaValueClickable,onClick:()=>X("worktreeBasePath",(R==null?void 0:R.worktreeBasePath)||""),title:"Click to edit worktree base path","aria-label":"Edit worktree base path","data-testid":"edit-worktree-base-path-button",children:[R!=null&&R.worktreeBasePath?h.jsx("span",{children:R.worktreeBasePath}):h.jsx("span",{className:A.metaPlaceholder,children:"Default (server default)"}),h.jsx("span",{className:A.editButton,"aria-hidden":"true",children:"✏️"})]})})]}),R&&h.jsxs("div",{className:A.metaTimestamps,children:[h.jsxs("span",{className:A.metaTimestamp,children:["Created ",Uy(R.createdAt)]}),R.updatedAt&&R.updatedAt!==R.createdAt&&h.jsxs("span",{className:A.metaTimestamp,children:["· Updated ",Uy(R.updatedAt)]})]})]}),je>0&&h.jsxs("div",{className:A.progressBarContainer,"data-testid":"progress-bar",children:[h.jsx("div",{className:A.progressBar,children:h.jsx("div",{className:A.progressFill,style:{width:`${G}%`}})}),h.jsxs("span",{className:A.progressLabel,children:[ne,"/",je]})]}),h.jsxs("div",{className:A.tabBar,role:"tablist","aria-label":"Project view",children:[h.jsx("button",{role:"tab","aria-selected":m==="graph",className:`${A.tab} ${m==="graph"?A.active:""}`,onClick:()=>p("graph"),children:"Graph"}),h.jsx("button",{role:"tab","aria-selected":m==="tasks",className:`${A.tab} ${m==="tasks"?A.active:""}`,onClick:()=>p("tasks"),children:"Tasks"})]}),m==="tasks"&&je>0&&h.jsxs("div",{className:A.projectSummary,children:[h.jsx("span",{className:A.projectSummaryTitle,children:`${ne}/${je} tasks complete`}),h.jsx("span",{className:A.projectSummarySubtitle,children:"Select a task or click + to create one"})]}),m==="tasks"&&je===0&&h.jsxs("div",{className:A.emptyCta,children:[h.jsx("button",{className:A.ctaButton,onClick:()=>s(ki(n)),children:"Create Task"}),h.jsx("div",{className:A.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),m==="graph"&&h.jsx(Zk,{projectId:n}),h.jsx(lc,{isOpen:v,title:"Archive Project?",description:"This will hide the project from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{R&&(d(R.id),s("/",{replace:!0})),y(!1)},onCancel:()=>y(!1)})]})}const Qk="_container_yc33j_1",Fk="_header_yc33j_8",Jk="_headerTitle_yc33j_35",Wk="_badge_yc33j_44",eR="_headerActions_yc33j_54",tR="_body_yc33j_61",nR="_formContent_yc33j_68",aR="_section_yc33j_75",sR="_label_yc33j_81",iR="_titleInput_yc33j_88",lR="_descriptionTextarea_yc33j_121",oR="_parentContext_yc33j_157",rR="_parentLabel_yc33j_165",cR="_parentName_yc33j_172",uR="_depList_yc33j_210",dR="_depItem_yc33j_216",fR="_depItemSelected_yc33j_238",hR="_noDeps_yc33j_242",mR="_btnPrimary_yc33j_248",pR="_btnGhost_yc33j_279",ut={container:Qk,header:Fk,headerTitle:Jk,badge:Wk,headerActions:eR,body:tR,formContent:nR,section:aR,label:sR,titleInput:iR,descriptionTextarea:lR,parentContext:oR,parentLabel:rR,parentName:cR,depList:uR,depItem:dR,depItemSelected:fR,noDeps:hR,btnPrimary:mR,btnGhost:pR};function Fb({mode:n,taskId:s,projectId:l,parentTaskId:o}){const{tasks:c,createTask:d,updateTask:f}=Ft(),{showToast:m}=to(),p=oa(),v=n==="edit",y=v&&s?c.find(R=>R.id===s):void 0,b=v?(y==null?void 0:y.projectId)??"":l??"",_=v?(y==null?void 0:y.parentTaskId)??"":o??"",T=_?c.find(R=>R.id===_):void 0,[N,D]=S.useState((y==null?void 0:y.title)??""),[w,j]=S.useState((y==null?void 0:y.description)??""),[V,M]=S.useState((y==null?void 0:y.dependsOn)??[]),$=S.useRef(!1);S.useEffect(()=>{v&&y&&!$.current&&($.current=!0,D(y.title),j(y.description),M(y.dependsOn))},[v,y]);const H=c.filter(R=>R.projectId===b&&(!v||R.id!==s)&&R.id!==_),J=N.trim().length>0&&(!v||y!==void 0)&&(v||b.length>0),te=R=>{M(ge=>ge.includes(R)?ge.filter(ne=>ne!==R):[...ge,R])},K=()=>{J&&(v&&y===void 0||(v&&s?(f(s,N.trim(),w,V),m("Task updated","success"),p(Di(s),{replace:!0})):(d(b,N.trim(),w,V.length>0?V:void 0,_||void 0),m("Task created","success"),p($l(b),{replace:!0}))))},W=()=>{p(v&&s?Di(s):$l(b))},he=v?"edit task":_?"child task":"new task";return h.jsxs("div",{className:ut.container,children:[h.jsxs("div",{className:ut.header,children:[h.jsxs("div",{className:ut.headerTitle,children:[h.jsx("span",{className:ut.badge,children:he}),T&&h.jsxs("span",{className:ut.parentContext,children:[h.jsx("span",{className:ut.parentLabel,children:"Child of"}),h.jsx("span",{className:ut.parentName,children:T.title})]})]}),h.jsxs("div",{className:ut.headerActions,children:[h.jsx("button",{onClick:K,disabled:!J,className:ut.btnPrimary,"data-testid":"task-edit-save",children:v?"Save Changes":"Create"}),h.jsx("button",{onClick:W,className:ut.btnGhost,children:"Cancel"})]})]}),h.jsx("div",{className:ut.body,children:h.jsxs("div",{className:ut.formContent,children:[h.jsxs("div",{className:ut.section,children:[h.jsx("label",{className:ut.label,htmlFor:"task-edit-title",children:"Title"}),h.jsx("input",{id:"task-edit-title",type:"text",value:N,onChange:R=>D(R.target.value),placeholder:"Task title...",autoFocus:!0,className:ut.titleInput,"data-testid":"task-edit-title",onKeyDown:R=>{R.key==="Enter"&&J&&K()}})]}),h.jsxs("div",{className:ut.section,children:[h.jsx("label",{className:ut.label,htmlFor:"task-edit-description",children:"Description"}),h.jsx("textarea",{id:"task-edit-description",value:w,onChange:R=>j(R.target.value),placeholder:"Describe the task... (markdown supported)",className:ut.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),h.jsxs("div",{className:ut.section,children:[h.jsx("div",{className:ut.label,children:"Dependencies"}),H.length===0?h.jsx("div",{className:ut.noDeps,children:"No other tasks in this project"}):h.jsx("div",{className:ut.depList,children:H.map(R=>{const ge=V.includes(R.id);return h.jsxs("label",{className:`${ut.depItem} ${ge?ut.depItemSelected:""}`,"data-testid":`dep-option-${R.id}`,children:[h.jsx("input",{type:"checkbox",checked:ge,onChange:()=>te(R.id)}),R.title,h.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",R.status,")"]})]},R.id)})})]})]})})]})}function gR(){const[n]=Sf(),s=n.get("project")??"",l=n.get("parent")??void 0;return s?h.jsx(Fb,{mode:"new",projectId:s,parentTaskId:l}):h.jsx(Mr,{to:"/",replace:!0})}function vR(){const{taskId:n}=Jr();return h.jsx(Fb,{mode:"edit",taskId:n})}const yR="_container_u6n1v_1",bR="_emptyState_u6n1v_8",SR="_card_u6n1v_14",xR="_cardHeader_u6n1v_34",_R="_categoryBadge_u6n1v_41",TR="_findingTitle_u6n1v_49",ER="_findingDate_u6n1v_55",jR="_findingContent_u6n1v_61",CR="_tags_u6n1v_67",AR="_tag_u6n1v_67",na={container:yR,emptyState:bR,card:SR,cardHeader:xR,categoryBadge:_R,findingTitle:TR,findingDate:ER,findingContent:jR,tags:CR,tag:AR};function NR(n){const s=new Date(n),l=new Date,o=l.getTime()-s.getTime(),c=Math.floor(o/1e3),d=Math.floor(c/60),f=Math.floor(d/60),m=Math.floor(f/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(f<24)return`${f}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const p=s.getFullYear()===l.getFullYear(),v=s.toLocaleString("en-US",{month:"short"}),y=s.getDate();return p?`${v} ${y}`:`${v} ${y} ${s.getFullYear()}`}const zy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function wR({projectId:n}){const{findings:s}=Ft(),l=s.filter(o=>o.projectId===n);return l.length===0?h.jsx("div",{className:na.emptyState,children:"No findings yet. Agents will post discoveries here."}):h.jsx("div",{className:na.container,children:l.map((o,c)=>{const d=zy[o.category]||zy.general;return h.jsxs(la.div,{className:na.card,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:c*.05,duration:.2},children:[h.jsxs("div",{className:na.cardHeader,children:[h.jsx("span",{className:na.categoryBadge,style:{background:d.bg,color:d.text},children:o.category}),h.jsx("span",{className:na.findingTitle,children:o.title}),h.jsx("span",{className:na.findingDate,title:o.createdAt,children:NR(o.createdAt)})]}),h.jsx("div",{className:na.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&h.jsx("div",{className:na.tags,children:o.tags.map(f=>h.jsx("span",{className:na.tag,style:{color:d.text,textShadow:`0 0 8px ${d.text}`},children:f},f))})]},o.id)})})}function Dr(n){if(!n)return"—";const s=new Date(n);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ld(n,s){if(!n||!s)return;const l=new Date(s).getTime()-new Date(n).getTime();if(isNaN(l)||l<0)return;const o=Math.floor(l/6e4),c=Math.floor(l%6e4/1e3);if(o===0)return`${c}s`;const d=Math.floor(o/60),f=o%60;return d===0?`${o}m ${c}s`:`${d}h ${f}m`}function DR(n){const s=n.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?A.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?A.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?A.envDotRed:A.envDotGray}function kR({status:n}){const s={not_started:"Not Started",working:"Working",paused:"Paused",complete:"Complete",failed:"Failed"},l={not_started:A.statusPending,working:A.statusInProgress,paused:A.statusWaitingInput,complete:A.statusDone,failed:A.statusFailed};return h.jsx("span",{className:`${A.statusBadge} ${l[n]??A.statusPending}`,children:s[n]??n})}function RR({task:n,tasksById:s,environments:l,projects:o,taskSessions:c}){const d=c.length>0?c[c.length-1]:void 0,f=(d==null?void 0:d.environmentId)??"",m=f?l.find(y=>y.id===f):void 0,p=o.find(y=>y.id===n.projectId),v=n.branch&&(p!=null&&p.repoUrl)?`${p.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(n.branch)}`:void 0;return h.jsxs("div",{className:A.overviewDashboard,children:[h.jsxs("div",{className:A.overviewHero,children:[h.jsx(kR,{status:n.status}),n.branch&&h.jsx("span",{className:A.overviewBranchPill,children:v?h.jsxs("a",{href:v,target:"_blank",rel:"noreferrer noopener",className:A.branchLink,children:["🔗"," ",n.branch]}):h.jsxs("span",{children:["🔗"," ",n.branch]})})]}),typeof n.description=="string"&&n.description&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Description"}),h.jsx("div",{className:A.overviewMarkdown,children:h.jsx(uf,{remarkPlugins:[df],children:n.description})})]}),f&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Environment"}),h.jsxs("div",{className:A.envRow,children:[m&&h.jsx("span",{className:`${A.envDot} ${DR(m.status)}`,title:m.status,"aria-label":`Status: ${m.status}`,role:"img"}),h.jsx("span",{className:A.overviewValue,children:(m==null?void 0:m.displayName)??f})]})]}),h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Dependencies"}),n.dependsOn.length===0?h.jsx("div",{className:A.overviewMuted,children:"None"}):h.jsx("div",{className:A.depList,children:n.dependsOn.map(y=>{const b=s.get(y),_=(b==null?void 0:b.status)==="complete";return h.jsxs("div",{className:`${A.depItem} ${_?A.depDone:A.depBlocked}`,children:[h.jsx("span",{children:_?"✓":"○"}),h.jsx("span",{children:(b==null?void 0:b.title)??y})]},y)})})]}),h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Timeline"}),h.jsxs("div",{className:A.timeline,children:[n.createdAt&&h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Created"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.createdAt)})]}),n.assignedAt&&(()=>{const y=Ld(n.createdAt,n.assignedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Assigned"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.assignedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),n.startedAt&&(()=>{const y=Ld(n.assignedAt??n.createdAt,n.startedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Started"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.startedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),n.completedAt&&(()=>{const y=Ld(n.startedAt,n.completedAt);return h.jsxs("div",{className:A.timelineRow,children:[h.jsx("span",{className:A.timelineKey,children:"Completed"}),h.jsx("span",{className:A.timelineValue,children:Dr(n.completedAt)}),y!==void 0&&h.jsx("span",{className:A.timelineDelta,children:y})]})})(),!n.createdAt&&!n.assignedAt&&!n.startedAt&&!n.completedAt&&h.jsx("div",{className:A.overviewMuted,children:"No timing data"})]})]}),n.reviewNotes&&h.jsxs("div",{className:A.overviewSection,children:[h.jsx("div",{className:A.overviewLabel,children:"Review Notes"}),h.jsx("div",{className:A.reviewNotes,children:n.reviewNotes})]})]})}function MR({eventsDropped:n}){return n<=0?h.jsx(h.Fragment,{}):h.jsxs("div",{className:A.eventOverflowWarning,role:"alert",children:["⚠ ",n.toLocaleString()," older event",n===1?"":"s"," were dropped — only the most recent 5,000 are shown."]})}function OR({task:n,sessionId:s,isBlocked:l,onStart:o,onResume:c,onStop:d,onComplete:f,onDelete:m,onEdit:p}){if(n.status==="not_started")return l?h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:p,className:A.btnGhost,children:"Edit"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]}):h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:o,className:A.btnPrimary,children:"Start"}),h.jsx("button",{onClick:p,className:A.btnGhost,children:"Edit"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]});if(n.status==="working")return h.jsx("div",{className:A.headerActions,children:h.jsx("button",{onClick:d,disabled:!s,className:A.btnDanger,children:"Stop"})});if(n.status==="paused")return h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:f,className:A.btnPrimary,children:"Complete"}),h.jsx("button",{onClick:c,className:A.btnGhost,children:"Resume"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]});if(n.status==="complete")return h.jsx("div",{className:A.headerActions,children:h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})});if(n.status==="failed")return h.jsxs("div",{className:A.headerActions,children:[h.jsx("button",{onClick:o,className:A.btnPrimary,children:"Retry"}),h.jsx("button",{onClick:m,className:A.btnDanger,children:"Delete"})]})}function BR({taskSessions:n,selectedSessionId:s,onSelect:l}){if(!(n.length<2))return h.jsxs("div",{className:A.attemptSelector,"data-testid":"attempt-selector",children:[h.jsx("span",{className:A.attemptLabel,children:"Attempts:"}),n.map((o,c)=>{const d=o.id===s,f=o.status==="completed"?"✓":o.status==="failed"?"✗":o.status==="running"||o.status==="idle"?"●":"";return h.jsxs("button",{className:`${A.attemptButton} ${d?A.attemptActive:""}`,onClick:()=>l(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":d,"data-testid":`attempt-${c+1}`,children:["#",c+1,f&&h.jsx("span",{className:A.attemptStatus,children:f})]},o.id)})]})}function Ud(){const{taskId:n}=Jr(),s=an(),l=oa(),{events:o,eventsDropped:c,tasks:d,environments:f,loadSessionEvents:m,loadFindings:p,kill:v,startTask:y,resumeTask:b,completeTask:_,deleteTask:T,projects:N,taskSessions:D,loadTaskSessions:w}=Ft(),j=S.useRef(null),V=S.useRef(void 0),M=S.useRef(void 0),$=S.useRef(void 0),H=S.useRef(void 0),J=S.useRef(void 0),te=s.pathname.endsWith("/stream")?"stream":s.pathname.endsWith("/findings")?"findings":"overview",[K,W]=S.useState(te),[he,R]=S.useState(!1),[ge,ne]=S.useState(void 0),je=S.useRef(te);te!==je.current&&(je.current=te,te!==K&&W(te));const G=d.find(ce=>ce.id===n),U=(G==null?void 0:G.projectId)||void 0,X=G?D[G.id]??[]:[];let ee;ge&&X.some(ce=>ce.id===ge)?ee=ge:ee=(G==null?void 0:G.latestSessionId)||void 0;const Ae=()=>{R(!0)},Ee=()=>{G&&(T(G.id),R(!1),l($l(G.projectId),{replace:!0}))};if((G==null?void 0:G.id)!==M.current&&(M.current=G==null?void 0:G.id,ge!==void 0&&ne(void 0)),S.useEffect(()=>{if(!(G!=null&&G.id))return;const ce=G.id!==H.current,Ie=G.latestSessionId!==J.current;(ce||Ie)&&(H.current=G.id,J.current=G.latestSessionId,w(G.id))},[G==null?void 0:G.id,G==null?void 0:G.latestSessionId,w]),(G==null?void 0:G.status)!==$.current){$.current=G==null?void 0:G.status;const ce=(G==null?void 0:G.status)==="not_started"?"overview":(G==null?void 0:G.status)==="working"||(G==null?void 0:G.status)==="paused"?"stream":(G==null?void 0:G.status)==="complete"?"findings":void 0;ce&&ce!==K&&W(ce)}const Ge=S.useMemo(()=>new Map(d.map(ce=>[ce.id,ce])),[d]),we=S.useMemo(()=>{const ce=ee?o.filter(Ie=>Ie.sessionId===ee):[];return Qb($b(ce))},[o,ee]),_e=G?G.dependsOn.some(ce=>{const Ie=Ge.get(ce);return Ie!==void 0&&Ie.status!=="complete"}):!1,Ce=S.useMemo(()=>bk(n,N,Ge),[n,N,Ge]);S.useEffect(()=>{ee&&ee!==V.current&&(V.current=ee,m(ee))},[ee,m]),S.useEffect(()=>{K==="findings"&&U&&p(U)},[K,U,p]),S.useEffect(()=>{j.current&&K==="stream"&&(j.current.scrollTop=j.current.scrollHeight)},[we.length,K]);const Q=ce=>{W(ce),l(Di(n,ce==="overview"?void 0:ce))};return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:Ce}),h.jsxs("div",{className:A.header,children:[h.jsxs("span",{className:A.headerTitle,children:[h.jsx("span",{"data-testid":"task-title",children:(G==null?void 0:G.title)||n}),G&&h.jsx("span",{className:A.taskStatusBadge,"data-testid":"task-status",children:G.status}),(G==null?void 0:G.branch)&&h.jsx("span",{className:A.taskBranch,children:G.branch}),_e&&h.jsx("span",{className:A.taskBlockedBadge,children:"blocked"})]}),G&&h.jsx(OR,{task:G,sessionId:ee,isBlocked:_e,onStart:()=>y(G.id),onResume:()=>b(G.id),onStop:()=>ee&&v(ee),onComplete:()=>_(G.id),onDelete:Ae,onEdit:()=>l(kT(G.id))})]}),h.jsxs("div",{className:A.tabBar,role:"tablist","aria-label":"Task view",children:[h.jsx("button",{role:"tab","aria-selected":K==="overview",className:`${A.tab} ${K==="overview"?A.active:""}`,onClick:()=>Q("overview"),children:"Overview"}),h.jsx("button",{role:"tab","aria-selected":K==="stream",className:`${A.tab} ${K==="stream"?A.active:""}`,onClick:()=>Q("stream"),children:"Stream"}),h.jsx("button",{role:"tab","aria-selected":K==="findings",className:`${A.tab} ${K==="findings"?A.active:""}`,onClick:()=>Q("findings"),children:"Findings"})]}),h.jsxs(Ui,{mode:"wait",children:[K==="overview"&&h.jsx(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:A.overviewContent,children:G?h.jsx(RR,{task:G,tasksById:Ge,environments:f,projects:N,taskSessions:X}):h.jsx("div",{className:A.waitingMessage,children:"No additional details"})},"overview"),K==="stream"&&h.jsxs(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[h.jsx(BR,{taskSessions:X,selectedSessionId:ee,onSelect:ce=>ne(ce)}),h.jsxs("div",{ref:j,className:A.eventScroll,children:[!ee&&G&&h.jsxs("div",{className:A.emptyCta,children:[h.jsx("button",{className:A.ctaButton,onClick:()=>y(G.id),children:"Start Task"}),h.jsx("div",{className:A.ctaDescription,children:"Click to begin agent execution"})]}),ee&&we.length===0&&h.jsx("div",{className:A.waitingMessage,children:"Waiting for events..."}),h.jsx(MR,{eventsDropped:c}),we.map((ce,Ie)=>h.jsx(qb,{event:ce,toolUseCtx:ce.toolUseCtx},`${ce.sessionId}-${ce.timestamp}-${Ie}`))]})]},"stream"),K==="findings"&&h.jsx(la.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:A.tabContent,children:U?h.jsx(wR,{projectId:U}):h.jsx("div",{className:A.noContext,children:"Navigate to a task within a project to view findings"})},"findings")]}),G&&h.jsx(lc,{isOpen:he,title:"Delete Task?",description:`"${G.title}" will be permanently removed.`,onConfirm:Ee,onCancel:()=>R(!1)})]})}function LR(){const n=pk();return h.jsxs("div",{className:A.panelContainer,children:[h.jsx(Hi,{segments:n}),h.jsx("div",{className:A.emptyState,children:"Configure the new environment below"})]})}const UR="_layout_1sbe4_1",zR="_content_1sbe4_8",Vy={layout:UR,content:zR},VR={environments:"Environments",credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About"};function HR(){const s=an().pathname.replace(/^\/settings\/?/,"").split("/")[0],l=VR[s],o=mk(l);return h.jsxs("div",{className:Vy.layout,children:[h.jsx(Hi,{segments:o}),h.jsx("div",{className:Vy.content,children:h.jsx(r0,{})})]})}const IR="_nav_29xjr_1",GR="_tab_29xjr_30",PR="_tabIcon_29xjr_56",qR="_tabActive_29xjr_62",kr={nav:IR,tab:GR,tabIcon:PR,tabActive:qR},Aa=[{path:"environments",label:"Environments",icon:"🖥️"},{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"about",label:"About",icon:"ℹ️"}];function YR(){var f;const n=an(),s=oa(),l=S.useRef(null),o=((f=Aa.find(m=>n.pathname===`${wi}/${m.path}`))==null?void 0:f.path)??Aa[0].path,c=S.useCallback(m=>{s(`${wi}/${m}`)},[s]),d=S.useCallback(m=>{var T,N;const p=(T=l.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!p)return;const v=Array.from(p).findIndex(D=>D===document.activeElement),y=v>=0?v:Aa.findIndex(D=>D.path===o);let b=y;if(m.key==="ArrowDown")m.preventDefault(),b=(y+1)%Aa.length;else if(m.key==="ArrowUp")m.preventDefault(),b=(y-1+Aa.length)%Aa.length;else if(m.key==="Home")m.preventDefault(),b=0;else if(m.key==="End")m.preventDefault(),b=Aa.length-1;else return;const _=Aa[b].path;s(`${wi}/${_}`),(N=p[b])==null||N.focus()},[o,s]);return h.jsx("nav",{className:kr.nav,ref:l,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Aa.map(m=>{const p=m.path===o;return h.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${kr.tab} ${p?kr.tabActive:""}`,onClick:()=>c(m.path),children:[h.jsx("span",{className:kr.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}const KR="_container_1nk8c_1",ZR="_header_1nk8c_5",XR="_headerLabel_1nk8c_12",$R="_addButton_1nk8c_20",QR="_envRow_1nk8c_55",FR="_targeted_1nk8c_69",JR="_expanded_1nk8c_72",WR="_statusDot_1nk8c_76",eM="_pulse_1nk8c_79",tM="_envName_1nk8c_83",nM="_envActions_1nk8c_87",aM="_idleLabel_1nk8c_94",sM="_newChatButton_1nk8c_99",iM="_envActionsRow_1nk8c_126",lM="_connectButton_1nk8c_134",oM="_stopButton_1nk8c_160",rM="_deleteButton_1nk8c_186",cM="_provisionMessage_1nk8c_213",uM="_errorMessage_1nk8c_220",dM="_sessionRow_1nk8c_227",fM="_selected_1nk8c_243",hM="_sessionDot_1nk8c_248",mM="_sessionSummaryRow_1nk8c_252",pM="_sessionExpandArrow_1nk8c_272",gM="_sessionSummaryText_1nk8c_283",vM="_sessionCountBadge_1nk8c_290",yM="_emptyCta_1nk8c_313",bM="_ctaDescription_1nk8c_326",SM="_ctaButton_1nk8c_332",Ke={container:KR,header:ZR,headerLabel:XR,addButton:$R,envRow:QR,targeted:FR,expanded:JR,statusDot:WR,pulse:eM,envName:tM,envActions:nM,idleLabel:aM,newChatButton:sM,envActionsRow:iM,connectButton:lM,stopButton:oM,deleteButton:rM,provisionMessage:cM,errorMessage:uM,sessionRow:dM,selected:fM,sessionDot:hM,sessionSummaryRow:mM,sessionExpandArrow:pM,sessionSummaryText:gM,sessionCountBadge:vM,emptyCta:yM,ctaDescription:bM,ctaButton:SM},xM={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"},_M={running:"running",idle:"awaiting input",failed:"failed",interrupted:"interrupted",completed:"completed"},Hy=["running","idle","failed","interrupted","completed"],TM=.2;function EM(n){const s={};for(const d of n)s[d.status]=(s[d.status]||0)+1;const l=Hy.filter(d=>s[d]>0).map(d=>`${s[d]} ${_M[d]||d}`),o=new Set(Hy),c=Object.keys(s).filter(d=>!o.has(d)).sort().map(d=>`${s[d]} ${d}`);return[...l,...c].join(", ")}function jM({status:n}){const s=n==="running"?"var(--accent-green)":n==="idle"?"var(--accent-yellow)":n==="completed"?"var(--text-secondary)":n==="failed"||n==="interrupted"?"var(--accent-red)":"var(--text-tertiary)";return h.jsx("span",{className:Ke.sessionDot,style:{color:s},children:"●"})}function CM({env:n,envSessions:s,selectedSessionId:l,isNewChatTarget:o,expanded:c,onToggleExpand:d,sessionsExpanded:f,onToggleSessionsExpand:m,provisionProgress:p,onProvision:v,onStop:y,onRemove:b,navigate:_}){const[T,N]=S.useState(!1),D=xM[n.status]||"var(--text-tertiary)",w=n.status==="connected",j=n.status==="connecting",V=n.status==="disconnected"||n.status==="error";return h.jsxs("div",{children:[h.jsx(lc,{isOpen:T,title:"Delete Environment?",description:`"${n.displayName||n.id}" will be permanently removed. This destroys the workspace and removes all data.`,onConfirm:()=>{b(n.id),N(!1)},onCancel:()=>N(!1)}),h.jsxs("div",{className:`${Ke.envRow} ${o?Ke.targeted:""} ${c?Ke.expanded:""}`,"data-testid":"env-row",onClick:d,children:[h.jsx("span",{className:`${Ke.statusDot} ${w?Ke.pulse:""}`,style:{color:D},children:"●"}),h.jsx("span",{className:Ke.envName,title:n.displayName||n.id,children:n.displayName||n.id}),h.jsxs("span",{className:Ke.envActions,children:[s.length===0&&!o&&!c&&h.jsx("span",{className:Ke.idleLabel,children:"(idle)"}),w&&h.jsx("button",{onClick:M=>{M.stopPropagation(),_(m0(n.id,n.defaultRuntime||"claude-code"))},title:"New chat",className:Ke.newChatButton,children:"+"})]})]}),c&&h.jsxs("div",{className:Ke.envActionsRow,children:[j&&p&&h.jsx("span",{className:Ke.provisionMessage,children:p.message}),n.status==="error"&&(p==null?void 0:p.stage)==="error"&&h.jsx("span",{className:Ke.errorMessage,children:p.message}),V&&h.jsx("button",{onClick:M=>{M.stopPropagation(),v(n.id)},className:Ke.connectButton,children:n.status==="error"?"Retry":"Connect"}),w&&h.jsx("button",{onClick:M=>{M.stopPropagation(),y(n.id)},className:Ke.stopButton,children:"Stop"}),!j&&h.jsx("button",{onClick:M=>{M.stopPropagation(),N(!0)},className:Ke.deleteButton,children:"Delete"})]}),s.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Ke.sessionSummaryRow,"data-testid":"session-summary-row",role:"button",tabIndex:0,"aria-expanded":f,"aria-label":f?"Collapse sessions":"Expand sessions",onClick:m,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),m())},children:[h.jsx("span",{className:`${Ke.sessionExpandArrow} ${f?Ke.expanded:""}`,children:"▸"}),h.jsx("span",{className:Ke.sessionSummaryText,children:EM(s)}),h.jsx("span",{className:Ke.sessionCountBadge,children:s.length})]}),h.jsx(Ui,{children:f&&h.jsx(la.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:TM,ease:"easeInOut"},style:{overflow:"hidden"},children:s.map(M=>h.jsxs("div",{onClick:$=>{$.stopPropagation(),_(h0(M.id))},className:`${Ke.sessionRow} ${l===M.id?Ke.selected:""}`,title:M.prompt,"data-testid":"session-row",children:[h.jsx(jM,{status:M.status})," ",M.prompt.length>24?M.prompt.slice(0,24)+"...":M.prompt]},M.id))})})]})]})}function AM(){const{environments:n,sessions:s,provisionStatus:l,provisionEnvironment:o,stopEnvironment:c,removeEnvironment:d}=Ft(),f=oa(),[m,p]=S.useState(null),[v,y]=S.useState(new Set),b=tn("/sessions/:sessionId"),_=tn("/sessions/new"),T=(b==null?void 0:b.params.sessionId)!=="new"?b==null?void 0:b.params.sessionId:void 0,[N]=Sf(),D=_?N.get("env")??void 0:void 0;return h.jsxs("div",{className:Ke.container,children:[h.jsxs("div",{className:Ke.header,children:[h.jsx("span",{className:Ke.headerLabel,children:"Environments"}),h.jsx("button",{className:Ke.addButton,onClick:()=>f(cv),title:"Add environment",children:"+ Add Environment"})]}),n.length===0&&h.jsxs("div",{className:Ke.emptyCta,children:[h.jsx("button",{className:Ke.ctaButton,onClick:()=>f(cv),children:"Add Environment"}),h.jsx("div",{className:Ke.ctaDescription,children:"Connect an environment to run agents"})]}),n.map(w=>{const j=s.filter(V=>V.environmentId===w.id);return h.jsx(CM,{env:w,envSessions:j,selectedSessionId:T,isNewChatTarget:D===w.id,expanded:m===w.id,onToggleExpand:()=>p(m===w.id?null:w.id),sessionsExpanded:v.has(w.id),onToggleSessionsExpand:()=>{y(V=>{const M=new Set(V);return M.has(w.id)?M.delete(w.id):M.add(w.id),M})},provisionProgress:l[w.id],onProvision:o,onStop:c,onRemove:d,navigate:f},w.id)})]})}function NM(){return h.jsx(AM,{})}const wM="_section_1ingb_14",DM="_sectionTitle_1ingb_26",kM="_sectionDescription_1ingb_35",RM="_tokenList_1ingb_48",MM="_tokenRow_1ingb_55",OM="_tokenBadge_1ingb_68",BM="_tokenName_1ingb_83",LM="_tokenTarget_1ingb_90",UM="_deleteButton_1ingb_99",zM="_addForm_1ingb_113",VM="_formRow_1ingb_119",HM="_input_1ingb_125",IM="_select_1ingb_155",GM="_addButton_1ingb_187",PM="_emptyStateInfo_1ingb_221",qM="_themeOptions_1ingb_229",YM="_themeOption_1ingb_229",KM="_themeOptionSelected_1ingb_254",ZM="_themeOptionHeader_1ingb_259",XM="_themeOptionLabel_1ingb_266",$M="_themeOptionDesc_1ingb_273",QM="_variantToggle_1ingb_279",FM="_variantButton_1ingb_286",JM="_variantActive_1ingb_305",WM="_themeSwatches_1ingb_311",e3="_themeSwatch_1ingb_311",t3="_systemToggle_1ingb_325",n3="_systemToggleHint_1ingb_341",a3="_themeActive_1ingb_348",s3="_aboutGrid_1ingb_354",i3="_aboutItem_1ingb_360",l3="_aboutLabel_1ingb_373",o3="_aboutValue_1ingb_379",r3="_aboutDot_1ingb_387",c3="_aboutDotConnected_1ingb_394",u3="_aboutDotDisconnected_1ingb_398",fe={section:wM,sectionTitle:DM,sectionDescription:kM,tokenList:RM,tokenRow:MM,tokenBadge:OM,tokenName:BM,tokenTarget:LM,deleteButton:UM,addForm:zM,formRow:VM,input:HM,select:IM,addButton:GM,emptyStateInfo:PM,themeOptions:qM,themeOption:YM,themeOptionSelected:KM,themeOptionHeader:ZM,themeOptionLabel:XM,themeOptionDesc:$M,variantToggle:QM,variantButton:FM,variantActive:JM,themeSwatches:WM,themeSwatch:e3,systemToggle:t3,systemToggleHint:n3,themeActive:a3,aboutGrid:s3,aboutItem:i3,aboutLabel:l3,aboutValue:o3,aboutDot:r3,aboutDotConnected:c3,aboutDotDisconnected:u3},d3=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function f3(){const{credentialProviders:n,updateCredentialProviders:s}=Ft(),l=(o,c)=>{const d={...n};o==="claude"?d.claude=c:d[o]=c,s(d)};return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),h.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),h.jsx("div",{className:fe.tokenList,children:d3.map(o=>h.jsxs("div",{className:fe.tokenRow,children:[h.jsx("span",{className:fe.tokenName,children:o.label}),h.jsx("span",{className:fe.tokenTarget,children:o.description}),h.jsx("select",{className:fe.select,value:n[o.key],onChange:c=>l(o.key,c.target.value),children:o.options.map(c=>h.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const h3=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function m3(){const{tokens:n,setToken:s,deleteToken:l}=Ft(),{showToast:o}=to(),[c,d]=S.useState(""),[f,m]=S.useState(""),[p,v]=S.useState("env_var"),[y,b]=S.useState(""),[_,T]=S.useState(null),N=j=>{if(j.preventDefault(),!c||!f)return;const V=p==="env_var"?y||c.toUpperCase()+"_TOKEN":"";s(c,f,p,V,p==="file"?y:""),o("Token saved successfully","success"),d(""),m(""),b("")},D=j=>{T(j)},w=()=>{_&&(l(_),o("Token deleted","info")),T(null)};return h.jsxs(h.Fragment,{children:[h.jsx(lc,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>T(null)}),h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),h.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),n.length===0?h.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):h.jsx("div",{className:fe.tokenList,children:n.map(j=>h.jsxs("div",{className:fe.tokenRow,children:[h.jsx("span",{className:fe.tokenBadge,children:j.tokenType}),h.jsx("span",{className:fe.tokenName,children:j.name}),h.jsx("span",{className:fe.tokenTarget,children:j.tokenType==="env_var"?j.envVar:j.filePath}),h.jsx("button",{className:fe.deleteButton,onClick:()=>D(j.name),title:`Delete ${j.name}`,children:"×"})]},j.name))}),h.jsxs("form",{className:fe.addForm,onSubmit:N,children:[h.jsxs("div",{className:fe.formRow,children:[h.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:j=>d(j.target.value)}),h.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:f,onChange:j=>m(j.target.value)})]}),h.jsxs("div",{className:fe.formRow,children:[h.jsx("select",{className:fe.select,value:p,onChange:j=>v(j.target.value),children:h3.map(j=>h.jsx("option",{value:j.value,children:j.label},j.value))}),h.jsx("input",{className:fe.input,type:"text",placeholder:p==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:y,onChange:j=>b(j.target.value)}),h.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}function p3(){return h.jsxs(h.Fragment,{children:[h.jsx(f3,{}),h.jsx(m3,{})]})}const g3="_container_1xcp7_1",v3="_header_1xcp7_7",y3="_form_1xcp7_19",b3="_formActions_1xcp7_87",S3="_list_1xcp7_93",x3="_card_1xcp7_99",_3="_active_1xcp7_109",T3="_cardHeader_1xcp7_113",E3="_cardActions_1xcp7_123",j3="_description_1xcp7_128",C3="_meta_1xcp7_134",A3="_promptDetails_1xcp7_151",N3="_promptText_1xcp7_163",w3="_empty_1xcp7_180",D3="_btnPrimary_1xcp7_186",k3="_btnSecondary_1xcp7_220",R3="_btnSmall_1xcp7_247",M3="_btnDanger_1xcp7_273",Et={container:g3,header:v3,form:y3,formActions:b3,list:S3,card:x3,active:_3,cardHeader:T3,cardActions:E3,description:j3,meta:C3,promptDetails:A3,promptText:N3,empty:w3,btnPrimary:D3,btnSecondary:k3,btnSmall:R3,btnDanger:M3};function O3(){const{personas:n,createPersona:s,updatePersona:l,deletePersona:o}=Ft(),[c,d]=S.useState(null),[f,m]=S.useState(!1),[p,v]=S.useState(null),[y,b]=S.useState(""),[_,T]=S.useState(""),[N,D]=S.useState(""),[w,j]=S.useState(""),[V,M]=S.useState(""),[$,H]=S.useState(0),J=()=>{b(""),T(""),D(""),j(""),M(""),H(0)},te=()=>{J(),d(null),m(!0)},K=ne=>{b(ne.name),T(ne.description),D(ne.systemPrompt),j(ne.runtime),M(ne.model),H(ne.maxTurns),d(ne),m(!1)},W=ne=>{ne.preventDefault(),!(!y.trim()||!N.trim())&&(c?(l(c.id,y,_,N,w,V,$),d(null)):(s(y,_,N,w,V,$),m(!1)),J())},he=ne=>{o(ne),v(null),(c==null?void 0:c.id)===ne&&(d(null),J())},R=()=>{d(null),m(!1),J()},ge=()=>h.jsxs("form",{onSubmit:W,className:Et.form,children:[h.jsx("h3",{children:c?"Edit Persona":"Create Persona"}),h.jsxs("label",{children:["Name",h.jsx("input",{type:"text",value:y,onChange:ne=>b(ne.target.value),placeholder:"e.g. Frontend Engineer",required:!0})]}),h.jsxs("label",{children:["Description",h.jsx("input",{type:"text",value:_,onChange:ne=>T(ne.target.value),placeholder:"Brief description..."})]}),h.jsxs("label",{children:["Runtime",h.jsxs("select",{value:w,onChange:ne=>j(ne.target.value),children:[h.jsx("option",{value:"",children:"Default"}),h.jsx("option",{value:"claude-code",children:"claude-code"}),h.jsx("option",{value:"codex",children:"codex"}),h.jsx("option",{value:"copilot",children:"copilot"})]})]}),h.jsxs("label",{children:["Model",h.jsx("input",{type:"text",value:V,onChange:ne=>M(ne.target.value),placeholder:"e.g. sonnet"})]}),h.jsxs("label",{children:["Max Turns",h.jsx("input",{type:"number",value:$,onChange:ne=>H(parseInt(ne.target.value,10)||0),min:0})]}),h.jsxs("label",{children:["System Prompt",h.jsx("textarea",{value:N,onChange:ne=>D(ne.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0})]}),h.jsxs("div",{className:Et.formActions,children:[h.jsx("button",{type:"submit",className:Et.btnPrimary,children:c?"Save":"Create"}),h.jsx("button",{type:"button",onClick:R,className:Et.btnSecondary,children:"Cancel"})]})]});return h.jsxs("div",{className:Et.container,children:[h.jsxs("div",{className:Et.header,children:[h.jsx("h2",{children:"Personas"}),h.jsx("button",{onClick:te,className:Et.btnPrimary,children:"+ New Persona"})]}),(f||c)&&ge(),n.length===0&&!f?h.jsx("p",{className:Et.empty,children:"No personas yet. Create one to get started."}):h.jsx("div",{className:Et.list,children:n.map(ne=>h.jsxs("div",{className:`${Et.card} ${(c==null?void 0:c.id)===ne.id?Et.active:""}`,children:[h.jsxs("div",{className:Et.cardHeader,children:[h.jsx("strong",{children:ne.name}),h.jsxs("div",{className:Et.cardActions,children:[h.jsx("button",{onClick:()=>K(ne),className:Et.btnSmall,children:"Edit"}),p===ne.id?h.jsxs(h.Fragment,{children:[h.jsx("button",{onClick:()=>he(ne.id),className:Et.btnDanger,children:"Confirm"}),h.jsx("button",{onClick:()=>v(null),className:Et.btnSmall,children:"Cancel"})]}):h.jsx("button",{onClick:()=>v(ne.id),className:Et.btnSmall,children:"Delete"})]})]}),ne.description&&h.jsx("p",{className:Et.description,children:ne.description}),h.jsxs("div",{className:Et.meta,children:[ne.runtime&&h.jsxs("span",{children:["Runtime: ",ne.runtime]}),ne.model&&h.jsxs("span",{children:["Model: ",ne.model]}),ne.maxTurns>0&&h.jsxs("span",{children:["Max turns: ",ne.maxTurns]})]}),h.jsxs("details",{className:Et.promptDetails,children:[h.jsx("summary",{children:"System Prompt"}),h.jsx("pre",{className:Et.promptText,children:ne.systemPrompt})]})]},ne.id))})]})}function B3(){return h.jsx(O3,{})}function L3(){const{themeId:n,resolvedThemeId:s,setTheme:l,preferSystem:o,setPreferSystem:c}=Zy();return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),h.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),h.jsx("div",{className:fe.themeOptions,children:Xr.filter(d=>!d.hidden).map(d=>{const f=!!(d.variantLightId&&d.variantDarkId),m=f?n===d.id||n===d.variantLightId||n===d.variantDarkId:n===d.id,p=f&&s===d.variantLightId;return h.jsxs("button",{type:"button",className:`${fe.themeOption} ${m?fe.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>l(d.id),children:[h.jsxs("span",{className:fe.themeOptionHeader,children:[h.jsxs("span",{children:[h.jsx("span",{className:fe.themeOptionLabel,children:d.label}),h.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),f&&h.jsxs("span",{className:fe.variantToggle,children:[h.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${m&&p?fe.variantActive:""}`,onClick:v=>{v.stopPropagation(),c(!1),l(d.variantLightId)},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),v.stopPropagation(),c(!1),l(d.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&p,children:"☼"}),h.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${m&&!p?fe.variantActive:""}`,onClick:v=>{v.stopPropagation(),c(!1),l(d.variantDarkId)},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),v.stopPropagation(),c(!1),l(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!p,children:"☾"})]})]}),d.swatches&&h.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((v,y)=>h.jsx("span",{className:fe.themeSwatch,style:{background:v}},y))})]},d.id)})}),h.jsxs("label",{className:fe.systemToggle,children:[h.jsx("input",{type:"checkbox",checked:o,onChange:d=>c(d.target.checked)}),h.jsx("span",{children:"Match system light/dark preference"})]}),h.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),h.jsxs("p",{className:fe.themeActive,children:["Active theme: ",h.jsx("strong",{children:s})]})]})}function U3(){return h.jsx(L3,{})}function z3(){const{connected:n,environments:s,sessions:l}=Ft(),o=s.filter(f=>f.status==="connected").length,c=s.length,d=l.filter(f=>["running","idle"].includes(f.status)).length;return h.jsxs("section",{className:fe.section,children:[h.jsx("h3",{className:fe.sectionTitle,children:"About"}),h.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),h.jsxs("div",{className:fe.aboutGrid,children:[h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Connection"}),h.jsxs("span",{className:fe.aboutValue,children:[h.jsx("span",{className:`${fe.aboutDot} ${n?fe.aboutDotConnected:fe.aboutDotDisconnected}`}),n?"Connected":"Disconnected"]})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Environments"}),h.jsxs("span",{className:fe.aboutValue,children:[o,"/",c," connected"]})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),h.jsx("span",{className:fe.aboutValue,children:d})]}),h.jsxs("div",{className:fe.aboutItem,children:[h.jsx("span",{className:fe.aboutLabel,children:"Version"}),h.jsx("span",{className:fe.aboutValue,children:"0.28.0"})]})]})]})}function V3(){return h.jsx(z3,{})}const H3="_root_cdda9_1",I3="_body_cdda9_7",G3="_main_cdda9_13",zd={root:H3,body:I3,main:G3},P3=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function q3(){const{lastSpawnedId:n,environments:s}=Ft(),{showToast:l}=to();jw(s,l);const o=oa(),c=an(),d=c.pathname.startsWith(wi);return S.useEffect(()=>{n&&!c.pathname.startsWith("/tasks/")&&o(h0(n),{replace:!0})},[n,o,c.pathname]),h.jsxs("div",{className:zd.root,children:[h.jsx(VT,{}),h.jsxs("div",{className:zd.body,children:[d?h.jsx(YR,{}):h.jsx(KN,{}),h.jsxs("div",{className:zd.main,children:[h.jsx(r0,{}),h.jsx(dw,{})]})]}),h.jsx(Ew,{})]})}function Y3(){return h.jsx(Q_,{children:h.jsxs(jt,{element:h.jsx(q3,{}),children:[h.jsx(jt,{index:!0,element:h.jsx(fk,{})}),h.jsx(jt,{path:"sessions/new",element:h.jsx(Sk,{})}),h.jsx(jt,{path:"sessions/:sessionId",element:h.jsx(Ek,{})}),h.jsx(jt,{path:"projects/:projectId",element:h.jsx($k,{})}),h.jsx(jt,{path:"tasks/new",element:h.jsx(gR,{})}),h.jsx(jt,{path:"tasks/:taskId",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/stream",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/findings",element:h.jsx(Ud,{})}),h.jsx(jt,{path:"tasks/:taskId/edit",element:h.jsx(vR,{})}),h.jsx(jt,{path:"environments/new",element:h.jsx(LR,{})}),h.jsxs(jt,{path:"settings",element:h.jsx(HR,{}),children:[h.jsx(jt,{index:!0,element:h.jsx(Mr,{to:"environments",replace:!0})}),h.jsx(jt,{path:"environments",element:h.jsx(NM,{})}),h.jsx(jt,{path:"credentials",element:h.jsx(p3,{})}),h.jsx(jt,{path:"tokens",element:h.jsx(Mr,{to:"../credentials",replace:!0})}),h.jsx(jt,{path:"personas",element:h.jsx(B3,{})}),h.jsx(jt,{path:"appearance",element:h.jsx(U3,{})}),h.jsx(jt,{path:"about",element:h.jsx(V3,{})})]}),h.jsx(jt,{path:"*",element:h.jsx(Mr,{to:"/",replace:!0})})]})})}function K3(){const n=P3?K1:U1;return h.jsx(J1,{children:h.jsx(X1,{children:h.jsx(n,{children:h.jsx(xT,{children:h.jsx(Y3,{})})})})})}_1.createRoot(document.getElementById("root")).render(h.jsx(S.StrictMode,{children:h.jsx(K3,{})}));
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Grackle</title>
7
- <script type="module" crossorigin src="/assets/index-BJ1oe_nq.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-NttW8y4V.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/assets/markdown-gcy1Jmzi.js">
9
9
  <link rel="modulepreload" crossorigin href="/assets/dagview-EHk2VaeR.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-BBRH_Md2.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "rehype-prism-plus": "^2.0.0",
32
32
  "remark-gfm": "^4.0.0",
33
33
  "react-router": "^7.0.0",
34
- "@grackle-ai/common": "0.28.0"
34
+ "@grackle-ai/common": "0.29.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rushstack/heft": "1.2.4",