import{ar as C,bc as I,bb as R,aY as o,aV as g,aT as t,a2 as T,V as y,aq as k,x as z,p as L,E as M,c as b,N as $,aE as A,aD as V}from"./chunk-02oqS8tD.js";import"./chunk-B8Q4vgLh.js";import"./chunk-x_Z6cwvR.js";/**
 * @license lucide-react v0.451.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const F=C("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),q=["all","failed","passed","error","stopped"];function _(){const s=I(e=>e.go),r=R(e=>e.projectId),[a,m]=o.useState([]),[n,p]=o.useState(null),[l,j]=o.useState("all"),[i,S]=o.useState(""),[d,u]=o.useState("loading"),[v,h]=o.useState(""),[N,f]=o.useState(!1),x=o.useCallback((e={})=>({...r===void 0?{}:{projectId:r},...l==="all"?{}:{status:l},...i.trim()===""?{}:{workflowId:i.trim()},limit:25,...e}),[r,l,i]),c=o.useCallback(async()=>{u("loading");try{const e=await g(x());m([...e.executions]),p(e.nextCursor),u("ready")}catch(e){h(e.message),u("error")}},[x]);o.useEffect(()=>{c()},[c]);const w=async()=>{if(n!==null){f(!0);try{const e=await g(x({cursor:n}));m(E=>[...E,...e.executions]),p(e.nextCursor)}catch(e){h(e.message)}finally{f(!1)}}};return t.jsxs(T,{title:"Execution history",subtitle:"Every run recorded for this workspace, newest first.",onBack:()=>s({name:"tools"}),actions:t.jsx(b,{size:"sm",variant:"outline",className:"h-7",onClick:()=>void c(),title:"Refresh",children:t.jsx($,{className:"h-3 w-3"})}),children:[t.jsxs(y,{title:"Filter",hint:"Applied on the server — the panel never holds the whole history.",children:[t.jsx("div",{className:"flex flex-wrap gap-1",children:q.map(e=>t.jsx("button",{type:"button",onClick:()=>j(e),className:k("min-h-6 rounded-md px-2 py-1 text-[10px] font-semibold capitalize",l===e?"bg-dynamic-azure/12 text-dynamic-azure":"text-muted-foreground hover:text-foreground"),children:e},e))}),t.jsxs("label",{className:"flex items-center gap-1.5 rounded-lg border border-stroke px-2 py-1 dark:border-stroke/30",children:[t.jsx(F,{className:"h-2.5 w-2.5 shrink-0 text-muted-foreground"}),t.jsx("input",{value:i,onChange:e=>S(e.target.value),placeholder:"Workflow id",className:"min-h-5 w-full bg-transparent text-[11px] outline-none placeholder:text-muted-foreground"})]})]}),d==="loading"&&t.jsx(z,{label:"Loading history…"}),d==="error"&&t.jsx(L,{title:"Could not load history",message:v,onRetry:()=>void c()}),d==="ready"&&a.length===0&&t.jsx(M,{title:"Nothing recorded yet",description:"No executions have been uploaded for this workspace. Run a tool, and its execution will appear here once it syncs."}),d==="ready"&&a.length>0&&t.jsxs(y,{title:`Executions · ${String(a.length)}${n===null?"":"+"}`,children:[t.jsx("div",{className:"space-y-1",children:a.map(e=>t.jsx(D,{row:e,onOpen:()=>s({name:"execution-detail",executionId:e.executionId})},e.executionId))}),n!==null&&t.jsx(b,{size:"sm",variant:"outline",className:"h-7 w-full",loading:N,onClick:()=>void w(),children:"Load more"})]})]})}const B={failed:"text-alert-orange",error:"text-alert-orange",passed:"text-emerald-700 dark:text-emerald-400",stopped:"text-muted-foreground",running:"text-muted-foreground"};function D({row:s,onOpen:r}){const a=s.failureSummary?.category;return t.jsxs("button",{type:"button",onClick:r,className:"flex min-h-6 w-full items-start gap-2 rounded-lg border border-stroke px-2 py-1.5 text-left hover:border-dynamic-azure/40 dark:border-stroke/30",children:[t.jsx("span",{className:k("mt-0.5 shrink-0 font-mono text-[9px] font-semibold uppercase",B[s.status]??"text-muted-foreground"),children:s.status}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block break-words text-[10.5px] font-medium leading-snug",children:s.title}),t.jsxs("span",{className:"mt-0.5 block font-mono text-[9px] text-muted-foreground",children:[A(s.startedAt),s.durationMs===void 0?"":` · ${V(s.durationMs)}`,s.browser===void 0?"":` · ${s.browser}`,s.appVersion===void 0?"":` · v${s.appVersion}`]}),a&&t.jsx("span",{className:"mt-0.5 block font-mono text-[9px] text-muted-foreground",children:a.toLowerCase().replace(/_/g," ")})]})]})}export{_ as ExecutionHistoryScreen};
//# sourceMappingURL=chunk-83u7hLvJ.js.map
