@grackle-ai/web 0.136.1 → 0.136.2
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.
- package/dist/assets/{KnowledgePage-Dbp2FOCL.js → KnowledgePage-pdM88IVS.js} +2 -2
- package/dist/assets/{KnowledgePage-Dbp2FOCL.js.map → KnowledgePage-pdM88IVS.js.map} +1 -1
- package/dist/assets/{McpAppWidget-DsHebvaE.js → McpAppWidget-D-BOXq5b.js} +2 -2
- package/dist/assets/{McpAppWidget-DsHebvaE.js.map → McpAppWidget-D-BOXq5b.js.map} +1 -1
- package/dist/assets/{SessionsListPage-CWjrzCjE.js → SessionsListPage-CL-9RybL.js} +2 -2
- package/dist/assets/{SessionsListPage-CWjrzCjE.js.map → SessionsListPage-CL-9RybL.js.map} +1 -1
- package/dist/assets/{grpc-D84KWgEK.js → grpc-atodrdN_.js} +6 -6
- package/dist/assets/{grpc-D84KWgEK.js.map → grpc-atodrdN_.js.map} +1 -1
- package/dist/assets/{index-Cd0m0XHc.js → index-DcnUq-w_.js} +6 -6
- package/dist/assets/{index-Cd0m0XHc.js.map → index-DcnUq-w_.js.map} +1 -1
- package/dist/index.html +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-
|
|
2
|
-
import{r as V2,a as q2,b as y,j as a,d as dd,H as Bo,P as Lo,i as L_,B as z_,c as $_,C as H_,M as P_,e as G2,f as Ic,h as F2,k as K2}from"./dagview-B70jDsRo.js";import{c as Z2,a as Sd,G as Y2,b as J2,d as W2,e as X2,p as Q2,f as ej,g as tj,h as nj,i as sj,M as aj,D as U_,A as V_,W as ij,O as oj,j as rj,C as Bs,k as Sm,l as q_,w as lj,t as cj,m as Oc,n as dj,R as Bc,S as gy}from"./grpc-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-D-BOXq5b.js","assets/dagview-B70jDsRo.js","assets/grpc-atodrdN_.js","assets/KnowledgePage-pdM88IVS.js","assets/markdown-CPoGw-1N.js","assets/KnowledgePage-CcVVrk7r.css","assets/SessionsListPage-CL-9RybL.js","assets/SessionsListPage-DXffE_Gw.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as V2,a as q2,b as y,j as a,d as dd,H as Bo,P as Lo,i as L_,B as z_,c as $_,C as H_,M as P_,e as G2,f as Ic,h as F2,k as K2}from"./dagview-B70jDsRo.js";import{c as Z2,a as Sd,G as Y2,b as J2,d as W2,e as X2,p as Q2,f as ej,g as tj,h as nj,i as sj,M as aj,D as U_,A as V_,W as ij,O as oj,j as rj,C as Bs,k as Sm,l as q_,w as lj,t as cj,m as Oc,n as dj,R as Bc,S as gy}from"./grpc-atodrdN_.js";import{v as uj,r as fj,t as Lc,i as pj,f as mj,M as jm,a as Tm}from"./markdown-CPoGw-1N.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();var Jf={exports:{}},zr={},Wf={exports:{}},Xf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
5
5
|
*
|
|
@@ -302,7 +302,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
302
302
|
`))??[],v=g.length>mp,b=c?o:g.slice(0,mp).join(`
|
|
303
303
|
`);let _="";if(s!=null)try{_=JSON.stringify(s,null,2)}catch{_=String(s)}return a.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardBlue} ${m?L.inProgress:""}`,"data-testid":"tool-card-generic",children:[a.jsxs("div",{className:L.header,children:[a.jsx("span",{className:L.icon,children:a.jsx(iT,{size:Pt,"aria-hidden":"true"})}),a.jsx("span",{className:L.toolName,style:{color:"var(--accent-blue)"},children:u}),p&&a.jsx("span",{className:L.fileName,children:p})]}),m&&_&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-args",children:_}),r&&o&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!m&&o&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:b}),v&&a.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{d(k=>!k)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[a.jsx("span",{className:`${L.chevron} ${c?L.chevronExpanded:""}`,"aria-hidden":"true",children:a.jsx(fa,{size:Ye})}),c?"collapse":`${g.length-mp} more lines`]})]})]})}const $A="_badgePill_1piak_1",HA="_modelBadge_1piak_14",PA="_backgroundBadge_1piak_26",UA="_backgroundDot_1piak_36",VA="_backgroundDotPulsing_1piak_41",qA="_viewActivity_1piak_55",GA="_description_1piak_74",FA="_statusLine_1piak_81",KA="_statusCompleted_1piak_91",ZA="_statusRunning_1piak_96",YA="_statusError_1piak_102",JA="_promptToggle_1piak_107",Xn={badgePill:$A,modelBadge:HA,backgroundBadge:PA,backgroundDot:UA,backgroundDotPulsing:VA,viewActivity:qA,description:GA,statusLine:FA,statusCompleted:KA,statusRunning:ZA,statusError:YA,promptToggle:JA},WA=/^Agent\s+(completed|running|failed|error)\.\s*agent_id:\s*(\S+),?\s*([^\n]*)(?:\n\n([\s\S]*))?$/i;function XA(t){const s=WA.exec(t);if(!s)return;const o=s[4];return{status:s[1].toLowerCase(),agentId:s[2].replace(/,$/,""),metadata:s[3].trim(),content:o?o.trim():void 0}}const hp=5;function QA({tool:t,args:s,result:o,isError:r,childSessionId:c}){const[d,u]=y.useState(!1),[p,m]=y.useState(!1),g=Q2(t,s),v=o===void 0,b=g.isPoll&&o?XA(o):void 0,_=(b==null?void 0:b.content)??o,k=(_==null?void 0:_.split(`
|
|
304
304
|
`))??[],S=k.length>hp,j=d?_:k.slice(0,hp).join(`
|
|
305
|
-
`),T=g.isPoll?"Subagent":"Agent";return a.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardTeal} ${v?L.inProgress:""}`,"data-testid":"tool-card-agent",children:[a.jsxs("div",{className:L.header,children:[a.jsx("span",{className:L.icon,style:{color:"var(--accent-teal, #2dd4bf)"},children:"▶"}),a.jsx("span",{className:L.toolName,style:{color:"var(--accent-teal, #2dd4bf)"},children:T}),g.agentType&&a.jsx("span",{className:Xn.badgePill,"data-testid":"tool-card-agent-type",children:g.agentType}),g.model&&a.jsx("span",{className:Xn.modelBadge,"data-testid":"tool-card-agent-model",children:g.model}),g.isBackground&&a.jsxs("span",{className:Xn.backgroundBadge,"data-testid":"tool-card-agent-background",children:[a.jsx("span",{className:v?Xn.backgroundDotPulsing:Xn.backgroundDot,children:"●"}),"BG"]}),g.agentName&&a.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-name",children:g.agentName}),g.agentId&&a.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-id",children:g.agentId}),a.jsx("span",{className:L.spacer}),c&&a.jsx(hl,{to:gl(c),className:Xn.viewActivity,"data-testid":"tool-card-agent-view-activity",children:"View activity →"}),v&&!g.isBackground&&a.jsx("span",{className:L.exitPending,"data-testid":"tool-card-pending",children:"●"})]}),g.description&&a.jsx("div",{className:Xn.description,"data-testid":"tool-card-agent-description",children:g.isResume?`Resuming: ${g.description}`:g.description}),b&&a.jsxs("div",{className:Xn.statusLine,"data-testid":"tool-card-agent-status",children:[a.jsx("span",{className:b.status==="completed"?Xn.statusCompleted:b.status==="running"?Xn.statusRunning:Xn.statusError,children:b.status}),b.metadata&&a.jsx("span",{children:b.metadata})]}),g.prompt&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:Xn.promptToggle,onClick:()=>{m(N=>!N)},"aria-expanded":p,"data-testid":"tool-card-prompt-toggle",children:[a.jsx("span",{className:`${L.chevron} ${p?L.chevronExpanded:""}`,children:"▸"}),"prompt"]}),p&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-prompt",children:g.prompt})]}),r&&o&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!v&&_&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:j}),S&&a.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{u(N=>!N)},"aria-expanded":d,"data-testid":"tool-card-toggle",children:[a.jsx("span",{className:`${L.chevron} ${d?L.chevronExpanded:""}`,children:"▸"}),d?"collapse":`${k.length-hp} more lines`]})]})]})}function gp(t){switch(rE(t.tool)){case"file-read":return a.jsx(By,{...t});case"file-edit":return a.jsx(FE,{...t});case"file-write":return a.jsx(By,{...t,writeVariant:!0});case"shell":return a.jsx(WE,{...t});case"search":return a.jsx(QE,{...t});case"todo":return a.jsx(yA,{...t});case"metadata":return a.jsx(_A,{...t});case"task":return a.jsx(jA,{...t});case"workpad":return a.jsx(wA,{...t});case"knowledge":return a.jsx(AA,{...t});case"ipc":return a.jsx(RA,{...t});case"tool-search":return a.jsx(OA,{...t});case"agent":return a.jsx(QA,{...t});default:return a.jsx(zA,{...t})}}const eD="_systemContextEvent_1oqvt_1",tD="_systemContextHeader_1oqvt_7",nD="_systemContextBadge_1oqvt_28",sD="_systemContextToggle_1oqvt_37",aD="_systemContextPre_1oqvt_43",iD="_systemContextEllipsis_1oqvt_54",oD="_systemEvent_1oqvt_58",rD="_systemTimestamp_1oqvt_65",lD="_textEvent_1oqvt_69",cD="_codeBlockWrapper_1oqvt_163",dD="_codeBlockCopyButton_1oqvt_166",uD="_errorEvent_1oqvt_170",fD="_statusEvent_1oqvt_178",pD="_userInputEvent_1oqvt_187",mD="_userInputContent_1oqvt_193",hD="_signalEvent_1oqvt_307",gD="_signalBadge_1oqvt_318",vD="_signalContent_1oqvt_327",yD="_usageEvent_1oqvt_332",bD="_usageBadge_1oqvt_339",_D="_defaultEvent_1oqvt_348",Ht={systemContextEvent:eD,systemContextHeader:tD,systemContextBadge:nD,systemContextToggle:sD,systemContextPre:aD,systemContextEllipsis:iD,systemEvent:oD,systemTimestamp:rD,textEvent:lD,codeBlockWrapper:cD,codeBlockCopyButton:dD,errorEvent:uD,statusEvent:fD,userInputEvent:pD,userInputContent:mD,signalEvent:hD,signalBadge:gD,signalContent:vD,usageEvent:yD,usageBadge:bD,defaultEvent:_D},$y=y.lazy(()=>Nm(()=>import("./McpAppWidget-
|
|
305
|
+
`),T=g.isPoll?"Subagent":"Agent";return a.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardTeal} ${v?L.inProgress:""}`,"data-testid":"tool-card-agent",children:[a.jsxs("div",{className:L.header,children:[a.jsx("span",{className:L.icon,style:{color:"var(--accent-teal, #2dd4bf)"},children:"▶"}),a.jsx("span",{className:L.toolName,style:{color:"var(--accent-teal, #2dd4bf)"},children:T}),g.agentType&&a.jsx("span",{className:Xn.badgePill,"data-testid":"tool-card-agent-type",children:g.agentType}),g.model&&a.jsx("span",{className:Xn.modelBadge,"data-testid":"tool-card-agent-model",children:g.model}),g.isBackground&&a.jsxs("span",{className:Xn.backgroundBadge,"data-testid":"tool-card-agent-background",children:[a.jsx("span",{className:v?Xn.backgroundDotPulsing:Xn.backgroundDot,children:"●"}),"BG"]}),g.agentName&&a.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-name",children:g.agentName}),g.agentId&&a.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-id",children:g.agentId}),a.jsx("span",{className:L.spacer}),c&&a.jsx(hl,{to:gl(c),className:Xn.viewActivity,"data-testid":"tool-card-agent-view-activity",children:"View activity →"}),v&&!g.isBackground&&a.jsx("span",{className:L.exitPending,"data-testid":"tool-card-pending",children:"●"})]}),g.description&&a.jsx("div",{className:Xn.description,"data-testid":"tool-card-agent-description",children:g.isResume?`Resuming: ${g.description}`:g.description}),b&&a.jsxs("div",{className:Xn.statusLine,"data-testid":"tool-card-agent-status",children:[a.jsx("span",{className:b.status==="completed"?Xn.statusCompleted:b.status==="running"?Xn.statusRunning:Xn.statusError,children:b.status}),b.metadata&&a.jsx("span",{children:b.metadata})]}),g.prompt&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:Xn.promptToggle,onClick:()=>{m(N=>!N)},"aria-expanded":p,"data-testid":"tool-card-prompt-toggle",children:[a.jsx("span",{className:`${L.chevron} ${p?L.chevronExpanded:""}`,children:"▸"}),"prompt"]}),p&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-prompt",children:g.prompt})]}),r&&o&&a.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!v&&_&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:j}),S&&a.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{u(N=>!N)},"aria-expanded":d,"data-testid":"tool-card-toggle",children:[a.jsx("span",{className:`${L.chevron} ${d?L.chevronExpanded:""}`,children:"▸"}),d?"collapse":`${k.length-hp} more lines`]})]})]})}function gp(t){switch(rE(t.tool)){case"file-read":return a.jsx(By,{...t});case"file-edit":return a.jsx(FE,{...t});case"file-write":return a.jsx(By,{...t,writeVariant:!0});case"shell":return a.jsx(WE,{...t});case"search":return a.jsx(QE,{...t});case"todo":return a.jsx(yA,{...t});case"metadata":return a.jsx(_A,{...t});case"task":return a.jsx(jA,{...t});case"workpad":return a.jsx(wA,{...t});case"knowledge":return a.jsx(AA,{...t});case"ipc":return a.jsx(RA,{...t});case"tool-search":return a.jsx(OA,{...t});case"agent":return a.jsx(QA,{...t});default:return a.jsx(zA,{...t})}}const eD="_systemContextEvent_1oqvt_1",tD="_systemContextHeader_1oqvt_7",nD="_systemContextBadge_1oqvt_28",sD="_systemContextToggle_1oqvt_37",aD="_systemContextPre_1oqvt_43",iD="_systemContextEllipsis_1oqvt_54",oD="_systemEvent_1oqvt_58",rD="_systemTimestamp_1oqvt_65",lD="_textEvent_1oqvt_69",cD="_codeBlockWrapper_1oqvt_163",dD="_codeBlockCopyButton_1oqvt_166",uD="_errorEvent_1oqvt_170",fD="_statusEvent_1oqvt_178",pD="_userInputEvent_1oqvt_187",mD="_userInputContent_1oqvt_193",hD="_signalEvent_1oqvt_307",gD="_signalBadge_1oqvt_318",vD="_signalContent_1oqvt_327",yD="_usageEvent_1oqvt_332",bD="_usageBadge_1oqvt_339",_D="_defaultEvent_1oqvt_348",Ht={systemContextEvent:eD,systemContextHeader:tD,systemContextBadge:nD,systemContextToggle:sD,systemContextPre:aD,systemContextEllipsis:iD,systemEvent:oD,systemTimestamp:rD,textEvent:lD,codeBlockWrapper:cD,codeBlockCopyButton:dD,errorEvent:uD,statusEvent:fD,userInputEvent:pD,userInputContent:mD,signalEvent:hD,signalBadge:gD,signalContent:vD,usageEvent:yD,usageBadge:bD,defaultEvent:_D},$y=y.lazy(()=>Nm(()=>import("./McpAppWidget-D-BOXq5b.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.McpAppWidget})));function Hy(t,s,o,r){if(!t||!s)return;const c=ej(o,r);if(c)return tj(t,nj(c,s))}const Py=3;function xD({content:t}){const[s,o]=y.useState(!1),r=t.split(`
|
|
306
306
|
`),c=r.length>Py,d=s?t:r.slice(0,Py).join(`
|
|
307
307
|
`);return a.jsxs("div",{className:Ht.systemContextEvent,"data-testid":"system-context-event",children:[a.jsxs("button",{type:"button",className:Ht.systemContextHeader,onClick:()=>{o(u=>!u)},"aria-expanded":s,children:[a.jsx("span",{className:Ht.systemContextBadge,children:"SYSTEM PROMPT"}),c&&a.jsx("span",{className:Ht.systemContextToggle,"aria-hidden":"true",children:s?a.jsx(F_,{size:Ye}):a.jsx(fa,{size:Ye})})]}),a.jsxs("pre",{className:Ht.systemContextPre,children:[d,!s&&c&&a.jsx("span",{className:Ht.systemContextEllipsis,children:"…"})]})]})}function kD({time:t,content:s}){return a.jsxs("div",{className:Ht.systemEvent,children:[a.jsxs("span",{className:Ht.systemTimestamp,children:["[",t,"]"]})," ",s]})}function Jp(t){return typeof t=="string"?t:typeof t=="number"?String(t):Array.isArray(t)?t.map(Jp).join(""):t!=null&&typeof t=="object"&&"props"in t?Jp(t.props.children):""}function SD({children:t,node:s,...o}){const r=Jp(t);return a.jsxs("div",{className:Ht.codeBlockWrapper,children:[a.jsx("pre",{...o,children:t}),a.jsx($C,{text:r,"data-testid":"copy-code-block",className:Ht.codeBlockCopyButton})]})}const jD={pre:SD};function xx({content:t}){return a.jsx(jm,{remarkPlugins:[Tm],rehypePlugins:[iE],components:jD,children:t})}function TD({content:t}){return a.jsx("div",{className:Ht.textEvent,children:a.jsx(xx,{content:t})})}function ND({content:t}){return a.jsxs("div",{className:Ht.errorEvent,children:["Error: ",t]})}function wD({content:t}){return a.jsxs("div",{className:Ht.statusEvent,children:["--- ",t," ---"]})}function CD({content:t}){return a.jsx("div",{className:Ht.userInputEvent,children:a.jsx("div",{className:Ht.userInputContent,"data-testid":"user-input-content",children:a.jsx(xx,{content:t})})})}function ED({content:t}){return a.jsxs("div",{className:Ht.signalEvent,"data-testid":"signal-event",children:[a.jsx("span",{className:Ht.signalBadge,children:"SIGNAL"}),a.jsx("span",{className:Ht.signalContent,children:t})]})}function AD({content:t}){let s=t;try{const o=JSON.parse(t),r=Number(o.input_tokens)||0,c=Number(o.output_tokens)||0,d=Ho(r+c),u=Ms(Number(o.cost_millicents)||0);s=`${d} tokens · ${u}`}catch{}return a.jsx("div",{className:Ht.usageEvent,"data-testid":"usage-event",children:a.jsx("span",{className:Ht.usageBadge,children:s})})}function Hr({content:t}){return a.jsx("div",{className:Ht.defaultEvent,children:t})}function DD({event:t,toolUseCtx:s,settled:o,sandboxProxyUrl:r}){const c=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"widget":{if(!r)return a.jsx(Hr,{content:t.content});let d={};try{d=JSON.parse(t.content)}catch{}const u=d.rendererKind??"mcp-app-html";if(u==="grackle-react"&&d.html){const m=`<!doctype html><html><head><meta charset="utf-8"></head><body><div id="grackle-root"></div><script type="module" src="${new URL(r,window.location.href).origin}/runtime.js"><\/script></body></html>`;return a.jsx(y.Suspense,{fallback:a.jsx(Hr,{content:"Loading widget..."}),children:a.jsx($y,{widgetHtml:m,sandboxProxyUrl:r,csp:d.csp,toolInput:{source:d.html,props:d.toolInput??{},components:d.components??[]}})})}return u!=="mcp-app-html"||!d.html?a.jsx(Hr,{content:t.content}):a.jsx(y.Suspense,{fallback:a.jsx(Hr,{content:"Loading widget..."}),children:a.jsx($y,{widgetHtml:d.html,sandboxProxyUrl:r,csp:d.csp,toolInput:d.toolInput,toolResult:d.toolResult})})}case"system":{if(t.raw)try{if(JSON.parse(t.raw).systemContext===!0)return a.jsx(xD,{content:t.content})}catch{}return a.jsx(kD,{time:c,content:t.content})}case"text":case"output":return a.jsx(TD,{content:t.content});case"tool_use":{let d="",u={};try{const p=JSON.parse(t.content);d=p.tool||"",u=p.args}catch{}return a.jsx(gp,{tool:d,args:u,result:o?"":void 0,childSessionId:Hy(t.sessionId,t.toolCallId,d,u)})}case"tool_result":{let d=t.toolError===!0;if(!d)try{JSON.parse(t.content).is_ok===!1&&(d=!0)}catch{}if(!d&&t.raw)try{d=JSON.parse(t.raw).is_error===!0}catch{}let u=t.content;if(t.content.trimStart().startsWith("{"))try{const p=JSON.parse(t.content);typeof p.content=="string"&&(u=p.content)}catch{}return s?a.jsx(gp,{tool:s.tool,args:s.args,result:u,isError:d,detailedResult:s.detailedResult,childSessionId:Hy(t.sessionId,t.toolCallId,s.tool,s.args)}):a.jsx(gp,{tool:"Tool output",args:void 0,result:u,isError:d})}case"error":return a.jsx(ND,{content:t.content});case"status":return a.jsx(wD,{content:t.content});case"user_input":return a.jsx(CD,{content:t.content});case"signal":return a.jsx(ED,{content:t.content});case"usage":return a.jsx(AD,{content:t.content});default:return a.jsx(Hr,{content:t.content})}}const Bm=y.createContext({});function Lm(t){const s=y.useRef(null);return s.current===null&&(s.current=t()),s.current}const Ad=y.createContext(null),zm=y.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class MD extends y.Component{getSnapshotBeforeUpdate(s){const o=this.props.childRef.current;if(o&&s.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=o.offsetHeight||0,r.width=o.offsetWidth||0,r.top=o.offsetTop,r.left=o.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function RD({children:t,isPresent:s}){const o=y.useId(),r=y.useRef(null),c=y.useRef({width:0,height:0,top:0,left:0}),{nonce:d}=y.useContext(zm);return y.useInsertionEffect(()=>{const{width:u,height:p,top:m,left:g}=c.current;if(s||!r.current||!u||!p)return;r.current.dataset.motionPopId=o;const v=document.createElement("style");return d&&(v.nonce=d),document.head.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
308
308
|
[data-motion-pop-id="${o}"] {
|
|
@@ -327,7 +327,7 @@ ${r.content}`);break}}}return s.join(`
|
|
|
327
327
|
|
|
328
328
|
${r}
|
|
329
329
|
|
|
330
|
-
--- End forwarded ---`}function AI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function DI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const MI="_wrapper_1cdza_1",RI="_scrollContainer_1cdza_9",II="_selectingPadding_1cdza_16",OI="_toolbar_1cdza_20",BI="_directionToggle_1cdza_27",LI="_scrollToAnchor_1cdza_65",zI="_scrollToAnchorBottom_1cdza_89",$I="_scrollToAnchorTop_1cdza_93",HI="_eventOverflowWarning_1cdza_97",oa={wrapper:MI,scrollContainer:RI,selectingPadding:II,toolbar:OI,directionToggle:BI,scrollToAnchor:LI,scrollToAnchorBottom:zI,scrollToAnchorTop:$I,eventOverflowWarning:HI},PI=10*1024,UI=new Set(["running","idle"]);function VI(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const ek="grackle-stream-direction";function qI(){try{return localStorage.getItem(ek)==="reversed"}catch{return!1}}function GI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(Cm,{size:Pt,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function vh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(qI),k=s6(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=DI({events:t,formatForClipboard:Q1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>UI.has(ce.status)&&ce.id!==d):[],[c,d]),B=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=NI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(ek,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const U=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),X=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),te=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),G=y.useCallback(async(ce,me)=>{if(!m)return;const xe=te(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,te,r,A]),ne=y.useCallback(ce=>{j(!1);const me=X(),xe=te(d),De=EI(xe,me);if(new TextEncoder().encode(De).length>PI){D({sessionId:ce,text:De}),N(!0);return}G(ce,De).catch(()=>{})},[X,te,d,G]),H=y.useCallback(()=>{N(!1),C&&(G(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,G]),O=y.useCallback(()=>{N(!1),D(void 0)},[]),q=k?0:.2,ge=b?-8:8,se=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ei,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(jy,{size:Pt,"aria-hidden":"true"}):a.jsx(Ty,{size:Pt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(GI,{eventsDropped:s}),a.jsx(os,{initial:!1,children:B.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Ut.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:q,ease:"easeOut"},children:a.jsx(F6,{copyText:CI(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:VI(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(DD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(os,{children:A.isSelecting&&a.jsx(tI,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{U().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(SI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ne,onCancel:()=>{j(!1)}}),a.jsx(bs,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${se} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:O}),a.jsx(os,{children:!M&&a.jsxs(Ut.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?a.jsx(Ty,{size:Pt,"aria-hidden":"true"}):a.jsx(jy,{size:Pt,"aria-hidden":"true"})," ","New events"]})})]})}function hm(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function tk(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function Ap(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const FI=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function nk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Ap(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Ap(t)};default:return{varName:"--text-tertiary",label:t.length>0?Ap(t):"Unknown"}}}function yh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(B=>{v(B),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const B=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(B===M){N();return}o(B),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(B=>{if(k.current){k.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(B=>{B.key==="Escape"?N():B.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const B=m?s.trim():s;return(m?g.trim():g)!==B})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const KI="_editFieldWrapper_yuzty_1",ZI="_editInput_yuzty_10",YI="_editTextarea_yuzty_42",JI="_editSelect_yuzty_78",WI="_editError_yuzty_111",XI="_editInputInvalid_yuzty_118",QI="_editHint_yuzty_123",e5="_unsavedDot_yuzty_132",t5="_metaValueClickable_yuzty_140",n5="_editButton_yuzty_159",s5="_metaPlaceholder_yuzty_175",a5="_worktreeToggle_yuzty_180",it={editFieldWrapper:KI,editInput:ZI,editTextarea:YI,editSelect:JI,editError:WI,editInputInvalid:XI,editHint:QI,unsavedDot:e5,metaValueClickable:t5,editButton:n5,metaPlaceholder:s5,worktreeToggle:a5};function $t(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),j=yh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function gm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=yh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function xd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=yh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function i5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const o5="_nav_1snmp_1",r5="_searchForm_1snmp_8",l5="_searchInput_1snmp_15",c5="_searchButton_1snmp_33",d5="_clearButton_1snmp_68",u5="_workspaceSelect_1snmp_85",f5="_listHeader_1snmp_99",p5="_nodeList_1snmp_108",m5="_nodeItem_1snmp_116",h5="_indicator_1snmp_129",g5="_label_1snmp_136",v5="_badge_1snmp_145",es={nav:o5,searchForm:r5,searchInput:l5,searchButton:c5,clearButton:d5,workspaceSelect:u5,listHeader:f5,nodeList:p5,nodeItem:m5,indicator:h5,label:g5,badge:v5};function y5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:es.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:es.searchForm,onSubmit:v,children:[a.jsx("input",{className:es.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:es.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:es.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:es.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:es.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:es.nodeList,children:t.map(S=>a.jsxs("li",{className:es.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:es.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:es.label,children:S.label}),a.jsx("span",{className:es.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const b5="_container_bwu10_1",_5="_hamburger_bwu10_33",x5="_brand_bwu10_49",k5="_brandLogo_bwu10_68",S5="_info_bwu10_75",j5="_connectionLabel_bwu10_90",T5="_connectionDot_bwu10_103",N5="_connected_bwu10_106",w5="_disconnected_bwu10_110",C5="_connecting_bwu10_113",Ds={container:b5,hamburger:_5,brand:x5,brandLogo:k5,info:S5,connectionLabel:j5,connectionDot:T5,connected:N5,disconnected:w5,connecting:C5},E5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},A5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function D5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=E5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(BT,{size:Tt,"aria-hidden":"true"})}),a.jsx(Ei,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Bd("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${A5[t]}`,"aria-hidden":"true",children:a.jsx(wi,{size:Z_,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const M5="_nav_gx5h3_1",R5="_tab_gx5h3_35",I5="_tabIcon_gx5h3_68",O5="_tabLabel_gx5h3_79",B5="_tabActive_gx5h3_84",L5="_tabEnd_gx5h3_90",wo={nav:M5,tab:R5,tabIcon:I5,tabLabel:O5,tabActive:B5,tabEnd:L5},od=[{view:"dashboard",label:"Dashboard",icon:a.jsx(ST,{size:Tt}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(nT,{size:Tt}),route:yC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(UT,{size:Tt}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(zT,{size:Tt}),route:vC,testId:"sidebar-tab-chat",order:3},{view:"sessions",label:"Sessions",icon:a.jsx(Uj,{size:Tt}),route:vx,testId:"sidebar-tab-sessions",order:4},{view:"knowledge",label:"Knowledge",icon:a.jsx(Zj,{size:Tt}),route:bx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(qT,{size:Tt}),route:gx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(sN,{size:Tt}),route:fC,testId:"sidebar-tab-settings",align:"end"}];function z5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(gx)?"coordination":t.startsWith(vx)?"sessions":t.startsWith("/chat")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(bx)?"knowledge":t.startsWith(Ti)?"settings":"tasks"}function $5({tabs:t=od}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=z5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ei,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const H5="_container_pi6ii_1",P5="_content_pi6ii_66",o_={container:H5,content:P5},U5=320,sk=220,ak=600,ik="grackle-sidebar-width";function V5(){try{const t=localStorage.getItem(ik);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=sk&&s<=ak)return s}}catch{}return U5}function q5(t){try{localStorage.setItem(ik,String(t))}catch{}}function G5({content:t}){const[s]=y.useState(V5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=sk&&m<=ak&&q5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:o_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:o_.content,children:t})})}const F5="_bar_tnfsh_1",K5="_btnPrimary_tnfsh_32",Z5="_statusText_tnfsh_85",Y5="_statusCompleted_tnfsh_90",J5="_statusFailed_tnfsh_94",W5="_statusBlocked_tnfsh_98",X5="_hintText_tnfsh_103",At={bar:F5,btnPrimary:K5,statusText:Z5,statusCompleted:Y5,statusFailed:J5,statusBlocked:W5,hintText:X5};function Q5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=sn("/sessions/:sessionId"),u=sn("/tasks/:taskId"),p=sn("/tasks/:taskId/stream"),m=sn("/tasks/:taskId/edit"),g=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=sn("/sessions/new"),k=sn("/environments/:environmentId/workspaces/:workspaceId"),S=sn("/tasks/new"),j=sn("/chat"),T=sn("/"),N=sn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,B=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(B)return o.find(ne=>ne.adapterType==="local"&&ne.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Select a task or click + to create one"})});if(D){const G=s.find(O=>O.id===D);if(!G)return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Loading..."})});const ne=new Map(s.map(O=>[O.id,O])),H=G.dependsOn.some(O=>{const q=ne.get(O);return q!==void 0&&q.status!=="complete"});if(G.status==="not_started"){const O=H?G.dependsOn.map(q=>ne.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:At.bar,children:H?a.jsxs("span",{className:At.statusBlocked,children:["Blocked by: ",O.join(", ")]}):a.jsx("span",{className:At.hintText,children:"Use the buttons above to start or manage this task"})})}if(G.status==="working"||G.status==="paused"){const O=G.latestSessionId||void 0,q=O?t.find(se=>se.id===O):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Waiting for agent..."})})}if(G.status==="complete")return a.jsxs("div",{className:At.bar,children:[a.jsx("span",{className:`${At.statusText} ${At.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ii(G.workspaceId,void 0,E)),className:At.btnPrimary,children:"+ New Task"})]});if(G.status==="failed")return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:`${At.statusText} ${At.statusFailed}`,children:"Task failed"})})}if(C){const G=t.find(O=>O.id===C),ne=(G==null?void 0:G.status)==="stopped";if(G!==void 0&&!ne)return a.jsx(a.Fragment,{});if(ne)return a.jsxs("div",{className:At.bar,children:[a.jsxs("span",{className:`${At.statusText} ${At.hintText}`,children:["Session ",G.endReason||G.status]}),a.jsx("button",{onClick:()=>r(px(G.environmentId)),className:At.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Loading..."})})}const eO="_nav_14i94_1",tO="_tab_14i94_24",nO="_tabActive_14i94_62",sO="_tabLabel_14i94_75",aO="_statusDot_14i94_81",iO="_pulse_14i94_87",oO="_addButton_14i94_99",rO="_empty_14i94_132",Va={nav:eO,tab:tO,tabActive:nO,tabLabel:sO,statusDot:aO,pulse:iO,addButton:oO,empty:rO},lO={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function cO({environments:t}){const s=xt(),o=y.useRef(null),r=sn("/environments/:environmentId"),c=sn("/environments/:environmentId/edit"),d=sn("/environments/:environmentId/workspaces/:workspaceId"),u=sn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Va.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=lO[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Va.tab} ${k?Va.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Va.statusDot} ${T?Va.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(wi,{size:Z_,fill:"currentColor"})}),a.jsx("span",{className:Va.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Va.addButton,onClick:()=>s(dC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Va.empty,children:"No environments yet."})]})}function dO(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function ok({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=dO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function uO(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function fO(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of mN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const pO="_container_z4i38_1",mO="_header_z4i38_5",hO="_headerActions_z4i38_17",gO="_searchInput_z4i38_23",vO="_searchHighlight_z4i38_56",yO="_groupToggle_z4i38_62",bO="_groupToggleActive_z4i38_89",_O="_addButton_z4i38_93",xO="_taskRow_z4i38_120",kO="_selected_z4i38_140",SO="_expandArrow_z4i38_150",jO="_expanded_z4i38_157",TO="_leafSpacer_z4i38_161",NO="_taskStatusIcon_z4i38_166",wO="_taskTitle_z4i38_170",CO="_workspaceBadge_z4i38_177",EO="_childCountBadge_z4i38_195",AO="_dependencyBadge_z4i38_208",DO="_blockedBadge_z4i38_220",MO="_addChildButton_z4i38_225",RO="_emptyState_z4i38_268",IO="_statusGroupHeader_z4i38_275",OO="_statusGroupIcon_z4i38_294",BO="_statusGroupLabel_z4i38_298",LO="_statusGroupCount_z4i38_303",We={container:pO,header:mO,headerActions:hO,searchInput:gO,searchHighlight:vO,groupToggle:yO,groupToggleActive:bO,addButton:_O,taskRow:xO,selected:kO,expandArrow:SO,expanded:jO,leafSpacer:TO,taskStatusIcon:NO,taskTitle:wO,workspaceBadge:CO,childCountBadge:EO,dependencyBadge:AO,blockedBadge:DO,addChildButton:MO,emptyState:RO,statusGroupHeader:IO,statusGroupIcon:OO,statusGroupLabel:BO,statusGroupCount:LO},zO=[{name:"title",weight:2},{name:"description",weight:1}],rk=16,$O=16,lk="grackle-task-group-by-status";function r_(){try{return localStorage.getItem(lk)==="true"}catch{return!1}}function HO(t){try{localStorage.setItem(lk,String(t))}catch{}}function PO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(fa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(os,{children:s&&a.jsx(Ut.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=Ja(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(ls(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(ls(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${rk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(ok,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ck({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ja(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=rk+s*$O,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(ls(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(ls(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(fa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(ok,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<aj&&a.jsx(Ei,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(os,{children:_&&b&&a.jsx(Ut.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(N=>a.jsx(ck,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function UO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(r_),[g,v]=y.useState(r_),[b,_]=y.useState(new Map),k=sn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(G=>[G.id,G.status])),[s]),T=y.useMemo(()=>new Map(t.map(G=>[G.id,G.name])),[t]),N=()=>{const G=!p;HO(G),m(G),G&&(v(!0),_(new Map))},C=G=>{_(ne=>{const H=new Map(ne),O=H.has(G)?H.get(G):g;return H.set(G,!O),H})},D=G=>b.has(G)?b.get(G):g,A=G=>{c(ne=>{const H=new Set(ne);return H.has(G)?(H.delete(G),u(O=>new Set(O).add(G))):(H.add(G),u(O=>{const q=new Set(O);return q.delete(G),q})),H})};y.useEffect(()=>{const G=new Set(s.filter(ne=>ne.parentTaskId).map(ne=>ne.parentTaskId));G.size>0&&c(ne=>{const H=new Set(ne);for(const O of G)d.has(O)||H.add(O);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:B,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const G=sj(s,E,zO),ne=new Set(G.map(ge=>ge.item.id)),H=new Map;for(const ge of G){const se=ge.matches.find(ce=>ce.key==="title");se&&H.set(ge.item.id,se.indices)}const O=new Set(ne),q=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ne]){let se=q.get(ge);for(;se!=null&&se.parentTaskId;)O.add(se.parentTaskId),se=q.get(se.parentTaskId)}return{directMatchTaskIds:ne,treeMatchTaskIds:O,titleHighlights:H}},[E,s]),Y=B!==null,U=Y?p?B:M:null,X=U?s.filter(G=>U.has(G.id)):s,te=p?[]:uO(X);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ei,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(MT,{size:Pt})})}),a.jsx(Ei,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:G=>R(G.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?fO(X,j).map(G=>a.jsx(PO,{group:G,isExpanded:D(G.status),onToggle:()=>C(G.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},G.status)):te.map(G=>a.jsx(ck,{node:G,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},G.id)),X.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),X.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const VO="_toast_ed2dk_1",qO="_success_ed2dk_18",GO="_icon_ed2dk_22",FO="_error_ed2dk_25",KO="_warning_ed2dk_32",ZO="_info_ed2dk_38",YO="_message_ed2dk_53",JO="_close_ed2dk_60",qr={toast:VO,success:qO,icon:GO,error:FO,warning:KO,info:ZO,message:YO,close:JO},WO={success:a.jsx(Di,{size:Tt}),error:a.jsx(Ls,{size:Tt}),warning:a.jsx(Cm,{size:Tt}),info:a.jsx(wm,{size:Tt})};function XO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ut.div,{className:`${qr.toast} ${qr[t.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:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:WO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})}const QO="_container_qqse2_1",eB={container:QO};function tB({toasts:t,onDismiss:s}){return a.jsx("div",{className:eB.container,"data-testid":"toast-container",children:a.jsx(os,{children:t.map(o=>a.jsx(XO,{toast:o,onDismiss:s},o.id))})})}const nB="_callout_e5awm_1",sB="_success_e5awm_11",aB="_icon_e5awm_15",iB="_error_e5awm_18",oB="_warning_e5awm_25",rB="_info_e5awm_32",lB="_content_e5awm_48",cB="_close_e5awm_53",Gr={callout:nB,success:sB,icon:aB,error:iB,warning:oB,info:rB,content:lB,close:cB},dB={success:a.jsx(Di,{size:Tt}),error:a.jsx(Ls,{size:Tt}),warning:a.jsx(Cm,{size:Tt}),info:a.jsx(wm,{size:Tt})};function uB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:dB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})})}function fB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(uB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,"). Run:"," ",a.jsx("code",{children:c})]})})}const pB="_container_m1fsr_1",mB="_heading_m1fsr_7",hB="_section_m1fsr_14",gB="_sectionTitle_m1fsr_26",vB="_sectionDescription_m1fsr_35",yB="_emptyState_m1fsr_41",bB="_tokenList_m1fsr_48",_B="_tokenRow_m1fsr_55",xB="_tokenBadge_m1fsr_68",kB="_tokenName_m1fsr_83",SB="_tokenTarget_m1fsr_90",jB="_deleteButton_m1fsr_99",TB="_addForm_m1fsr_113",NB="_formRow_m1fsr_119",wB="_input_m1fsr_125",CB="_select_m1fsr_155",EB="_addButton_m1fsr_187",AB="_emptyStateInfo_m1fsr_221",DB="_themeOptions_m1fsr_229",MB="_themeOption_m1fsr_229",RB="_themeOptionSelected_m1fsr_254",IB="_themeOptionHeader_m1fsr_259",OB="_themeOptionLabel_m1fsr_266",BB="_themeOptionDesc_m1fsr_273",LB="_variantToggle_m1fsr_279",zB="_variantButton_m1fsr_286",$B="_variantActive_m1fsr_305",HB="_themeSwatches_m1fsr_311",PB="_themeSwatch_m1fsr_311",UB="_systemToggle_m1fsr_325",VB="_systemToggleHint_m1fsr_341",qB="_themeActive_m1fsr_348",GB="_aboutGrid_m1fsr_354",FB="_aboutItem_m1fsr_360",KB="_aboutLabel_m1fsr_373",ZB="_aboutValue_m1fsr_379",YB="_aboutDot_m1fsr_387",JB="_aboutDotConnected_m1fsr_394",WB="_aboutDotDisconnected_m1fsr_398",XB="_aboutDotConnecting_m1fsr_402",fe={container:pB,heading:mB,section:hB,sectionTitle:gB,sectionDescription:vB,emptyState:yB,tokenList:bB,tokenRow:_B,tokenBadge:xB,tokenName:kB,tokenTarget:SB,deleteButton:jB,addForm:TB,formRow:NB,input:wB,select:CB,addButton:EB,emptyStateInfo:AB,themeOptions:DB,themeOption:MB,themeOptionSelected:RB,themeOptionHeader:IB,themeOptionLabel:OB,themeOptionDesc:BB,variantToggle:LB,variantButton:zB,variantActive:$B,themeSwatches:HB,themeSwatch:PB,systemToggle:UB,systemToggleHint:VB,themeActive:qB,aboutGrid:GB,aboutItem:FB,aboutLabel:KB,aboutValue:ZB,aboutDot:YB,aboutDotConnected:JB,aboutDotDisconnected:WB,aboutDotConnecting:XB},QB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function eL({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=N=>{if(N.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:QB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ld=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],dk=new Set(Ld.map(t=>t.id)),l_="grackle";function vm(t){return Ld.find(s=>s.id===t)}function tL({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Ld.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const nL={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},sL={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function aL({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${sL[t]}`}),nL[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.136.0"})]})]})]})}const iL="_container_cddyd_1",oL="_header_cddyd_8",rL="_headerTitle_cddyd_35",lL="_badge_cddyd_44",cL="_headerActions_cddyd_54",dL="_body_cddyd_61",uL="_formContent_cddyd_73",fL="_section_cddyd_85",pL="_label_cddyd_91",mL="_titleInput_cddyd_98",hL="_descriptionTextarea_cddyd_131",gL="_parentContext_cddyd_167",vL="_parentLabel_cddyd_175",yL="_parentName_cddyd_182",bL="_personaSelect_cddyd_186",_L="_depList_cddyd_220",xL="_depItem_cddyd_226",kL="_depItemSelected_cddyd_248",SL="_noDeps_cddyd_252",jL="_btnPrimary_cddyd_258",TL="_btnGhost_cddyd_289",Qe={container:iL,header:oL,headerTitle:rL,badge:lL,headerActions:cL,body:dL,formContent:uL,section:fL,label:pL,titleInput:mL,descriptionTextarea:hL,parentContext:gL,parentLabel:vL,parentName:yL,personaSelect:bL,depList:_L,depItem:xL,depItemSelected:kL,noDeps:SL,btnPrimary:jL,btnGhost:TL};function uk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",B=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,U]=y.useState((S==null?void 0:S.description)??""),[X,te]=y.useState((S==null?void 0:S.dependsOn)??[]),[G,ne]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,O]=y.useState((S==null?void 0:S.canDecompose)??!1),[q,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[se,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),U(S.description),te(S.dependsOn),ne(S.defaultPersonaId),O(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{te(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||se||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,X,G),b==null||b("Task updated","success"),v?v():_(ls(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,X.length>0?X:void 0,R||void 0,G,H,q,()=>{b==null||b("Task created","success"),_(o?Ci(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?ls(s,void 0,C,A):o?Ci(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),B&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:B.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||se,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>U(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:G,onChange:ke=>ne(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>O(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:q,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=X.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const NL="_actionButtons_1rjka_1",wL="_btnPrimary_1rjka_8",CL="_btnDanger_1rjka_39",EL="_btnGhost_1rjka_78",Yt={actionButtons:NL,btnPrimary:wL,btnDanger:CL,btnGhost:EL},AL=new Set(["stopped","suspended"]);function DL({task:t,sessionId:s,latestSessionStatus:o,isBlocked:r,onStart:c,onResume:d,onStop:u,onPause:p,onDelete:m,onEdit:g}){if(t.status==="not_started")return r?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:c,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:p,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused"){const v=o!==void 0&&AL.has(o);return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),v&&a.jsx("button",{onClick:d,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:c,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const ML="_workpadSection_y8nj9_1",RL="_workpadLabel_y8nj9_9",IL="_workpadStatus_y8nj9_17",OL="_workpadSummary_y8nj9_23",BL="_workpadExtra_y8nj9_29",qa={workpadSection:ML,workpadLabel:RL,workpadStatus:IL,workpadSummary:OL,workpadExtra:BL};function LL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),a.jsx("div",{className:qa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:qa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:qa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:qa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const zL="_overviewDashboard_ng7kf_1",$L="_overviewHero_ng7kf_7",HL="_statusBadge_ng7kf_14",PL="_statusPending_ng7kf_26",UL="_statusAssigned_ng7kf_31",VL="_statusInProgress_ng7kf_36",qL="_statusReview_ng7kf_41",GL="_statusDone_ng7kf_46",FL="_statusFailed_ng7kf_51",KL="_statusWaitingInput_ng7kf_56",ZL="_overviewBranchPill_ng7kf_61",YL="_branchLink_ng7kf_76",JL="_overviewSection_ng7kf_87",WL="_overviewLabel_ng7kf_93",XL="_overviewValue_ng7kf_100",QL="_overviewMuted_ng7kf_105",e8="_overviewMarkdown_ng7kf_111",t8="_envRow_ng7kf_186",n8="_envDot_ng7kf_192",s8="_envDotGreen_ng7kf_199",a8="_envDotYellow_ng7kf_203",i8="_envDotRed_ng7kf_207",o8="_envDotGray_ng7kf_211",r8="_depList_ng7kf_215",l8="_depItem_ng7kf_221",c8="_depBlocked_ng7kf_228",d8="_depDone_ng7kf_232",u8="_timeline_ng7kf_236",f8="_timelineRow_ng7kf_242",p8="_timelineKey_ng7kf_249",m8="_timelineValue_ng7kf_255",h8="_timelineDelta_ng7kf_259",g8="_reviewNotes_ng7kf_270",be={overviewDashboard:zL,overviewHero:$L,statusBadge:HL,statusPending:PL,statusAssigned:UL,statusInProgress:VL,statusReview:qL,statusDone:GL,statusFailed:FL,statusWaitingInput:KL,overviewBranchPill:ZL,branchLink:YL,overviewSection:JL,overviewLabel:WL,overviewValue:XL,overviewMuted:QL,overviewMarkdown:e8,envRow:t8,envDot:n8,envDotGreen:s8,envDotYellow:a8,envDotRed:i8,envDotGray:o8,depList:r8,depItem:l8,depBlocked:c8,depDone:d8,timeline:u8,timelineRow:f8,timelineKey:p8,timelineValue:m8,timelineDelta:h8,reviewNotes:g8};function Kc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Dp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function c_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function v8({status:t}){const s=Ja(t),o=pN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function y8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(v8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(jm,{remarkPlugins:[Tm],children:t.description})})]}),t.workpad&&a.jsx(LL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Dp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Dp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Dp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," /"," ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," /"," ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function b8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function _8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},B=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(rN,{size:Pt,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{B().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const x8="_container_legrg_1",k8="_header_legrg_8",S8="_headerTitle_legrg_35",j8="_badge_legrg_44",T8="_headerActions_legrg_54",N8="_body_legrg_61",w8="_formContent_legrg_73",C8="_section_legrg_85",E8="_label_legrg_91",A8="_nameInput_legrg_98",D8="_fieldInput_legrg_131",M8="_adapterSelect_legrg_164",R8="_readOnlyValue_legrg_198",I8="_codespaceSection_legrg_204",O8="_codespaceActions_legrg_210",B8="_creatingHint_legrg_216",L8="_errorHint_legrg_222",z8="_btnPrimary_legrg_235",$8="_btnGhost_legrg_266",re={container:x8,header:k8,headerTitle:S8,badge:j8,headerActions:T8,body:N8,formContent:w8,section:C8,label:E8,nameInput:A8,fieldInput:D8,adapterSelect:M8,readOnlyValue:R8,codespaceSection:I8,codespaceActions:O8,creatingHint:B8,errorHint:L8,btnPrimary:z8,btnGhost:$8},rd=1,ld=65535;function Mp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=rd&&s<=ld}function Rp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function H8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:re.codespaceSection,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:re.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:re.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:re.codespaceSection,children:a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:re.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:re.errorHint,children:d})]})})}function fk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(le=>le.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[B,M]=y.useState(""),[$,Y]=y.useState(""),[U,X]=y.useState(""),[te,G]=y.useState(""),[ne,H]=y.useState(""),[O,q]=y.useState(""),[ge,se]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const le={};if(E==="local"){if(B.trim()&&(le.host=B.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.port=ve)}}else if(E==="ssh"){if(le.host=B.trim(),U.trim()&&(le.user=U.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.sshPort=ve)}te.trim()&&(le.identityFile=te.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(le.attach=ot.trim()):(ne.trim()&&(le.image=ne.trim()),O.trim()&&(le.repo=O.trim())):E==="codespace"&&(le.codespaceName=ge.trim());return le},[E,B,$,U,te,ne,O,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!B.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Mp($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Ie=()=>{T(s?$o(s):zo)},ee=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Rp(C.adapterConfig),on=ve.trim();on?et[le]=on:delete et[le],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Rp(C.adapterConfig);if(ve.trim()){const on=Number(ve);Number.isInteger(on)&&on>=rd&&on<=ld&&(et[le]=on)}else delete et[le];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:re.container,children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Ie,className:re.btnGhost,children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsx("div",{className:re.formContent,children:a.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const le=Rp(C.adapterConfig);return a.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Ie,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Name"}),a.jsx($t,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Adapter Type"}),a.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:re.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Port"}),a.jsx($t,{value:String(le.port??""),onSave:ve=>nt("port",ve),validate:ve=>Mp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"User"}),a.jsx($t,{value:String(le.user??""),onSave:ve=>ee("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"SSH Port"}),a.jsx($t,{value:String(le.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Mp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Identity File"}),a.jsx($t,{value:String(le.identityFile??""),onSave:ve=>ee("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&le.attach!==void 0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Attach (container)"}),a.jsx($t,{value:String(le.attach??""),onSave:ve=>ee("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&le.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Image"}),a.jsx($t,{value:String(le.image??""),onSave:ve=>ee("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repo"}),a.jsx($t,{value:String(le.repo??""),onSave:ve=>ee("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace Name"}),a.jsx($t,{value:String(le.codespaceName??""),onSave:ve=>ee("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"new environment"})}),a.jsxs("div",{className:re.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ie,className:re.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:le=>A(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:le=>{R(le.target.value),le.target.value==="codespace"&&u(ce||void 0)},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:le=>{me(le.target.value),E==="codespace"&&u(le.target.value||void 0)},className:re.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(le=>a.jsxs("option",{value:le.id,children:[le.label," (@",le.username,")",le.isDefault?" — default":""]},le.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:rd,max:ld,value:$,onChange:le=>Y(le.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:le=>X(le.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:rd,max:ld,value:$,onChange:le=>Y(le.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:te,onChange:le=>G(le.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:le=>{const ve=le.target.value;De(ve),ve==="attach"&&_()},className:re.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:ne,onChange:le=>H(le.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:O,onChange:le=>q(le.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},className:re.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(le=>a.jsxs("option",{value:le.name,children:[le.name," (",le.image,") ",le.status]},le.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:re.errorHint,children:S}):a.jsx("span",{className:re.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},placeholder:"Enter container name/ID...",className:re.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(H8,{codespaceName:ge,onCodespaceNameChange:se,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const P8="_group_1iprv_1",U8="_groupTitle_1iprv_8",V8="_shortcutList_1iprv_17",q8="_shortcutRow_1iprv_23",G8="_keys_1iprv_36",F8="_kbd_1iprv_43",K8="_description_1iprv_60",xi={group:P8,groupTitle:U8,shortcutList:V8,shortcutRow:q8,keys:G8,kbd:F8,description:K8},Z8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function Y8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),Z8.map(t=>a.jsxs("div",{className:xi.group,children:[a.jsx("h4",{className:xi.groupTitle,children:t.title}),a.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:xi.shortcutRow,children:[a.jsx("span",{className:xi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:xi.kbd,children:o},o))}),a.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const J8=[{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"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function W8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.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."}),a.jsx("div",{className:fe.tokenList,children:J8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const X8="_container_10efq_1",Q8="_header_10efq_7",e7="_list_10efq_105",t7="_card_10efq_111",n7="_cardHeader_10efq_125",s7="_cardTitle_10efq_135",a7="_defaultBadge_10efq_141",i7="_cardActions_10efq_155",o7="_description_10efq_160",r7="_meta_10efq_166",l7="_empty_10efq_212",c7="_typeBadge_10efq_362",ts={container:X8,header:Q8,list:e7,card:t7,cardHeader:n7,cardTitle:s7,defaultBadge:a7,cardActions:i7,description:o7,meta:r7,empty:l7,typeBadge:c7};function d7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ts.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ts.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:ts.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ts.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:ts.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ts.description,children:v.description}),a.jsxs("div",{className:ts.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(bs,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const u7="_container_uy08i_1",f7="_header_uy08i_7",p7="_count_uy08i_13",m7="_presets_uy08i_18",h7="_presetButton_uy08i_24",g7="_filterInput_uy08i_41",v7="_groups_uy08i_53",y7="_group_uy08i_53",b7="_groupHeader_uy08i_68",_7="_groupName_uy08i_77",x7="_groupCount_uy08i_81",k7="_toolList_uy08i_87",S7="_toolItem_uy08i_95",j7="_toolName_uy08i_103",bn={container:u7,header:f7,count:p7,presets:m7,presetButton:h7,filterInput:g7,groups:v7,group:y7,groupHeader:b7,groupName:_7,groupCount:x7,toolList:k7,toolItem:S7,toolName:j7},T7=(()=>{const t=new Map;for(const s of V_){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),N7=[{name:"default",label:"Default",tools:U_},{name:"worker",label:"Worker",tools:ij},{name:"orchestrator",label:"Orchestrator",tools:oj},{name:"admin",label:"Admin",tools:rj}];function d_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:bn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:bn.header,children:a.jsx("span",{className:bn.count,children:t.length===0?`Using default (${U_.length} tools)`:`${t.length} of ${V_.size} tools selected`})}),a.jsxs("div",{className:bn.presets,"data-testid":"mcp-tool-presets",children:[N7.map(v=>a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:bn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:bn.groups,children:T7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:bn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:bn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:bn.groupName,children:v}),a.jsxs("span",{className:bn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:bn.toolList,children:_.map(S=>a.jsxs("label",{className:bn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:bn.toolName,children:S})]},S))})]},v)})})]})}const w7="_container_1gfuq_1",C7="_header_1gfuq_7",E7="_list_1gfuq_19",A7="_card_1gfuq_25",D7="_cardHeader_1gfuq_40",M7="_cardTitle_1gfuq_46",R7="_statusBadge_1gfuq_56",I7="_enabled_1gfuq_68",O7="_disabled_1gfuq_71",B7="_cardActions_1gfuq_75",L7="_cardMeta_1gfuq_80",z7="_empty_1gfuq_98",ns={container:w7,header:C7,list:E7,card:A7,cardHeader:D7,cardTitle:M7,statusBadge:R7,enabled:I7,disabled:O7,cardActions:B7,cardMeta:L7,empty:z7};function $7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ns.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ns.list,children:t.map(_=>a.jsxs("div",{className:ns.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ns.statusBadge} ${_.enabled?ns.enabled:ns.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ns.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ns.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?hm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",tk(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(bs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const H7="_nav_1bhou_1",P7="_tab_1bhou_24",U7="_tabIcon_1bhou_62",V7="_tabActive_1bhou_68",Zc={nav:H7,tab:P7,tabIcon:U7,tabActive:V7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(NT,{size:Tt})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(bT,{size:Tt})},{path:"personas",label:"Personas",icon:a.jsx(dN,{size:Tt})},{path:"schedules",label:"Schedules",icon:a.jsx(Jj,{size:Tt})},{path:"appearance",label:"Appearance",icon:a.jsx(FT,{size:Tt})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(CT,{size:Tt})},{path:"plugins",label:"Plugins",icon:a.jsx(XT,{size:Tt})},{path:"about",label:"About",icon:a.jsx(wm,{size:Tt})}];function q7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ti}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ti}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${Ti}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const G7=["lifecycle:","pipe:","stdin:"];function bh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function pk(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function F7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=pk(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const K7="_container_16qkd_1",Z7="_header_16qkd_7",Y7="_title_16qkd_15",J7="_headerActions_16qkd_21",W7="_internalsToggle_16qkd_27",X7="_refreshButton_16qkd_37",Q7="_state_16qkd_52",ez="_group_16qkd_59",tz="_groupHeader_16qkd_63",nz="_row_16qkd_72",sz="_selected_16qkd_92",az="_kindBadge_16qkd_96",iz="_kindChatroom_16qkd_108",oz="_kindPipe_16qkd_114",rz="_kindChannel_16qkd_120",lz="_streamName_16qkd_126",cz="_meta_16qkd_135",Jt={container:K7,header:Z7,title:Y7,headerActions:J7,internalsToggle:W7,refreshButton:X7,state:Q7,group:ez,groupHeader:tz,row:nz,selected:sz,kindBadge:az,kindChatroom:iz,kindPipe:oz,kindChannel:rz,streamName:lz,meta:cz},dz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function uz({kind:t}){return t==="chatroom"?a.jsx(HT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(vT,{size:Ye,"aria-hidden":"true"}):a.jsx(xT,{size:Ye,"aria-hidden":"true"})}function fz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=F7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(eN,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=bh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(uz,{kind:N})," ",dz[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const pz="_transcript_1p4cm_1",mz="_message_1p4cm_10",hz="_meta_1p4cm_16",gz="_sender_1p4cm_24",vz="_time_1p4cm_29",yz="_content_1p4cm_34",bz="_state_1p4cm_42",Ga={transcript:pz,message:mz,meta:hz,sender:gz,time:vz,content:yz,state:bz};function _z(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function xz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:Ga.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:Ga.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:Ga.meta,children:[a.jsx("span",{className:Ga.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:Ga.time,children:_z(o.timestamp)})]}),a.jsx("div",{className:Ga.content,children:o.content})]},o.seq))})}const kz="_panel_i6ltf_1",Sz="_header_i6ltf_24",jz="_title_i6ltf_33",Tz="_closeButton_i6ltf_43",Nz="_body_i6ltf_57",wz="_section_i6ltf_63",Cz="_sectionLabel_i6ltf_67",Ez="_metaRow_i6ltf_76",Az="_metaKey_i6ltf_84",Dz="_metaValue_i6ltf_90",Mz="_subscriberCard_i6ltf_99",Rz="_subscriberHeader_i6ltf_107",Iz="_sessionLink_i6ltf_114",Oz="_badges_i6ltf_132",Bz="_badgeRw_i6ltf_150 _badge_i6ltf_132",Lz="_badgeR_i6ltf_150 _badge_i6ltf_132",zz="_badgeW_i6ltf_162 _badge_i6ltf_132",$z="_badgeAsync_i6ltf_168 _badge_i6ltf_132",Hz="_badgeSync_i6ltf_174 _badge_i6ltf_132",Pz="_badgeDetach_i6ltf_178 _badge_i6ltf_132",Uz="_spawnTag_i6ltf_184 _badge_i6ltf_132",Vz="_fdNumber_i6ltf_189",qz="_emptySubscribers_i6ltf_195",Gz="_metaValueMono_i6ltf_201 _metaValue_i6ltf_90",Fz="_advanced_i6ltf_216",Kz="_advancedSummary_i6ltf_220",He={panel:kz,header:Sz,title:jz,closeButton:Tz,body:Nz,section:wz,sectionLabel:Cz,metaRow:Ez,metaKey:Az,metaValue:Dz,subscriberCard:Mz,subscriberHeader:Rz,sessionLink:Iz,badges:Oz,badgeRw:Bz,badgeR:Lz,badgeW:zz,badgeAsync:$z,badgeSync:Hz,badgeDetach:Pz,spawnTag:Uz,fdNumber:Vz,emptySubscribers:qz,metaValueMono:Gz,advanced:Fz,advancedSummary:Kz},Zz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function Yz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function Jz({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Wz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:Zz[bh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(gl(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(xz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(Yz,{permission:d.permission}),a.jsx(Jz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}const mk="session",_h="stream",u_="messageDot";function Yc(t){return`session:${t}`}function f_(t){return`stream:${t}`}function Xz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Qz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function e$(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function t$(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??Xz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=bh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=e$(v,b);d.push({id:`edge-pipe-${m.id}`,source:Yc(_.sessionId),target:Yc(k.sessionId),type:u_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Ic.ArrowClosed},markerStart:S?{type:Ic.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:pk(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=f_(m.id),_=Yc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:u_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Qz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Ic.ArrowClosed},markerStart:N?{type:Ic.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Yc(m),type:mk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:f_(m),type:_h,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const n$=200,s$=64,a$=180,i$=56,o$=40,r$=70;function p_(t){return t===_h?{width:a$,height:i$}:{width:n$,height:s$}}function l$(t){if(t.nodes.length===0)return t;const s=new dd.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:o$,ranksep:r$});for(const r of t.nodes){const{width:c,height:d}=p_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return dd.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=p_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function c$(t,s){return y.useMemo(()=>l$(t$(t,s)),[t,s])}const d$="_graphContainer_1uzcp_1",u$="_empty_1uzcp_18",f$="_nodeContent_1uzcp_28",p$="_nodeHeader_1uzcp_38",m$="_nodeTitle_1uzcp_50",h$="_nodeMeta_1uzcp_58",g$="_nodeSubtle_1uzcp_64",v$="_countBadge_1uzcp_69",y$="_sessionNode_1uzcp_81",b$="_sessionAccent_1uzcp_103",_$="_external_1uzcp_109",x$="_streamNode_1uzcp_114",k$="_chatroom_1uzcp_134",S$="_channel_1uzcp_139",j$="_pipe_1uzcp_143",T$="_haloless_1uzcp_147",N$="_selected_1uzcp_153",w$="_kindBadge_1uzcp_158",C$="_handle_1uzcp_172",E$="_messageDot_1uzcp_179",vt={graphContainer:d$,empty:u$,nodeContent:f$,nodeHeader:p$,nodeTitle:m$,nodeMeta:h$,nodeSubtle:g$,countBadge:v$,sessionNode:y$,sessionAccent:b$,external:_$,streamNode:x$,chatroom:k$,channel:S$,pipe:j$,haloless:T$,selected:N$,kindBadge:w$,handle:C$,messageDot:E$};function A$({data:t}){const{session:s,streamCount:o,external:r}=t,c=nk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function D$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const m_="0.7s",M$=3;function R$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=F2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(K2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:M$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:m_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:m_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Ip="#6b7a8d",I$={[mk]:A$,[_h]:D$},O$={messageDot:R$};function B$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=c$(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of FI)k[S]=_.getPropertyValue(S).trim()||Ip;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[nk(k.session.status,k.external).varName]??Ip:Ip},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(L_,{nodes:m,edges:p,nodeTypes:I$,edgeTypes:O$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(z_,{variant:$_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(H_,{showInteractive:!1}),a.jsx(P_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function L$({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(Ny.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ny.map(d=>{const u=Ja(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const z$="_boardContainer_1c4y1_1",$$="_column_1c4y1_17",H$="_columnHeader_1c4y1_34",P$="_columnIcon_1c4y1_47",U$="_columnLabel_1c4y1_52",V$="_columnCount_1c4y1_57",q$="_cardList_1c4y1_67",G$="_emptyPlaceholder_1c4y1_76",F$="_card_1c4y1_67",K$="_cardHeader_1c4y1_107",Z$="_cardStatusIcon_1c4y1_113",Y$="_cardTitle_1c4y1_119",J$="_cardBadges_1c4y1_127",W$="_badge_1c4y1_134",X$="_blockedBadge_1c4y1_146",Q$="_childBadge_1c4y1_151",e9="_depBadge_1c4y1_155",t9="_parentBadge_1c4y1_159",n9="_pausedSubBadge_1c4y1_166",s9="_personaBadge_1c4y1_170",a9="_envBadge_1c4y1_174",i9="_emptyCta_1c4y1_178",o9="_ctaButton_1c4y1_188",r9="_ctaDescription_1c4y1_204",dt={boardContainer:z$,column:$$,columnHeader:H$,columnIcon:P$,columnLabel:U$,columnCount:V$,cardList:q$,emptyPlaceholder:G$,card:F$,cardHeader:K$,cardStatusIcon:Z$,cardTitle:Y$,cardBadges:J$,badge:W$,blockedBadge:X$,childBadge:Q$,depBadge:e9,parentBadge:t9,pausedSubBadge:n9,personaBadge:s9,envBadge:a9,emptyCta:i9,ctaButton:o9,ctaDescription:r9};function l9({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>L$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(os,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Ut.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(c9,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(ls(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function c9({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ja(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const d9="_formContent_ymnez_1",u9="_section_ymnez_13",f9="_label_ymnez_19",p9="_titleInput_ymnez_26",m9="_descriptionTextarea_ymnez_58",h9="_selectField_ymnez_94",g9="_checkboxRow_ymnez_128",v9="_checkboxLabel_ymnez_141",y9="_fieldError_ymnez_146",jt={formContent:d9,section:u9,label:f9,titleInput:p9,descriptionTextarea:m9,selectField:h9,checkboxRow:g9,checkboxLabel:v9,fieldError:y9};function b9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const _9=100;function x9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:_9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const hk=y.createContext(void 0),k9=4e3;function S9({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=k9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(hk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function mn(){const t=y.useContext(hk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const ym="grackle-theme",gk="grackle-prefer-system",vk="(prefers-color-scheme: dark)";let Jr=[],cd;function Op(){cd=void 0;for(const t of Jr)t()}function bm(){return typeof window>"u"?!1:window.matchMedia(vk).matches}function nl(){if(typeof localStorage>"u")return l_;try{const t=localStorage.getItem(ym);if(t!==null&&dk.has(t))return t}catch{}return l_}function kd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(gk)==="true"}catch{return!1}}function _m(t){return Ld.find(s=>s.variantLightId===t||s.variantDarkId===t)}function yk(t,s){const o=vm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?bm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=_m(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return bm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=yk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),kd());function j9(){return cd===void 0&&(cd={themeId:nl(),systemDark:bm(),preferSystem:kd()}),cd}function T9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function N9(){const t=y.useSyncExternalStore(T9,j9),{themeId:s,preferSystem:o}=t,r=yk(s,o),c=y.useCallback(u=>{if(dk.has(u)){try{localStorage.setItem(ym,u)}catch{}Ao(u,kd(),!0),Op()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(gk,u?"true":"false")}catch{}if(u){const p=nl(),m=vm(p);if(m!=null&&m.hidden){const g=_m(p);if(g)try{localStorage.setItem(ym,g.id)}catch{}}}Ao(nl(),u,!0),Op()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(vk),p=()=>{const m=nl(),g=kd();if(g){const v=vm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=_m(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Op()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const bk=y.createContext(void 0);function w9({children:t}){const s=N9();return a.jsx(bk.Provider,{value:s,children:t})}function xh(){const t=y.useContext(bk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const _k=y.createContext(void 0),xk=y.createContext(void 0);function C9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(xk.Provider,{value:r,children:a.jsx(_k.Provider,{value:s,children:t})})}function E9(){return y.useContext(_k)}function A9(){const t=y.useContext(xk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const kh=y.createContext(void 0);function pt(){const t=y.useContext(kh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function kk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Sk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function D9(t){return kk(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")&&(t.turnId===void 0||typeof t.turnId=="string")&&(t.serverSeq===void 0||typeof t.serverSeq=="string")}const M9=new Set(["off","subscription","api_key"]),Jc=new Set(["off","on"]);function R9(t){return kk(t)&&M9.has(t.claude)&&Jc.has(t.github)&&Jc.has(t.copilot)&&Jc.has(t.codex)&&Jc.has(t.goose)}function jk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function Tk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Co=5e3;function I9(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const Ai={label:"Home",url:Fo};function O9(t){return t?[Ai,{label:"Settings",url:Ti},{label:t,url:void 0}]:[Ai,{label:"Settings",url:void 0}]}const Nk={label:"Environments",url:zo};function B9(){return[Ai,{label:"Environments",url:void 0}]}function L9(){return[Ai,{label:"New Chat",url:void 0}]}function z9(t){return[Ai,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function $9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ai,Nk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function H9(t,s,o,r,c){const d=I9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ai];v&&g&&(b.push(Nk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:Ci(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:ls(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function Sh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function h_(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function P9(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Bp(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function jh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Bp(u,s.get(u),h_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Bp(u,s.get(u),P9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Bp(u,s.get(u),h_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function U9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=wk(s),d=s.filter(m=>xm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||xm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function wk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function xm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function V9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=wk(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):xm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function q9(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function G9(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
330
|
+
--- End forwarded ---`}function AI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function DI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const MI="_wrapper_1cdza_1",RI="_scrollContainer_1cdza_9",II="_selectingPadding_1cdza_16",OI="_toolbar_1cdza_20",BI="_directionToggle_1cdza_27",LI="_scrollToAnchor_1cdza_65",zI="_scrollToAnchorBottom_1cdza_89",$I="_scrollToAnchorTop_1cdza_93",HI="_eventOverflowWarning_1cdza_97",oa={wrapper:MI,scrollContainer:RI,selectingPadding:II,toolbar:OI,directionToggle:BI,scrollToAnchor:LI,scrollToAnchorBottom:zI,scrollToAnchorTop:$I,eventOverflowWarning:HI},PI=10*1024,UI=new Set(["running","idle"]);function VI(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const ek="grackle-stream-direction";function qI(){try{return localStorage.getItem(ek)==="reversed"}catch{return!1}}function GI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(Cm,{size:Pt,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function vh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(qI),k=s6(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=DI({events:t,formatForClipboard:Q1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>UI.has(ce.status)&&ce.id!==d):[],[c,d]),B=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=NI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(ek,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const U=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),X=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),te=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),G=y.useCallback(async(ce,me)=>{if(!m)return;const xe=te(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,te,r,A]),ne=y.useCallback(ce=>{j(!1);const me=X(),xe=te(d),De=EI(xe,me);if(new TextEncoder().encode(De).length>PI){D({sessionId:ce,text:De}),N(!0);return}G(ce,De).catch(()=>{})},[X,te,d,G]),H=y.useCallback(()=>{N(!1),C&&(G(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,G]),O=y.useCallback(()=>{N(!1),D(void 0)},[]),q=k?0:.2,ge=b?-8:8,se=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ei,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(jy,{size:Pt,"aria-hidden":"true"}):a.jsx(Ty,{size:Pt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(GI,{eventsDropped:s}),a.jsx(os,{initial:!1,children:B.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Ut.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:q,ease:"easeOut"},children:a.jsx(F6,{copyText:CI(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:VI(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(DD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(os,{children:A.isSelecting&&a.jsx(tI,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{U().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(SI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ne,onCancel:()=>{j(!1)}}),a.jsx(bs,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${se} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:O}),a.jsx(os,{children:!M&&a.jsxs(Ut.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?a.jsx(Ty,{size:Pt,"aria-hidden":"true"}):a.jsx(jy,{size:Pt,"aria-hidden":"true"})," ","New events"]})})]})}function hm(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function tk(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function Ap(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const FI=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function nk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Ap(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Ap(t)};default:return{varName:"--text-tertiary",label:t.length>0?Ap(t):"Unknown"}}}function yh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(B=>{v(B),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const B=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(B===M){N();return}o(B),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(B=>{if(k.current){k.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(B=>{B.key==="Escape"?N():B.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const B=m?s.trim():s;return(m?g.trim():g)!==B})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const KI="_editFieldWrapper_yuzty_1",ZI="_editInput_yuzty_10",YI="_editTextarea_yuzty_42",JI="_editSelect_yuzty_78",WI="_editError_yuzty_111",XI="_editInputInvalid_yuzty_118",QI="_editHint_yuzty_123",e5="_unsavedDot_yuzty_132",t5="_metaValueClickable_yuzty_140",n5="_editButton_yuzty_159",s5="_metaPlaceholder_yuzty_175",a5="_worktreeToggle_yuzty_180",it={editFieldWrapper:KI,editInput:ZI,editTextarea:YI,editSelect:JI,editError:WI,editInputInvalid:XI,editHint:QI,unsavedDot:e5,metaValueClickable:t5,editButton:n5,metaPlaceholder:s5,worktreeToggle:a5};function $t(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),j=yh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function gm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=yh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function xd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=yh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function i5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const o5="_nav_1snmp_1",r5="_searchForm_1snmp_8",l5="_searchInput_1snmp_15",c5="_searchButton_1snmp_33",d5="_clearButton_1snmp_68",u5="_workspaceSelect_1snmp_85",f5="_listHeader_1snmp_99",p5="_nodeList_1snmp_108",m5="_nodeItem_1snmp_116",h5="_indicator_1snmp_129",g5="_label_1snmp_136",v5="_badge_1snmp_145",es={nav:o5,searchForm:r5,searchInput:l5,searchButton:c5,clearButton:d5,workspaceSelect:u5,listHeader:f5,nodeList:p5,nodeItem:m5,indicator:h5,label:g5,badge:v5};function y5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:es.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:es.searchForm,onSubmit:v,children:[a.jsx("input",{className:es.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:es.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:es.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:es.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:es.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:es.nodeList,children:t.map(S=>a.jsxs("li",{className:es.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:es.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:es.label,children:S.label}),a.jsx("span",{className:es.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const b5="_container_bwu10_1",_5="_hamburger_bwu10_33",x5="_brand_bwu10_49",k5="_brandLogo_bwu10_68",S5="_info_bwu10_75",j5="_connectionLabel_bwu10_90",T5="_connectionDot_bwu10_103",N5="_connected_bwu10_106",w5="_disconnected_bwu10_110",C5="_connecting_bwu10_113",Ds={container:b5,hamburger:_5,brand:x5,brandLogo:k5,info:S5,connectionLabel:j5,connectionDot:T5,connected:N5,disconnected:w5,connecting:C5},E5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},A5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function D5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=E5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(BT,{size:Tt,"aria-hidden":"true"})}),a.jsx(Ei,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Bd("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${A5[t]}`,"aria-hidden":"true",children:a.jsx(wi,{size:Z_,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const M5="_nav_gx5h3_1",R5="_tab_gx5h3_35",I5="_tabIcon_gx5h3_68",O5="_tabLabel_gx5h3_79",B5="_tabActive_gx5h3_84",L5="_tabEnd_gx5h3_90",wo={nav:M5,tab:R5,tabIcon:I5,tabLabel:O5,tabActive:B5,tabEnd:L5},od=[{view:"dashboard",label:"Dashboard",icon:a.jsx(ST,{size:Tt}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(nT,{size:Tt}),route:yC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(UT,{size:Tt}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(zT,{size:Tt}),route:vC,testId:"sidebar-tab-chat",order:3},{view:"sessions",label:"Sessions",icon:a.jsx(Uj,{size:Tt}),route:vx,testId:"sidebar-tab-sessions",order:4},{view:"knowledge",label:"Knowledge",icon:a.jsx(Zj,{size:Tt}),route:bx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(qT,{size:Tt}),route:gx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(sN,{size:Tt}),route:fC,testId:"sidebar-tab-settings",align:"end"}];function z5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(gx)?"coordination":t.startsWith(vx)?"sessions":t.startsWith("/chat")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(bx)?"knowledge":t.startsWith(Ti)?"settings":"tasks"}function $5({tabs:t=od}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=z5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ei,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const H5="_container_pi6ii_1",P5="_content_pi6ii_66",o_={container:H5,content:P5},U5=320,sk=220,ak=600,ik="grackle-sidebar-width";function V5(){try{const t=localStorage.getItem(ik);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=sk&&s<=ak)return s}}catch{}return U5}function q5(t){try{localStorage.setItem(ik,String(t))}catch{}}function G5({content:t}){const[s]=y.useState(V5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=sk&&m<=ak&&q5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:o_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:o_.content,children:t})})}const F5="_bar_tnfsh_1",K5="_btnPrimary_tnfsh_32",Z5="_statusText_tnfsh_85",Y5="_statusCompleted_tnfsh_90",J5="_statusFailed_tnfsh_94",W5="_statusBlocked_tnfsh_98",X5="_hintText_tnfsh_103",At={bar:F5,btnPrimary:K5,statusText:Z5,statusCompleted:Y5,statusFailed:J5,statusBlocked:W5,hintText:X5};function Q5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=sn("/sessions/:sessionId"),u=sn("/tasks/:taskId"),p=sn("/tasks/:taskId/stream"),m=sn("/tasks/:taskId/edit"),g=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=sn("/sessions/new"),k=sn("/environments/:environmentId/workspaces/:workspaceId"),S=sn("/tasks/new"),j=sn("/chat"),T=sn("/"),N=sn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,B=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(B)return o.find(ne=>ne.adapterType==="local"&&ne.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Select a task or click + to create one"})});if(D){const G=s.find(O=>O.id===D);if(!G)return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Loading..."})});const ne=new Map(s.map(O=>[O.id,O])),H=G.dependsOn.some(O=>{const q=ne.get(O);return q!==void 0&&q.status!=="complete"});if(G.status==="not_started"){const O=H?G.dependsOn.map(q=>ne.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:At.bar,children:H?a.jsxs("span",{className:At.statusBlocked,children:["Blocked by: ",O.join(", ")]}):a.jsx("span",{className:At.hintText,children:"Use the buttons above to start or manage this task"})})}if(G.status==="working"||G.status==="paused"){const O=G.latestSessionId||void 0,q=O?t.find(se=>se.id===O):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Waiting for agent..."})})}if(G.status==="complete")return a.jsxs("div",{className:At.bar,children:[a.jsx("span",{className:`${At.statusText} ${At.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ii(G.workspaceId,void 0,E)),className:At.btnPrimary,children:"+ New Task"})]});if(G.status==="failed")return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:`${At.statusText} ${At.statusFailed}`,children:"Task failed"})})}if(C){const G=t.find(O=>O.id===C),ne=(G==null?void 0:G.status)==="stopped";if(G!==void 0&&!ne)return a.jsx(a.Fragment,{});if(ne)return a.jsxs("div",{className:At.bar,children:[a.jsxs("span",{className:`${At.statusText} ${At.hintText}`,children:["Session ",G.endReason||G.status]}),a.jsx("button",{onClick:()=>r(px(G.environmentId)),className:At.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:At.bar,children:a.jsx("span",{className:At.hintText,children:"Loading..."})})}const eO="_nav_14i94_1",tO="_tab_14i94_24",nO="_tabActive_14i94_62",sO="_tabLabel_14i94_75",aO="_statusDot_14i94_81",iO="_pulse_14i94_87",oO="_addButton_14i94_99",rO="_empty_14i94_132",Va={nav:eO,tab:tO,tabActive:nO,tabLabel:sO,statusDot:aO,pulse:iO,addButton:oO,empty:rO},lO={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function cO({environments:t}){const s=xt(),o=y.useRef(null),r=sn("/environments/:environmentId"),c=sn("/environments/:environmentId/edit"),d=sn("/environments/:environmentId/workspaces/:workspaceId"),u=sn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Va.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=lO[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Va.tab} ${k?Va.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Va.statusDot} ${T?Va.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(wi,{size:Z_,fill:"currentColor"})}),a.jsx("span",{className:Va.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Va.addButton,onClick:()=>s(dC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Va.empty,children:"No environments yet."})]})}function dO(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function ok({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=dO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function uO(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function fO(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of mN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const pO="_container_z4i38_1",mO="_header_z4i38_5",hO="_headerActions_z4i38_17",gO="_searchInput_z4i38_23",vO="_searchHighlight_z4i38_56",yO="_groupToggle_z4i38_62",bO="_groupToggleActive_z4i38_89",_O="_addButton_z4i38_93",xO="_taskRow_z4i38_120",kO="_selected_z4i38_140",SO="_expandArrow_z4i38_150",jO="_expanded_z4i38_157",TO="_leafSpacer_z4i38_161",NO="_taskStatusIcon_z4i38_166",wO="_taskTitle_z4i38_170",CO="_workspaceBadge_z4i38_177",EO="_childCountBadge_z4i38_195",AO="_dependencyBadge_z4i38_208",DO="_blockedBadge_z4i38_220",MO="_addChildButton_z4i38_225",RO="_emptyState_z4i38_268",IO="_statusGroupHeader_z4i38_275",OO="_statusGroupIcon_z4i38_294",BO="_statusGroupLabel_z4i38_298",LO="_statusGroupCount_z4i38_303",We={container:pO,header:mO,headerActions:hO,searchInput:gO,searchHighlight:vO,groupToggle:yO,groupToggleActive:bO,addButton:_O,taskRow:xO,selected:kO,expandArrow:SO,expanded:jO,leafSpacer:TO,taskStatusIcon:NO,taskTitle:wO,workspaceBadge:CO,childCountBadge:EO,dependencyBadge:AO,blockedBadge:DO,addChildButton:MO,emptyState:RO,statusGroupHeader:IO,statusGroupIcon:OO,statusGroupLabel:BO,statusGroupCount:LO},zO=[{name:"title",weight:2},{name:"description",weight:1}],rk=16,$O=16,lk="grackle-task-group-by-status";function r_(){try{return localStorage.getItem(lk)==="true"}catch{return!1}}function HO(t){try{localStorage.setItem(lk,String(t))}catch{}}function PO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(fa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(os,{children:s&&a.jsx(Ut.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=Ja(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(ls(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(ls(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${rk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(ok,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ck({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ja(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=rk+s*$O,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(ls(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(ls(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(fa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(ok,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<aj&&a.jsx(Ei,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(os,{children:_&&b&&a.jsx(Ut.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(N=>a.jsx(ck,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function UO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(r_),[g,v]=y.useState(r_),[b,_]=y.useState(new Map),k=sn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(G=>[G.id,G.status])),[s]),T=y.useMemo(()=>new Map(t.map(G=>[G.id,G.name])),[t]),N=()=>{const G=!p;HO(G),m(G),G&&(v(!0),_(new Map))},C=G=>{_(ne=>{const H=new Map(ne),O=H.has(G)?H.get(G):g;return H.set(G,!O),H})},D=G=>b.has(G)?b.get(G):g,A=G=>{c(ne=>{const H=new Set(ne);return H.has(G)?(H.delete(G),u(O=>new Set(O).add(G))):(H.add(G),u(O=>{const q=new Set(O);return q.delete(G),q})),H})};y.useEffect(()=>{const G=new Set(s.filter(ne=>ne.parentTaskId).map(ne=>ne.parentTaskId));G.size>0&&c(ne=>{const H=new Set(ne);for(const O of G)d.has(O)||H.add(O);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:B,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const G=sj(s,E,zO),ne=new Set(G.map(ge=>ge.item.id)),H=new Map;for(const ge of G){const se=ge.matches.find(ce=>ce.key==="title");se&&H.set(ge.item.id,se.indices)}const O=new Set(ne),q=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ne]){let se=q.get(ge);for(;se!=null&&se.parentTaskId;)O.add(se.parentTaskId),se=q.get(se.parentTaskId)}return{directMatchTaskIds:ne,treeMatchTaskIds:O,titleHighlights:H}},[E,s]),Y=B!==null,U=Y?p?B:M:null,X=U?s.filter(G=>U.has(G.id)):s,te=p?[]:uO(X);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ei,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(MT,{size:Pt})})}),a.jsx(Ei,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:G=>R(G.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?fO(X,j).map(G=>a.jsx(PO,{group:G,isExpanded:D(G.status),onToggle:()=>C(G.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},G.status)):te.map(G=>a.jsx(ck,{node:G,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},G.id)),X.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),X.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const VO="_toast_ed2dk_1",qO="_success_ed2dk_18",GO="_icon_ed2dk_22",FO="_error_ed2dk_25",KO="_warning_ed2dk_32",ZO="_info_ed2dk_38",YO="_message_ed2dk_53",JO="_close_ed2dk_60",qr={toast:VO,success:qO,icon:GO,error:FO,warning:KO,info:ZO,message:YO,close:JO},WO={success:a.jsx(Di,{size:Tt}),error:a.jsx(Ls,{size:Tt}),warning:a.jsx(Cm,{size:Tt}),info:a.jsx(wm,{size:Tt})};function XO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ut.div,{className:`${qr.toast} ${qr[t.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:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:WO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})}const QO="_container_qqse2_1",eB={container:QO};function tB({toasts:t,onDismiss:s}){return a.jsx("div",{className:eB.container,"data-testid":"toast-container",children:a.jsx(os,{children:t.map(o=>a.jsx(XO,{toast:o,onDismiss:s},o.id))})})}const nB="_callout_e5awm_1",sB="_success_e5awm_11",aB="_icon_e5awm_15",iB="_error_e5awm_18",oB="_warning_e5awm_25",rB="_info_e5awm_32",lB="_content_e5awm_48",cB="_close_e5awm_53",Gr={callout:nB,success:sB,icon:aB,error:iB,warning:oB,info:rB,content:lB,close:cB},dB={success:a.jsx(Di,{size:Tt}),error:a.jsx(Ls,{size:Tt}),warning:a.jsx(Cm,{size:Tt}),info:a.jsx(wm,{size:Tt})};function uB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:dB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})})}function fB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(uB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,"). Run:"," ",a.jsx("code",{children:c})]})})}const pB="_container_m1fsr_1",mB="_heading_m1fsr_7",hB="_section_m1fsr_14",gB="_sectionTitle_m1fsr_26",vB="_sectionDescription_m1fsr_35",yB="_emptyState_m1fsr_41",bB="_tokenList_m1fsr_48",_B="_tokenRow_m1fsr_55",xB="_tokenBadge_m1fsr_68",kB="_tokenName_m1fsr_83",SB="_tokenTarget_m1fsr_90",jB="_deleteButton_m1fsr_99",TB="_addForm_m1fsr_113",NB="_formRow_m1fsr_119",wB="_input_m1fsr_125",CB="_select_m1fsr_155",EB="_addButton_m1fsr_187",AB="_emptyStateInfo_m1fsr_221",DB="_themeOptions_m1fsr_229",MB="_themeOption_m1fsr_229",RB="_themeOptionSelected_m1fsr_254",IB="_themeOptionHeader_m1fsr_259",OB="_themeOptionLabel_m1fsr_266",BB="_themeOptionDesc_m1fsr_273",LB="_variantToggle_m1fsr_279",zB="_variantButton_m1fsr_286",$B="_variantActive_m1fsr_305",HB="_themeSwatches_m1fsr_311",PB="_themeSwatch_m1fsr_311",UB="_systemToggle_m1fsr_325",VB="_systemToggleHint_m1fsr_341",qB="_themeActive_m1fsr_348",GB="_aboutGrid_m1fsr_354",FB="_aboutItem_m1fsr_360",KB="_aboutLabel_m1fsr_373",ZB="_aboutValue_m1fsr_379",YB="_aboutDot_m1fsr_387",JB="_aboutDotConnected_m1fsr_394",WB="_aboutDotDisconnected_m1fsr_398",XB="_aboutDotConnecting_m1fsr_402",fe={container:pB,heading:mB,section:hB,sectionTitle:gB,sectionDescription:vB,emptyState:yB,tokenList:bB,tokenRow:_B,tokenBadge:xB,tokenName:kB,tokenTarget:SB,deleteButton:jB,addForm:TB,formRow:NB,input:wB,select:CB,addButton:EB,emptyStateInfo:AB,themeOptions:DB,themeOption:MB,themeOptionSelected:RB,themeOptionHeader:IB,themeOptionLabel:OB,themeOptionDesc:BB,variantToggle:LB,variantButton:zB,variantActive:$B,themeSwatches:HB,themeSwatch:PB,systemToggle:UB,systemToggleHint:VB,themeActive:qB,aboutGrid:GB,aboutItem:FB,aboutLabel:KB,aboutValue:ZB,aboutDot:YB,aboutDotConnected:JB,aboutDotDisconnected:WB,aboutDotConnecting:XB},QB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function eL({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=N=>{if(N.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:QB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ld=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],dk=new Set(Ld.map(t=>t.id)),l_="grackle";function vm(t){return Ld.find(s=>s.id===t)}function tL({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Ld.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const nL={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},sL={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function aL({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${sL[t]}`}),nL[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.136.1"})]})]})]})}const iL="_container_cddyd_1",oL="_header_cddyd_8",rL="_headerTitle_cddyd_35",lL="_badge_cddyd_44",cL="_headerActions_cddyd_54",dL="_body_cddyd_61",uL="_formContent_cddyd_73",fL="_section_cddyd_85",pL="_label_cddyd_91",mL="_titleInput_cddyd_98",hL="_descriptionTextarea_cddyd_131",gL="_parentContext_cddyd_167",vL="_parentLabel_cddyd_175",yL="_parentName_cddyd_182",bL="_personaSelect_cddyd_186",_L="_depList_cddyd_220",xL="_depItem_cddyd_226",kL="_depItemSelected_cddyd_248",SL="_noDeps_cddyd_252",jL="_btnPrimary_cddyd_258",TL="_btnGhost_cddyd_289",Qe={container:iL,header:oL,headerTitle:rL,badge:lL,headerActions:cL,body:dL,formContent:uL,section:fL,label:pL,titleInput:mL,descriptionTextarea:hL,parentContext:gL,parentLabel:vL,parentName:yL,personaSelect:bL,depList:_L,depItem:xL,depItemSelected:kL,noDeps:SL,btnPrimary:jL,btnGhost:TL};function uk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",B=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,U]=y.useState((S==null?void 0:S.description)??""),[X,te]=y.useState((S==null?void 0:S.dependsOn)??[]),[G,ne]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,O]=y.useState((S==null?void 0:S.canDecompose)??!1),[q,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[se,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),U(S.description),te(S.dependsOn),ne(S.defaultPersonaId),O(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{te(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||se||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,X,G),b==null||b("Task updated","success"),v?v():_(ls(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,X.length>0?X:void 0,R||void 0,G,H,q,()=>{b==null||b("Task created","success"),_(o?Ci(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?ls(s,void 0,C,A):o?Ci(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),B&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:B.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||se,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>U(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:G,onChange:ke=>ne(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>O(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:q,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=X.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const NL="_actionButtons_1rjka_1",wL="_btnPrimary_1rjka_8",CL="_btnDanger_1rjka_39",EL="_btnGhost_1rjka_78",Yt={actionButtons:NL,btnPrimary:wL,btnDanger:CL,btnGhost:EL},AL=new Set(["stopped","suspended"]);function DL({task:t,sessionId:s,latestSessionStatus:o,isBlocked:r,onStart:c,onResume:d,onStop:u,onPause:p,onDelete:m,onEdit:g}){if(t.status==="not_started")return r?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:c,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:p,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused"){const v=o!==void 0&&AL.has(o);return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),v&&a.jsx("button",{onClick:d,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:c,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const ML="_workpadSection_y8nj9_1",RL="_workpadLabel_y8nj9_9",IL="_workpadStatus_y8nj9_17",OL="_workpadSummary_y8nj9_23",BL="_workpadExtra_y8nj9_29",qa={workpadSection:ML,workpadLabel:RL,workpadStatus:IL,workpadSummary:OL,workpadExtra:BL};function LL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),a.jsx("div",{className:qa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:qa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:qa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:qa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const zL="_overviewDashboard_ng7kf_1",$L="_overviewHero_ng7kf_7",HL="_statusBadge_ng7kf_14",PL="_statusPending_ng7kf_26",UL="_statusAssigned_ng7kf_31",VL="_statusInProgress_ng7kf_36",qL="_statusReview_ng7kf_41",GL="_statusDone_ng7kf_46",FL="_statusFailed_ng7kf_51",KL="_statusWaitingInput_ng7kf_56",ZL="_overviewBranchPill_ng7kf_61",YL="_branchLink_ng7kf_76",JL="_overviewSection_ng7kf_87",WL="_overviewLabel_ng7kf_93",XL="_overviewValue_ng7kf_100",QL="_overviewMuted_ng7kf_105",e8="_overviewMarkdown_ng7kf_111",t8="_envRow_ng7kf_186",n8="_envDot_ng7kf_192",s8="_envDotGreen_ng7kf_199",a8="_envDotYellow_ng7kf_203",i8="_envDotRed_ng7kf_207",o8="_envDotGray_ng7kf_211",r8="_depList_ng7kf_215",l8="_depItem_ng7kf_221",c8="_depBlocked_ng7kf_228",d8="_depDone_ng7kf_232",u8="_timeline_ng7kf_236",f8="_timelineRow_ng7kf_242",p8="_timelineKey_ng7kf_249",m8="_timelineValue_ng7kf_255",h8="_timelineDelta_ng7kf_259",g8="_reviewNotes_ng7kf_270",be={overviewDashboard:zL,overviewHero:$L,statusBadge:HL,statusPending:PL,statusAssigned:UL,statusInProgress:VL,statusReview:qL,statusDone:GL,statusFailed:FL,statusWaitingInput:KL,overviewBranchPill:ZL,branchLink:YL,overviewSection:JL,overviewLabel:WL,overviewValue:XL,overviewMuted:QL,overviewMarkdown:e8,envRow:t8,envDot:n8,envDotGreen:s8,envDotYellow:a8,envDotRed:i8,envDotGray:o8,depList:r8,depItem:l8,depBlocked:c8,depDone:d8,timeline:u8,timelineRow:f8,timelineKey:p8,timelineValue:m8,timelineDelta:h8,reviewNotes:g8};function Kc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Dp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function c_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function v8({status:t}){const s=Ja(t),o=pN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function y8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(v8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(jm,{remarkPlugins:[Tm],children:t.description})})]}),t.workpad&&a.jsx(LL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${c_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Dp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Dp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Dp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Kc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," /"," ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," /"," ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function b8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function _8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},B=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(rN,{size:Pt,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{B().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const x8="_container_legrg_1",k8="_header_legrg_8",S8="_headerTitle_legrg_35",j8="_badge_legrg_44",T8="_headerActions_legrg_54",N8="_body_legrg_61",w8="_formContent_legrg_73",C8="_section_legrg_85",E8="_label_legrg_91",A8="_nameInput_legrg_98",D8="_fieldInput_legrg_131",M8="_adapterSelect_legrg_164",R8="_readOnlyValue_legrg_198",I8="_codespaceSection_legrg_204",O8="_codespaceActions_legrg_210",B8="_creatingHint_legrg_216",L8="_errorHint_legrg_222",z8="_btnPrimary_legrg_235",$8="_btnGhost_legrg_266",re={container:x8,header:k8,headerTitle:S8,badge:j8,headerActions:T8,body:N8,formContent:w8,section:C8,label:E8,nameInput:A8,fieldInput:D8,adapterSelect:M8,readOnlyValue:R8,codespaceSection:I8,codespaceActions:O8,creatingHint:B8,errorHint:L8,btnPrimary:z8,btnGhost:$8},rd=1,ld=65535;function Mp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=rd&&s<=ld}function Rp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function H8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:re.codespaceSection,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:re.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:re.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:re.codespaceSection,children:a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:re.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:re.errorHint,children:d})]})})}function fk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(le=>le.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[B,M]=y.useState(""),[$,Y]=y.useState(""),[U,X]=y.useState(""),[te,G]=y.useState(""),[ne,H]=y.useState(""),[O,q]=y.useState(""),[ge,se]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const le={};if(E==="local"){if(B.trim()&&(le.host=B.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.port=ve)}}else if(E==="ssh"){if(le.host=B.trim(),U.trim()&&(le.user=U.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.sshPort=ve)}te.trim()&&(le.identityFile=te.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(le.attach=ot.trim()):(ne.trim()&&(le.image=ne.trim()),O.trim()&&(le.repo=O.trim())):E==="codespace"&&(le.codespaceName=ge.trim());return le},[E,B,$,U,te,ne,O,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!B.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Mp($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Ie=()=>{T(s?$o(s):zo)},ee=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Rp(C.adapterConfig),on=ve.trim();on?et[le]=on:delete et[le],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Rp(C.adapterConfig);if(ve.trim()){const on=Number(ve);Number.isInteger(on)&&on>=rd&&on<=ld&&(et[le]=on)}else delete et[le];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:re.container,children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Ie,className:re.btnGhost,children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsx("div",{className:re.formContent,children:a.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const le=Rp(C.adapterConfig);return a.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Ie,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Name"}),a.jsx($t,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Adapter Type"}),a.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:re.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Port"}),a.jsx($t,{value:String(le.port??""),onSave:ve=>nt("port",ve),validate:ve=>Mp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"User"}),a.jsx($t,{value:String(le.user??""),onSave:ve=>ee("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"SSH Port"}),a.jsx($t,{value:String(le.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Mp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Identity File"}),a.jsx($t,{value:String(le.identityFile??""),onSave:ve=>ee("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&le.attach!==void 0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Attach (container)"}),a.jsx($t,{value:String(le.attach??""),onSave:ve=>ee("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&le.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Image"}),a.jsx($t,{value:String(le.image??""),onSave:ve=>ee("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repo"}),a.jsx($t,{value:String(le.repo??""),onSave:ve=>ee("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace Name"}),a.jsx($t,{value:String(le.codespaceName??""),onSave:ve=>ee("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"new environment"})}),a.jsxs("div",{className:re.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ie,className:re.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:le=>A(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:le=>{R(le.target.value),le.target.value==="codespace"&&u(ce||void 0)},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:le=>{me(le.target.value),E==="codespace"&&u(le.target.value||void 0)},className:re.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(le=>a.jsxs("option",{value:le.id,children:[le.label," (@",le.username,")",le.isDefault?" — default":""]},le.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:rd,max:ld,value:$,onChange:le=>Y(le.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:le=>X(le.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:rd,max:ld,value:$,onChange:le=>Y(le.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:te,onChange:le=>G(le.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:le=>{const ve=le.target.value;De(ve),ve==="attach"&&_()},className:re.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:ne,onChange:le=>H(le.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:O,onChange:le=>q(le.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},className:re.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(le=>a.jsxs("option",{value:le.name,children:[le.name," (",le.image,") ",le.status]},le.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:re.errorHint,children:S}):a.jsx("span",{className:re.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},placeholder:"Enter container name/ID...",className:re.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(H8,{codespaceName:ge,onCodespaceNameChange:se,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const P8="_group_1iprv_1",U8="_groupTitle_1iprv_8",V8="_shortcutList_1iprv_17",q8="_shortcutRow_1iprv_23",G8="_keys_1iprv_36",F8="_kbd_1iprv_43",K8="_description_1iprv_60",xi={group:P8,groupTitle:U8,shortcutList:V8,shortcutRow:q8,keys:G8,kbd:F8,description:K8},Z8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function Y8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),Z8.map(t=>a.jsxs("div",{className:xi.group,children:[a.jsx("h4",{className:xi.groupTitle,children:t.title}),a.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:xi.shortcutRow,children:[a.jsx("span",{className:xi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:xi.kbd,children:o},o))}),a.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const J8=[{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"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function W8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.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."}),a.jsx("div",{className:fe.tokenList,children:J8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const X8="_container_10efq_1",Q8="_header_10efq_7",e7="_list_10efq_105",t7="_card_10efq_111",n7="_cardHeader_10efq_125",s7="_cardTitle_10efq_135",a7="_defaultBadge_10efq_141",i7="_cardActions_10efq_155",o7="_description_10efq_160",r7="_meta_10efq_166",l7="_empty_10efq_212",c7="_typeBadge_10efq_362",ts={container:X8,header:Q8,list:e7,card:t7,cardHeader:n7,cardTitle:s7,defaultBadge:a7,cardActions:i7,description:o7,meta:r7,empty:l7,typeBadge:c7};function d7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ts.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ts.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:ts.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ts.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:ts.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ts.description,children:v.description}),a.jsxs("div",{className:ts.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(bs,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const u7="_container_uy08i_1",f7="_header_uy08i_7",p7="_count_uy08i_13",m7="_presets_uy08i_18",h7="_presetButton_uy08i_24",g7="_filterInput_uy08i_41",v7="_groups_uy08i_53",y7="_group_uy08i_53",b7="_groupHeader_uy08i_68",_7="_groupName_uy08i_77",x7="_groupCount_uy08i_81",k7="_toolList_uy08i_87",S7="_toolItem_uy08i_95",j7="_toolName_uy08i_103",bn={container:u7,header:f7,count:p7,presets:m7,presetButton:h7,filterInput:g7,groups:v7,group:y7,groupHeader:b7,groupName:_7,groupCount:x7,toolList:k7,toolItem:S7,toolName:j7},T7=(()=>{const t=new Map;for(const s of V_){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),N7=[{name:"default",label:"Default",tools:U_},{name:"worker",label:"Worker",tools:ij},{name:"orchestrator",label:"Orchestrator",tools:oj},{name:"admin",label:"Admin",tools:rj}];function d_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:bn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:bn.header,children:a.jsx("span",{className:bn.count,children:t.length===0?`Using default (${U_.length} tools)`:`${t.length} of ${V_.size} tools selected`})}),a.jsxs("div",{className:bn.presets,"data-testid":"mcp-tool-presets",children:[N7.map(v=>a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:bn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:bn.groups,children:T7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:bn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:bn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:bn.groupName,children:v}),a.jsxs("span",{className:bn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:bn.toolList,children:_.map(S=>a.jsxs("label",{className:bn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:bn.toolName,children:S})]},S))})]},v)})})]})}const w7="_container_1gfuq_1",C7="_header_1gfuq_7",E7="_list_1gfuq_19",A7="_card_1gfuq_25",D7="_cardHeader_1gfuq_40",M7="_cardTitle_1gfuq_46",R7="_statusBadge_1gfuq_56",I7="_enabled_1gfuq_68",O7="_disabled_1gfuq_71",B7="_cardActions_1gfuq_75",L7="_cardMeta_1gfuq_80",z7="_empty_1gfuq_98",ns={container:w7,header:C7,list:E7,card:A7,cardHeader:D7,cardTitle:M7,statusBadge:R7,enabled:I7,disabled:O7,cardActions:B7,cardMeta:L7,empty:z7};function $7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ns.container,children:[a.jsxs("div",{className:ns.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ns.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ns.list,children:t.map(_=>a.jsxs("div",{className:ns.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ns.cardHeader,children:[a.jsxs("span",{className:ns.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ns.statusBadge} ${_.enabled?ns.enabled:ns.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ns.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ns.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?hm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",tk(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(bs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const H7="_nav_1bhou_1",P7="_tab_1bhou_24",U7="_tabIcon_1bhou_62",V7="_tabActive_1bhou_68",Zc={nav:H7,tab:P7,tabIcon:U7,tabActive:V7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(NT,{size:Tt})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(bT,{size:Tt})},{path:"personas",label:"Personas",icon:a.jsx(dN,{size:Tt})},{path:"schedules",label:"Schedules",icon:a.jsx(Jj,{size:Tt})},{path:"appearance",label:"Appearance",icon:a.jsx(FT,{size:Tt})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(CT,{size:Tt})},{path:"plugins",label:"Plugins",icon:a.jsx(XT,{size:Tt})},{path:"about",label:"About",icon:a.jsx(wm,{size:Tt})}];function q7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ti}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ti}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${Ti}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const G7=["lifecycle:","pipe:","stdin:"];function bh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function pk(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function F7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=pk(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const K7="_container_16qkd_1",Z7="_header_16qkd_7",Y7="_title_16qkd_15",J7="_headerActions_16qkd_21",W7="_internalsToggle_16qkd_27",X7="_refreshButton_16qkd_37",Q7="_state_16qkd_52",ez="_group_16qkd_59",tz="_groupHeader_16qkd_63",nz="_row_16qkd_72",sz="_selected_16qkd_92",az="_kindBadge_16qkd_96",iz="_kindChatroom_16qkd_108",oz="_kindPipe_16qkd_114",rz="_kindChannel_16qkd_120",lz="_streamName_16qkd_126",cz="_meta_16qkd_135",Jt={container:K7,header:Z7,title:Y7,headerActions:J7,internalsToggle:W7,refreshButton:X7,state:Q7,group:ez,groupHeader:tz,row:nz,selected:sz,kindBadge:az,kindChatroom:iz,kindPipe:oz,kindChannel:rz,streamName:lz,meta:cz},dz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function uz({kind:t}){return t==="chatroom"?a.jsx(HT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(vT,{size:Ye,"aria-hidden":"true"}):a.jsx(xT,{size:Ye,"aria-hidden":"true"})}function fz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=F7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(eN,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=bh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(uz,{kind:N})," ",dz[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const pz="_transcript_1p4cm_1",mz="_message_1p4cm_10",hz="_meta_1p4cm_16",gz="_sender_1p4cm_24",vz="_time_1p4cm_29",yz="_content_1p4cm_34",bz="_state_1p4cm_42",Ga={transcript:pz,message:mz,meta:hz,sender:gz,time:vz,content:yz,state:bz};function _z(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function xz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:Ga.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:Ga.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:Ga.meta,children:[a.jsx("span",{className:Ga.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:Ga.time,children:_z(o.timestamp)})]}),a.jsx("div",{className:Ga.content,children:o.content})]},o.seq))})}const kz="_panel_i6ltf_1",Sz="_header_i6ltf_24",jz="_title_i6ltf_33",Tz="_closeButton_i6ltf_43",Nz="_body_i6ltf_57",wz="_section_i6ltf_63",Cz="_sectionLabel_i6ltf_67",Ez="_metaRow_i6ltf_76",Az="_metaKey_i6ltf_84",Dz="_metaValue_i6ltf_90",Mz="_subscriberCard_i6ltf_99",Rz="_subscriberHeader_i6ltf_107",Iz="_sessionLink_i6ltf_114",Oz="_badges_i6ltf_132",Bz="_badgeRw_i6ltf_150 _badge_i6ltf_132",Lz="_badgeR_i6ltf_150 _badge_i6ltf_132",zz="_badgeW_i6ltf_162 _badge_i6ltf_132",$z="_badgeAsync_i6ltf_168 _badge_i6ltf_132",Hz="_badgeSync_i6ltf_174 _badge_i6ltf_132",Pz="_badgeDetach_i6ltf_178 _badge_i6ltf_132",Uz="_spawnTag_i6ltf_184 _badge_i6ltf_132",Vz="_fdNumber_i6ltf_189",qz="_emptySubscribers_i6ltf_195",Gz="_metaValueMono_i6ltf_201 _metaValue_i6ltf_90",Fz="_advanced_i6ltf_216",Kz="_advancedSummary_i6ltf_220",He={panel:kz,header:Sz,title:jz,closeButton:Tz,body:Nz,section:wz,sectionLabel:Cz,metaRow:Ez,metaKey:Az,metaValue:Dz,subscriberCard:Mz,subscriberHeader:Rz,sessionLink:Iz,badges:Oz,badgeRw:Bz,badgeR:Lz,badgeW:zz,badgeAsync:$z,badgeSync:Hz,badgeDetach:Pz,spawnTag:Uz,fdNumber:Vz,emptySubscribers:qz,metaValueMono:Gz,advanced:Fz,advancedSummary:Kz},Zz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function Yz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function Jz({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Wz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:Zz[bh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(gl(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(xz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(Yz,{permission:d.permission}),a.jsx(Jz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}const mk="session",_h="stream",u_="messageDot";function Yc(t){return`session:${t}`}function f_(t){return`stream:${t}`}function Xz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Qz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function e$(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function t$(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??Xz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=bh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=e$(v,b);d.push({id:`edge-pipe-${m.id}`,source:Yc(_.sessionId),target:Yc(k.sessionId),type:u_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Ic.ArrowClosed},markerStart:S?{type:Ic.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:pk(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=f_(m.id),_=Yc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:u_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Qz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Ic.ArrowClosed},markerStart:N?{type:Ic.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Yc(m),type:mk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:f_(m),type:_h,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const n$=200,s$=64,a$=180,i$=56,o$=40,r$=70;function p_(t){return t===_h?{width:a$,height:i$}:{width:n$,height:s$}}function l$(t){if(t.nodes.length===0)return t;const s=new dd.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:o$,ranksep:r$});for(const r of t.nodes){const{width:c,height:d}=p_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return dd.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=p_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function c$(t,s){return y.useMemo(()=>l$(t$(t,s)),[t,s])}const d$="_graphContainer_1uzcp_1",u$="_empty_1uzcp_18",f$="_nodeContent_1uzcp_28",p$="_nodeHeader_1uzcp_38",m$="_nodeTitle_1uzcp_50",h$="_nodeMeta_1uzcp_58",g$="_nodeSubtle_1uzcp_64",v$="_countBadge_1uzcp_69",y$="_sessionNode_1uzcp_81",b$="_sessionAccent_1uzcp_103",_$="_external_1uzcp_109",x$="_streamNode_1uzcp_114",k$="_chatroom_1uzcp_134",S$="_channel_1uzcp_139",j$="_pipe_1uzcp_143",T$="_haloless_1uzcp_147",N$="_selected_1uzcp_153",w$="_kindBadge_1uzcp_158",C$="_handle_1uzcp_172",E$="_messageDot_1uzcp_179",vt={graphContainer:d$,empty:u$,nodeContent:f$,nodeHeader:p$,nodeTitle:m$,nodeMeta:h$,nodeSubtle:g$,countBadge:v$,sessionNode:y$,sessionAccent:b$,external:_$,streamNode:x$,chatroom:k$,channel:S$,pipe:j$,haloless:T$,selected:N$,kindBadge:w$,handle:C$,messageDot:E$};function A$({data:t}){const{session:s,streamCount:o,external:r}=t,c=nk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function D$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const m_="0.7s",M$=3;function R$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=F2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(K2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:M$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:m_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:m_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Ip="#6b7a8d",I$={[mk]:A$,[_h]:D$},O$={messageDot:R$};function B$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=c$(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of FI)k[S]=_.getPropertyValue(S).trim()||Ip;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[nk(k.session.status,k.external).varName]??Ip:Ip},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(L_,{nodes:m,edges:p,nodeTypes:I$,edgeTypes:O$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(z_,{variant:$_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(H_,{showInteractive:!1}),a.jsx(P_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function L$({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(Ny.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ny.map(d=>{const u=Ja(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const z$="_boardContainer_1c4y1_1",$$="_column_1c4y1_17",H$="_columnHeader_1c4y1_34",P$="_columnIcon_1c4y1_47",U$="_columnLabel_1c4y1_52",V$="_columnCount_1c4y1_57",q$="_cardList_1c4y1_67",G$="_emptyPlaceholder_1c4y1_76",F$="_card_1c4y1_67",K$="_cardHeader_1c4y1_107",Z$="_cardStatusIcon_1c4y1_113",Y$="_cardTitle_1c4y1_119",J$="_cardBadges_1c4y1_127",W$="_badge_1c4y1_134",X$="_blockedBadge_1c4y1_146",Q$="_childBadge_1c4y1_151",e9="_depBadge_1c4y1_155",t9="_parentBadge_1c4y1_159",n9="_pausedSubBadge_1c4y1_166",s9="_personaBadge_1c4y1_170",a9="_envBadge_1c4y1_174",i9="_emptyCta_1c4y1_178",o9="_ctaButton_1c4y1_188",r9="_ctaDescription_1c4y1_204",dt={boardContainer:z$,column:$$,columnHeader:H$,columnIcon:P$,columnLabel:U$,columnCount:V$,cardList:q$,emptyPlaceholder:G$,card:F$,cardHeader:K$,cardStatusIcon:Z$,cardTitle:Y$,cardBadges:J$,badge:W$,blockedBadge:X$,childBadge:Q$,depBadge:e9,parentBadge:t9,pausedSubBadge:n9,personaBadge:s9,envBadge:a9,emptyCta:i9,ctaButton:o9,ctaDescription:r9};function l9({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>L$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(os,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Ut.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(c9,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(ls(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function c9({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ja(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const d9="_formContent_ymnez_1",u9="_section_ymnez_13",f9="_label_ymnez_19",p9="_titleInput_ymnez_26",m9="_descriptionTextarea_ymnez_58",h9="_selectField_ymnez_94",g9="_checkboxRow_ymnez_128",v9="_checkboxLabel_ymnez_141",y9="_fieldError_ymnez_146",jt={formContent:d9,section:u9,label:f9,titleInput:p9,descriptionTextarea:m9,selectField:h9,checkboxRow:g9,checkboxLabel:v9,fieldError:y9};function b9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const _9=100;function x9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:_9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const hk=y.createContext(void 0),k9=4e3;function S9({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=k9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(hk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function mn(){const t=y.useContext(hk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const ym="grackle-theme",gk="grackle-prefer-system",vk="(prefers-color-scheme: dark)";let Jr=[],cd;function Op(){cd=void 0;for(const t of Jr)t()}function bm(){return typeof window>"u"?!1:window.matchMedia(vk).matches}function nl(){if(typeof localStorage>"u")return l_;try{const t=localStorage.getItem(ym);if(t!==null&&dk.has(t))return t}catch{}return l_}function kd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(gk)==="true"}catch{return!1}}function _m(t){return Ld.find(s=>s.variantLightId===t||s.variantDarkId===t)}function yk(t,s){const o=vm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?bm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=_m(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return bm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=yk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),kd());function j9(){return cd===void 0&&(cd={themeId:nl(),systemDark:bm(),preferSystem:kd()}),cd}function T9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function N9(){const t=y.useSyncExternalStore(T9,j9),{themeId:s,preferSystem:o}=t,r=yk(s,o),c=y.useCallback(u=>{if(dk.has(u)){try{localStorage.setItem(ym,u)}catch{}Ao(u,kd(),!0),Op()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(gk,u?"true":"false")}catch{}if(u){const p=nl(),m=vm(p);if(m!=null&&m.hidden){const g=_m(p);if(g)try{localStorage.setItem(ym,g.id)}catch{}}}Ao(nl(),u,!0),Op()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(vk),p=()=>{const m=nl(),g=kd();if(g){const v=vm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=_m(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Op()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const bk=y.createContext(void 0);function w9({children:t}){const s=N9();return a.jsx(bk.Provider,{value:s,children:t})}function xh(){const t=y.useContext(bk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const _k=y.createContext(void 0),xk=y.createContext(void 0);function C9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(xk.Provider,{value:r,children:a.jsx(_k.Provider,{value:s,children:t})})}function E9(){return y.useContext(_k)}function A9(){const t=y.useContext(xk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const kh=y.createContext(void 0);function pt(){const t=y.useContext(kh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function kk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Sk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function D9(t){return kk(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")&&(t.turnId===void 0||typeof t.turnId=="string")&&(t.serverSeq===void 0||typeof t.serverSeq=="string")}const M9=new Set(["off","subscription","api_key"]),Jc=new Set(["off","on"]);function R9(t){return kk(t)&&M9.has(t.claude)&&Jc.has(t.github)&&Jc.has(t.copilot)&&Jc.has(t.codex)&&Jc.has(t.goose)}function jk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function Tk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Co=5e3;function I9(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const Ai={label:"Home",url:Fo};function O9(t){return t?[Ai,{label:"Settings",url:Ti},{label:t,url:void 0}]:[Ai,{label:"Settings",url:void 0}]}const Nk={label:"Environments",url:zo};function B9(){return[Ai,{label:"Environments",url:void 0}]}function L9(){return[Ai,{label:"New Chat",url:void 0}]}function z9(t){return[Ai,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function $9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ai,Nk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function H9(t,s,o,r,c){const d=I9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ai];v&&g&&(b.push(Nk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:Ci(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:ls(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function Sh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function h_(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function P9(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Bp(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function jh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Bp(u,s.get(u),h_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Bp(u,s.get(u),P9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Bp(u,s.get(u),h_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function U9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=wk(s),d=s.filter(m=>xm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||xm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function wk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function xm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function V9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=wk(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):xm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function q9(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function G9(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
331
331
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
332
332
|
const header = req.headers.authorization;
|
|
333
333
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -757,5 +757,5 @@ const grackle = await host.mcpServer({
|
|
|
757
757
|
url: env.vars.GRACKLE_MCP_URL,
|
|
758
758
|
});
|
|
759
759
|
|
|
760
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(d_,{selectedTools:Y,onChange:ue=>{U(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(bs,{isOpen:X,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>te(!1)})]})}function pq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=mn(),d=xt();return a.jsx($7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(mC),onNavigateToSchedule:u=>d(hx(u))})}const mq="_container_1g4qh_1",hq="_form_1g4qh_7",gq="_formActions_1g4qh_66",vq="_editableSection_1g4qh_73",yq="_helperText_1g4qh_84",bq="_metaSection_1g4qh_90",_q="_optional_1g4qh_108",xq="_readonlyValue_1g4qh_113",Bn={container:mq,form:hq,formActions:gq,editableSection:vq,helperText:yq,metaSection:bq,optional:_q,readonlyValue:xq};function I_(){const{scheduleId:t}=pa(),s=xt(),{showToast:o}=mn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx(zn,{to:ap,replace:!0});const _=[{label:"Settings",url:Ti},{label:"Schedules",url:ap},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(ma,{segments:_}),a.jsx(kq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(ap)},showToast:o})]})}function kq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,B]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(O=>({value:O.id,label:O.name})),U=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],X=O=>{O.preventDefault(),$&&c(v,_,S,T,C||void 0).then(q=>{m("Schedule created","success"),g(hx(q.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},te=(O,q)=>{t&&d(t.id,{[O]:q}).then(()=>{m("Schedule updated","success"),O==="title"&&b(String(q)),O==="description"&&k(String(q)),O==="scheduleExpression"&&j(String(q)),O==="personaId"&&N(String(q))},()=>{m("Failed to update schedule","error")})},G=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ne=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:X,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:O=>b(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s) | Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:O=>N(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:U.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(an,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:G,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(an,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx($t,{value:v,onSave:O=>{te("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:B,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx($t,{value:_,onSave:O=>{te("description",O)},fieldId:"schedule-description",activeFieldId:R,onActivate:B,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx($t,{value:S,onSave:O=>{te("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:B,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(xd,{value:T,onSave:O=>{te("personaId",O)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:B,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(O=>O.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",hm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",tk(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",hm(t.createdAt)]})]})]}):null,a.jsx(bs,{isOpen:A,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:ne,onCancel:()=>E(!1)})]})}function Sq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=xh();return a.jsx(tL,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function jq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function Tq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=jq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(fB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(aL,{connectionStatus:t,environments:s,sessions:o})]})}function Nq(){return a.jsx(Y8,{})}function wq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(b8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const O_=Ii();function Cq(){const t=xt();return Ya({key:"?"},()=>{t(hC)}),Ya({key:"n"},()=>{t(O_)}),Ya({key:"N"},()=>{t(O_)}),a.jsx(a.Fragment,{})}function $d(t){const s=A9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function Eq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(UO,{workspaces:t,tasks:s}),[t,s]);return $d(o),a.jsx(Ri,{})}function Aq(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(cO,{environments:t}),[t]);return $d(s),a.jsx(Ri,{})}function Dq(){const t=y.useMemo(()=>a.jsx(q7,{}),[]);return $d(t),a.jsx(Ri,{})}function Mq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(y5,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return $d(u),a.jsx(Ri,{})}const Rq="_wizard_1260s_1",Iq="_container_1260s_10",Oq="_stepContent_1260s_19",Bq="_logoArea_1260s_28",Lq="_logoImage_1260s_32",zq="_heading_1260s_41",$q="_tagline_1260s_49",Hq="_subtitle_1260s_56",Pq="_featureList_1260s_64",Uq="_runtimeGrid_1260s_89",Vq="_runtimeCard_1260s_101",qq="_runtimeName_1260s_133",Gq="_runtimeDescription_1260s_139",Fq="_buttonRow_1260s_144",Kq="_primaryButton_1260s_151",Zq="_ghostButton_1260s_185",Yq="_dots_1260s_213",Jq="_dot_1260s_213",Xe={wizard:Rq,container:Iq,stepContent:Oq,logoArea:Bq,logoImage:Lq,heading:zq,tagline:$q,subtitle:Hq,featureList:Pq,runtimeGrid:Uq,runtimeCard:Vq,runtimeName:qq,runtimeDescription:Gq,buttonRow:Fq,primaryButton:Kq,ghostButton:Zq,dots:Yq,dot:Jq};function Wq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Bd("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Xq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Qq=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function eG({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Qq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function tG(){return typeof Notification<"u"}function nG({onFinish:t,onBack:s,finishDisabled:o}){const r=tG(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const sG=4,B_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function aG(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=mn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=B_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===gy);if(N&&j!==N.runtime){const C=B_[j]??"sonnet";T.push(s(gy,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(os,{mode:"wait",children:a.jsxs(Ut.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Wq,{onNext:()=>p(1)}),u===1&&a.jsx(Xq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(eG,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(nG,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:sG},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const iG="_root_zndgp_1",oG="_body_zndgp_7",rG="_main_zndgp_19",lG="_sidebarWrapper_zndgp_26",cG="_overlay_zndgp_51",Wr={root:iG,body:oG,main:rG,sidebarWrapper:lG,overlay:cG},dG=y.lazy(()=>Nm(()=>import("./KnowledgePage-Dbp2FOCL.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),uG=y.lazy(()=>Nm(()=>import("./SessionsListPage-CWjrzCjE.js"),__vite__mapDeps([6,1,2,4,7])).then(t=>({default:t.SessionsListPage}))),Dk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function fG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=mn(),p=Wt(),m=E9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(D5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx($5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(G5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Ri,{}),a.jsx(Q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(tB,{toasts:d,onDismiss:u}),a.jsx(Cq,{})]})}function pG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=zd(),{showToast:m}=mn();$H(s,m),qH(c,m),HH(o,r,m);const g=xt(),v=Wt(),b=y.useRef(void 0);if(y.useEffect(()=>{t&&t!==b.current&&!v.pathname.includes("/tasks/")&&(b.current=t,g(gl(t),{replace:!0}))},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const _=cH(p);return a.jsx(C9,{children:a.jsxs("div",{className:Wr.root,children:[Dk&&a.jsx(qC,{}),a.jsx(fG,{tabs:_})]})})}function Vp(){const{workspaceId:t}=pa(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function mG(){const{pluginNames:t}=zd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(Ew,{children:[a.jsx(Ce,{path:"setup",element:a.jsx(aG,{})}),a.jsxs(Ce,{element:a.jsx(pG,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(CU,{})}),a.jsx(Ce,{path:"sessions/new",element:a.jsx(ZU,{})}),a.jsx(Ce,{path:"chat",element:a.jsx(zU,{})}),a.jsx(Ce,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(Ce,{path:"coordination",element:a.jsx(KU,{})}),a.jsx(Ce,{path:"sessions",element:a.jsx(y.Suspense,{fallback:a.jsx(mm,{}),children:a.jsx(uG,{})})}),a.jsx(Ce,{path:"sessions/:sessionId",element:a.jsx(XU,{})}),o&&a.jsx(Ce,{element:a.jsx(Mq,{}),children:a.jsx(Ce,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(mm,{}),children:a.jsx(dG,{})})})}),s&&a.jsxs(Ce,{element:a.jsx(Eq,{}),children:[a.jsx(Ce,{path:"tasks",element:a.jsx(NU,{})}),a.jsx(Ce,{path:"tasks/new",element:a.jsx(A_,{})}),a.jsx(Ce,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ce,{element:a.jsx(Aq,{}),children:[a.jsx(Ce,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ce,{path:"workspaces/new",element:a.jsx(pV,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(nV,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(A_,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ce,{path:"environments",element:a.jsx(_V,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(wU,{})}),a.jsx(Ce,{path:"new",element:a.jsx(hV,{})}),a.jsx(Ce,{path:":environmentId",element:a.jsx(JV,{})}),a.jsx(Ce,{path:":environmentId/edit",element:a.jsx(gV,{})})]})]}),a.jsx(Ce,{element:a.jsx(Dq,{}),children:a.jsxs(Ce,{path:"settings",element:a.jsx(QV,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(Ce,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ce,{path:"credentials",element:a.jsx(eq,{})}),a.jsx(Ce,{path:"github-accounts",element:a.jsx(tq,{})}),a.jsx(Ce,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(Ce,{path:"personas",element:a.jsx(nq,{})}),a.jsx(Ce,{path:"personas/new",element:a.jsx(R_,{})}),a.jsx(Ce,{path:"personas/:personaId",element:a.jsx(R_,{})}),a.jsx(Ce,{path:"schedules",element:a.jsx(pq,{})}),a.jsx(Ce,{path:"schedules/new",element:a.jsx(I_,{})}),a.jsx(Ce,{path:"schedules/:scheduleId",element:a.jsx(I_,{})}),a.jsx(Ce,{path:"appearance",element:a.jsx(Sq,{})}),a.jsx(Ce,{path:"shortcuts",element:a.jsx(Nq,{})}),a.jsx(Ce,{path:"plugins",element:a.jsx(wq,{})}),a.jsx(Ce,{path:"about",element:a.jsx(Tq,{})})]})}),a.jsx(Ce,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const hG=1e4;function gG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),hG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(os,{mode:"wait",children:r?a.jsx(Ut.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(mm,{})},"splash"):a.jsx(Ut.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(eC,{basename:"/".replace(/\/$/,""),children:a.jsx(mG,{})})},"app")})}function vG(){const t=Dk?nH:zH;return a.jsx(iH,{children:a.jsx(w9,{children:a.jsx(S9,{children:a.jsx(t,{children:a.jsx(gG,{})})})})})}bj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(vG,{})}));export{os as A,ma as B,fa as C,Ye as I,bx as K,UT as M,qp as S,pt as a,Ap as b,Re as c,F_ as d,Ho as e,hm as f,Ms as g,nT as h,Ut as m,gl as s,ls as t,xt as u};
|
|
761
|
-
//# sourceMappingURL=index-
|
|
760
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(d_,{selectedTools:Y,onChange:ue=>{U(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,a.jsx(bs,{isOpen:X,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>te(!1)})]})}function pq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=mn(),d=xt();return a.jsx($7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(mC),onNavigateToSchedule:u=>d(hx(u))})}const mq="_container_1g4qh_1",hq="_form_1g4qh_7",gq="_formActions_1g4qh_66",vq="_editableSection_1g4qh_73",yq="_helperText_1g4qh_84",bq="_metaSection_1g4qh_90",_q="_optional_1g4qh_108",xq="_readonlyValue_1g4qh_113",Bn={container:mq,form:hq,formActions:gq,editableSection:vq,helperText:yq,metaSection:bq,optional:_q,readonlyValue:xq};function I_(){const{scheduleId:t}=pa(),s=xt(),{showToast:o}=mn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx(zn,{to:ap,replace:!0});const _=[{label:"Settings",url:Ti},{label:"Schedules",url:ap},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(ma,{segments:_}),a.jsx(kq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(ap)},showToast:o})]})}function kq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,B]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(O=>({value:O.id,label:O.name})),U=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],X=O=>{O.preventDefault(),$&&c(v,_,S,T,C||void 0).then(q=>{m("Schedule created","success"),g(hx(q.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},te=(O,q)=>{t&&d(t.id,{[O]:q}).then(()=>{m("Schedule updated","success"),O==="title"&&b(String(q)),O==="description"&&k(String(q)),O==="scheduleExpression"&&j(String(q)),O==="personaId"&&N(String(q))},()=>{m("Failed to update schedule","error")})},G=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ne=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:X,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:O=>b(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s) | Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:O=>N(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:U.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(an,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:G,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(an,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx($t,{value:v,onSave:O=>{te("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:B,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx($t,{value:_,onSave:O=>{te("description",O)},fieldId:"schedule-description",activeFieldId:R,onActivate:B,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx($t,{value:S,onSave:O=>{te("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:B,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(xd,{value:T,onSave:O=>{te("personaId",O)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:B,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(O=>O.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",hm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",tk(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",hm(t.createdAt)]})]})]}):null,a.jsx(bs,{isOpen:A,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:ne,onCancel:()=>E(!1)})]})}function Sq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=xh();return a.jsx(tL,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function jq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function Tq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=jq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(fB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(aL,{connectionStatus:t,environments:s,sessions:o})]})}function Nq(){return a.jsx(Y8,{})}function wq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(b8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const O_=Ii();function Cq(){const t=xt();return Ya({key:"?"},()=>{t(hC)}),Ya({key:"n"},()=>{t(O_)}),Ya({key:"N"},()=>{t(O_)}),a.jsx(a.Fragment,{})}function $d(t){const s=A9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function Eq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(UO,{workspaces:t,tasks:s}),[t,s]);return $d(o),a.jsx(Ri,{})}function Aq(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(cO,{environments:t}),[t]);return $d(s),a.jsx(Ri,{})}function Dq(){const t=y.useMemo(()=>a.jsx(q7,{}),[]);return $d(t),a.jsx(Ri,{})}function Mq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(y5,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return $d(u),a.jsx(Ri,{})}const Rq="_wizard_1260s_1",Iq="_container_1260s_10",Oq="_stepContent_1260s_19",Bq="_logoArea_1260s_28",Lq="_logoImage_1260s_32",zq="_heading_1260s_41",$q="_tagline_1260s_49",Hq="_subtitle_1260s_56",Pq="_featureList_1260s_64",Uq="_runtimeGrid_1260s_89",Vq="_runtimeCard_1260s_101",qq="_runtimeName_1260s_133",Gq="_runtimeDescription_1260s_139",Fq="_buttonRow_1260s_144",Kq="_primaryButton_1260s_151",Zq="_ghostButton_1260s_185",Yq="_dots_1260s_213",Jq="_dot_1260s_213",Xe={wizard:Rq,container:Iq,stepContent:Oq,logoArea:Bq,logoImage:Lq,heading:zq,tagline:$q,subtitle:Hq,featureList:Pq,runtimeGrid:Uq,runtimeCard:Vq,runtimeName:qq,runtimeDescription:Gq,buttonRow:Fq,primaryButton:Kq,ghostButton:Zq,dots:Yq,dot:Jq};function Wq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Bd("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function Xq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Qq=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function eG({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Qq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function tG(){return typeof Notification<"u"}function nG({onFinish:t,onBack:s,finishDisabled:o}){const r=tG(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const sG=4,B_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function aG(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=mn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=B_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===gy);if(N&&j!==N.runtime){const C=B_[j]??"sonnet";T.push(s(gy,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(os,{mode:"wait",children:a.jsxs(Ut.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Wq,{onNext:()=>p(1)}),u===1&&a.jsx(Xq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(eG,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(nG,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:sG},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const iG="_root_zndgp_1",oG="_body_zndgp_7",rG="_main_zndgp_19",lG="_sidebarWrapper_zndgp_26",cG="_overlay_zndgp_51",Wr={root:iG,body:oG,main:rG,sidebarWrapper:lG,overlay:cG},dG=y.lazy(()=>Nm(()=>import("./KnowledgePage-pdM88IVS.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),uG=y.lazy(()=>Nm(()=>import("./SessionsListPage-CL-9RybL.js"),__vite__mapDeps([6,1,2,4,7])).then(t=>({default:t.SessionsListPage}))),Dk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function fG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=mn(),p=Wt(),m=E9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(D5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx($5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(G5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Ri,{}),a.jsx(Q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(tB,{toasts:d,onDismiss:u}),a.jsx(Cq,{})]})}function pG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=zd(),{showToast:m}=mn();$H(s,m),qH(c,m),HH(o,r,m);const g=xt(),v=Wt(),b=y.useRef(void 0);if(y.useEffect(()=>{t&&t!==b.current&&!v.pathname.includes("/tasks/")&&(b.current=t,g(gl(t),{replace:!0}))},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const _=cH(p);return a.jsx(C9,{children:a.jsxs("div",{className:Wr.root,children:[Dk&&a.jsx(qC,{}),a.jsx(fG,{tabs:_})]})})}function Vp(){const{workspaceId:t}=pa(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function mG(){const{pluginNames:t}=zd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(Ew,{children:[a.jsx(Ce,{path:"setup",element:a.jsx(aG,{})}),a.jsxs(Ce,{element:a.jsx(pG,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(CU,{})}),a.jsx(Ce,{path:"sessions/new",element:a.jsx(ZU,{})}),a.jsx(Ce,{path:"chat",element:a.jsx(zU,{})}),a.jsx(Ce,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(Ce,{path:"coordination",element:a.jsx(KU,{})}),a.jsx(Ce,{path:"sessions",element:a.jsx(y.Suspense,{fallback:a.jsx(mm,{}),children:a.jsx(uG,{})})}),a.jsx(Ce,{path:"sessions/:sessionId",element:a.jsx(XU,{})}),o&&a.jsx(Ce,{element:a.jsx(Mq,{}),children:a.jsx(Ce,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(mm,{}),children:a.jsx(dG,{})})})}),s&&a.jsxs(Ce,{element:a.jsx(Eq,{}),children:[a.jsx(Ce,{path:"tasks",element:a.jsx(NU,{})}),a.jsx(Ce,{path:"tasks/new",element:a.jsx(A_,{})}),a.jsx(Ce,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ce,{element:a.jsx(Aq,{}),children:[a.jsx(Ce,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ce,{path:"workspaces/new",element:a.jsx(pV,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Vp,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(nV,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(A_,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ce,{path:"environments",element:a.jsx(_V,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(wU,{})}),a.jsx(Ce,{path:"new",element:a.jsx(hV,{})}),a.jsx(Ce,{path:":environmentId",element:a.jsx(JV,{})}),a.jsx(Ce,{path:":environmentId/edit",element:a.jsx(gV,{})})]})]}),a.jsx(Ce,{element:a.jsx(Dq,{}),children:a.jsxs(Ce,{path:"settings",element:a.jsx(QV,{}),children:[a.jsx(Ce,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(Ce,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ce,{path:"credentials",element:a.jsx(eq,{})}),a.jsx(Ce,{path:"github-accounts",element:a.jsx(tq,{})}),a.jsx(Ce,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(Ce,{path:"personas",element:a.jsx(nq,{})}),a.jsx(Ce,{path:"personas/new",element:a.jsx(R_,{})}),a.jsx(Ce,{path:"personas/:personaId",element:a.jsx(R_,{})}),a.jsx(Ce,{path:"schedules",element:a.jsx(pq,{})}),a.jsx(Ce,{path:"schedules/new",element:a.jsx(I_,{})}),a.jsx(Ce,{path:"schedules/:scheduleId",element:a.jsx(I_,{})}),a.jsx(Ce,{path:"appearance",element:a.jsx(Sq,{})}),a.jsx(Ce,{path:"shortcuts",element:a.jsx(Nq,{})}),a.jsx(Ce,{path:"plugins",element:a.jsx(wq,{})}),a.jsx(Ce,{path:"about",element:a.jsx(Tq,{})})]})}),a.jsx(Ce,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const hG=1e4;function gG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),hG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(os,{mode:"wait",children:r?a.jsx(Ut.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(mm,{})},"splash"):a.jsx(Ut.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(eC,{basename:"/".replace(/\/$/,""),children:a.jsx(mG,{})})},"app")})}function vG(){const t=Dk?nH:zH;return a.jsx(iH,{children:a.jsx(w9,{children:a.jsx(S9,{children:a.jsx(t,{children:a.jsx(gG,{})})})})})}bj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(vG,{})}));export{os as A,ma as B,fa as C,Ye as I,bx as K,UT as M,qp as S,pt as a,Ap as b,Re as c,F_ as d,Ho as e,hm as f,Ms as g,nT as h,Ut as m,gl as s,ls as t,xt as u};
|
|
761
|
+
//# sourceMappingURL=index-DcnUq-w_.js.map
|