1import{K as Q,r as n,b9 as G,j as e,B as J,b2 as U,c as i,L as X,ba as Y,bb as Z,bc as ee}from"./index-CPaYb3xI.js";import{r as re}from"./package-icon-Bm9VlHox.js";import{C as T}from"./copy-badge-DTEV2Aji.js";import{f as q}from"./format-relative-time-cNw4UkeX.js";import"./tooltip-D7tB-7w9.js";import"./index-B-8uziNJ.js";import"./index-Be0Um-nQ.js";function y({label:t,value:d}){return e.jsxs("div",{className:"rounded-lg border border-border/60 bg-surface-1/50 px-3 py-2",children:[e.jsx("p",{className:"font-medium text-muted-foreground text-xs uppercase tracking-[var(--tracking-label)]",children:t}),e.jsx("p",{className:"mt-0.5 font-semibold text-sm tabular-nums tracking-tight",children:d})]})}function S({status:t}){const d=t==="success"||t==="ok",x=t==="failed"||t==="error";return e.jsx("span",{className:i("inline-flex rounded-full border px-2 py-0.5 font-semibold text-[11px] uppercase tracking-wide",d&&"border-emerald-500/30 bg-emerald-500/10 text-emerald-600",x&&"border-red-500/30 bg-red-500/10 text-red-600",!(d||x)&&"border-border/70 bg-surface-1 text-muted-foreground"),children:t})}function b(t){const d=(t.namespace??"").toLowerCase(),x=(t.mode??"").toLowerCase(),l=(t.env??"").toLowerCase(),k=(t.summary??"").toLowerCase();return d==="cloudflare-containers"||l==="cloudflare-containers"||x.includes("containers")||k.includes("worker+container")||k.includes("container `")?"cf-container":d==="cloudflare-workers"||l==="cloudflare-workers"||x.startsWith("cloudflare-")||x.startsWith("workers-")?"cf-worker":t.kubeContext||d&&!d.startsWith("cloudflare")?"kubernetes":"other"}function z({surface:t}){const d=t==="cf-worker"?"CF Worker":t==="cf-container"?"CF Container":t==="kubernetes"?"Kubernetes":"Deploy";return e.jsx("span",{className:i("inline-flex rounded-full border px-2 py-0.5 font-semibold text-xs tracking-wide",t==="cf-worker"&&"border-orange-500/30 bg-
1orange-500/10 text-orange-700 dark:text-orange-300",t==="cf-container"&&"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",t==="kubernetes"&&"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",t==="other"&&"border-border/70 bg-surface-1 text-muted-foreground"),children:d})}function se({initialItems:t,initialCommands:d}){const x=Q(),[l,k]=n.useState(t),[m,V]=n.useState(d),[u,W]=n.useState(null),[g,B]=n.useState(null),[h,A]=n.useState(null),[j,O]=n.useState(""),[v,F]=n.useState(t[0]?.id??null),[w,L]=n.useState(d[0]?.id??null),[R,_]=n.useTransition(),[I,D]=n.useState(null),[M,K]=n.useState(!1),p=n.useMemo(()=>l.find(r=>r.id===v)??l[0]??null,[l,v]),o=I?.id===p?.id?I:p,c=n.useMemo(()=>m.find(r=>r.id===w)??m[0]??null,[m,w]);n.useEffect(()=>{const r=p?.id;if(!r){D(null);return}if(p.logsComplete!==!1&&!p.logsR2Key){D(p);return}let s=!1;return K(!0),G({data:{id:r}}).then(a=>{!s&&a&&D(a)}).finally(()=>{s||K(!1)}),()=>{s=!0}},[p]);const N=n.useMemo(()=>{const r=l.filter(f=>f.status==="failed").length,s=l.filter(f=>f.status==="success").length,a=l.filter(f=>b(f)==="cf-worker").length,C=l.filter(f=>b(f)==="cf-container").length;return{total:l.length,failed:r,ok:s,cfWorker:a,cfContainer:C}},[l]),E=n.useMemo(()=>{const r=j.trim().toLowerCase();return l.filter(s=>u&&s.status!==u||g&&b(s)!==g?!1:r?[s.target,s.env,s.mode,s.namespace,s.projectName,s.repositoryFullName,s.error,s.summary,s.logs,s.services.join(" "),b(s)].filter(Boolean).join(` 2`).toLowerCase().includes(r):!0)},[l,u,g,j]),$=n.useMemo(()=>{const r=new Map;for(const s of m)r.set(s.command,(r.get(s.command)??0)+1);return[...r.entries()].sort((s,a)=>a[1]-s[1]||s[0].localeCompare(a[0]))},[m]),P=n.useMemo(()=>{const r=j.trim().toLowerCase();return m.filter(s=>u&&s.status!==u||h&&s.command!==h?!1:r?[s.command,s.action,s.message,s.details,s.hint,s.projectPath,s.repositoryFullName].filter(Boolean).join(` 3`).toLowerCase().includes(r):!0)},[m,u,h,j]),H=()=>{_(async()=>{const[r,s]=await Promise.all([Y({data:{limit:100}}),Z({data:{limit:150}})]);k(r),V(s),v&&!r.some(a=>a.id===v)&&F(r[0]?.id??null),w&&!s.some(a=>a.id===w)&&L(s[0]?.id??null),await x.invalidate()})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"size-5 text-muted-foreground"}),e.jsx("h1",{className:"font-semibold text-xl tracking-tight",children:"Deploys & ops"})]}),e.jsxs("p",{className:"max-w-2xl text-muted-foreground text-sm",children:["Authenticated ",e.jsx("code",{className:"text-xs",children:"xbp deploy"}),","," ",e.jsx("code",{className:"text-xs",children:"xbp cloudflare deploy"}),","," ",e.jsx("code",{className:"text-xs",children:"xbp workers deploy"}),","," ",e.jsx("code",{className:"text-xs",children:"xbp kubernetes"}),", and"," ",e.jsx("code",{className:"text-xs",children:"xbp service"})," results (success and failure) are soft-ingested to D1. Kubernetes deploys keep full build/apply logs; Cloudflare Worker, Container, and OpenNext deploys show under Deploy runs with surface badges and modes like"," ",e.jsx("code",{className:"text-xs",children:"cloudflare-deploy"}),","," ",e.jsx("code",{className:"text-xs",children:"workers-run"}),","," ",e.jsx("code",{className:"text-xs",children:"cloudflare-containers-push"}),"."]})]}),e.jsxs(J,{disabled:R,onClick:H,size:"sm",type:"button",variant:"outline",children:[e.jsx(U,{className:i("size-3.5",R&&"animate-spin")}),"Refresh"]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[e.jsx(y,{label:"Total",value:String(N.total)}),e.jsx(y,{label:"Success",value:String(N.ok)}),e.jsx(y,{label:"Failed",value:String(N.failed)}),e.jsx(y,{label:"CF Worker",value:String(N.cfWorker)}),e.jsx(y,{label:"CF Container",value:String(N.cfContainer)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{className:i("rounded-full border px-2.5 py-1 text-xs",u||g?"border-border/70 text-muted-foreground":"border-foreground
3/15 bg-foreground text-background"),onClick:()=>{W(null),B(null)},type:"button",children:"All"}),["failed","success"].map(r=>e.jsx("button",{className:i("rounded-full border px-2.5 py-1 text-xs",u===r?"border-foreground/15 bg-foreground text-background":"border-border/70 text-muted-foreground"),onClick:()=>W(s=>s===r?null:r),type:"button",children:r},r)),[["cf-worker","CF Worker"],["cf-container","CF Container"],["kubernetes","Kubernetes"]].map(([r,s])=>e.jsx("button",{className:i("rounded-full border px-2.5 py-1 text-xs",g===r?"border-foreground/15 bg-foreground text-background":"border-border/70 text-muted-foreground"),onClick:()=>B(a=>a===r?null:r),type:"button",children:s},r)),e.jsx("input",{className:"ml-auto h-8 min-w-48 flex-1 rounded-md border border-border/70 bg-background px-2.5 text-sm outline-none focus:border-foreground/30",onChange:r=>O(r.target.value),placeholder:"Filter target, mode, error, logsâ¦",value:j})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"font-semibold text-sm tracking-tight",children:"Command results"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"xbp kubernetes · service · deploy · cloudflare · workers · redeploy · oci"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{className:i("rounded-full border px-2.5 py-1 text-xs",h?"border-border/70 text-muted-foreground":"border-foreground
3/15 bg-foreground text-background"),onClick:()=>A(null),type:"button",children:"All commands"}),$.map(([r,s])=>e.jsxs("button",{className:i("rounded-full border px-2.5 py-1 text-xs",h===r?"border-foreground/15 bg-foreground text-background":"border-border/70 text-muted-foreground"),onClick:()=>A(a=>a===r?null:r),type:"button",children:[r," ",e.jsx("span",{className:"tabular-nums opacity-70",children:s})]},r))]}),P.length===0?e.jsxs("div",{className:"rounded-xl border border-border/80 border-dashed bg-surface-1/40 px-6 py-8 text-center text-muted-foreground text-sm",children:["No command activity yet. Run ",e.jsx(T,{value:"xbp login"})," then"," ",e.jsx("code",{className:"text-xs",children:"xbp kubernetes"})," /"," ",e.jsx("code",{className:"text-xs",children:"xbp service"})," /"," ",e.jsx("code",{className:"text-xs",children:"xbp deploy"}),"."]}):e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"border-border/60 border-b bg-surface-1/60 text-[11px] text-muted-foreground uppercase tracking-[0.12em]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"When"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Command"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Message"})]})}),e.jsx("tbody",{children:P.map(r=>{const s=c?.id===r.id;return e.jsxs("tr",{className:i("cursor-pointer border-border/40 border-b transition-colors",s?"bg-foreground
3/5":"hover:bg-surface-1/50"),onClick:()=>L(r.id),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&L(r.id)},tabIndex:0,children:[e.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs tabular-nums",children:q(r.occurredAt)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(S,{status:r.status})}),e.jsxs("td",{className:"px-3 py-2 font-medium",children:[r.command,r.action?e.jsx("span",{className:"ml-1 font-normal text-muted-foreground text-xs",children:r.action}):null]}),e.jsx("td",{className:"max-w-56 truncate px-3 py-2 text-muted-foreground text-xs",children:r.message})]},r.id)})})]})}),e.jsx("div",{className:"rounded-xl border border-border/70 bg-surface-1/30 p-4",children:c?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{status:c.status}),e.jsx("span",{className:"font-semibold",children:c.command}),c.action?e.jsxs("span",{className:"text-muted-foreground",children:["· ",c.action]}):null]}),e.jsx("pre",{className:"wrap-break-word max-h-48 overflow-auto whitespace-pre-wrap rounded-lg border border-border/60 bg-background p-3 font-mono text-[11px]",children:c.message}),c.details?e.jsx("pre",{className:"wrap-break-word max-h-64 overflow-auto whitespace-pre-wrap rounded-lg border border-border/60 bg-background p-3 font-mono text-[11px] text-muted-foreground",children:c.details}):null,c.hint?e.jsxs("p",{className:"text-amber-700 text-xs dark:text-amber-300",children:["Hint: ",c.hint]}):null,e.jsxs("p",{className:"text-muted-foreground text-xs",children:[c.repositoryFullName??c.projectPath??"â"," ","· xbp ",c.xbpVersion??"â"]})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a command result."})})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"font-semibold text-sm tracking-tight",children:"Deploy runs"}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"Kubernetes · Cloudflare Worker · Cloudflare Container · OpenNext"})]}),l.length===0?e.jsxs("div",{className:"rounded-xl border border-border/80 border-dashed bg-surface-1/40 px-6 py-8 text-center text-muted-foreground text-sm",children:["No deploy runs yet. After ",e.jsx(T,{value:"xbp login"}),", run"," ",e.jsx("code",{className:"text-xs",children:"xbp deploy ⦠--run"}),","," ",e.jsx("code",{className:"text-xs",children:"xbp cloudflare deploy --app â¦"}),", or"," ",e.jsx("code",{className:"text-xs",children:"xbp workers --app ⦠deploy run"})," to post activity here. Also see"," ",e.jsx(X,{className:"underline underline-offset-2",to:"/dashboard/cli-errors",children:"CLI errors"}),"."]}):E.length===0?e.jsx("div",{className:"rounded-xl border border-border/80 border-dashed bg-surface-1/40 px-6 py-8 text-center text-muted-foreground text-sm",children:"No deploys match this filter."}):e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.1fr)]",children:[e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"border-border/60 border-b bg-surface-1/60 text-[11px] text-muted-foreground uppercase tracking-[0.12em]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"When"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Surface"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Target"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Mode"})]})}),e.jsx("tbody",{children:E.map(r=>{const s=o?.id===r.id,a=b(r);return e.jsxs("tr",{className:i("cursor-pointer border-border/40 border-b transition-colors",s?"bg-foreground
3/5":"hover:bg-surface-1/50"),onClick:()=>F(r.id),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&F(r.id)},tabIndex:0,children:[e.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs tabular-nums",children:q(r.occurredAt)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(S,{status:r.status})}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(z,{surface:a})}),e.jsx("td",{className:"px-3 py-2 font-medium",children:r.target}),e.jsx("td",{className:"max-w-36 truncate px-3 py-2 text-muted-foreground text-xs",children:r.mode})]},r.id)})})]})}),e.jsx("div",{className:"rounded-xl border border-border/70 bg-surface-1/30 p-4",children:o?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{status:o.status}),e.jsx(z,{surface:b(o)}),e.jsx("span",{className:"font-semibold",children:o.target}),e.jsxs("span",{className:"text-muted-foreground",children:["· ",o.env]}),e.jsx("span",{className:"rounded-md border border-border/60 bg-background px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:o.mode})]}),e.jsxs("div",{className:"grid gap-1 text-muted-foreground text-xs sm:grid-cols-2",children:[e.jsxs("div",{children:["project:"," ",e.jsx("span",{className:"text-foreground",children:o.projectName??"â"})]}),e.jsxs("div",{children:["repo:"," ",e.jsx("span",{className:"text-foreground",children:o.repositoryFullName??"â"})]}),e.jsxs("div",{children:["namespace:"," ",e.jsx("span",{className:"text-foreground",children:o.namespace??"â"})]}),e.jsxs("div",{children:["xbp:"," ",e.jsx("span",{className:"text-foreground",children:o.xbpVersion??o.cliVersion??"â"})]}),e.jsxs("div",{className:"sm:col-span-2",children:["services:"," ",e.jsx("span",{className:"text-foreground",children:o.services.join(", ")||"â"})]})]}),o.error?e.jsx("div",{className:"rounded-lg border border-red-500/25 bg-red-500/5 p-3 text-red-700 text-sm dark:text-red-300",children:e.jsx("pre",{className:"wrap-break-word max-h-40 overflow-auto whitespace-pre-wrap font-mono text-xs",children:o.error})}):null,o.summary?e.jsx("p",{className:"text-muted-foreground text-sm",children:o.summary}):null,e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 font-medium text-muted-foreground text-xs uppercase tracking-[var(--tracking-label)]",children:b(o)==="kubernetes"?"Build / apply logs":"Deploy notes"}),e.jsx("pre",{className:"max-h-112 overflow-auto rounded-lg border border-border/60 bg-background p-3 font-mono text-[11px] text-foreground/90 leading-relaxed",children:M?"Loading full deploy logsâ¦":o.logs?.trim()||o.summary?.trim()||"(no logs captured)"}),o.logsComplete===!1&&!M?e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Showing preview",o.logsByteLength?` (${o.logsByteLength.toLocaleString()} bytes total)`:"","; open again if full body failed to load from storage."]}):null]})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a deploy to inspect details."})})]})]})]})}function ie(){const{items:t,commands:d}=ee.useLoaderData();return e.jsx(se,{initialCommands:d,initialItems:t})}export{ie as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.