1import{z as Ae,y as $e,dU as Me,dV as Fe,r as i,A as Pe,dW as De,d3 as Be,de as He,dX as le,dY as w,j as e,c as Oe,W as oe,N as U,B as j,bQ as ie,q,f as C,J as ze,K as Ee,aq as F,dZ as Ue,d_ as qe,d$ as Ve,e0 as ce,e1 as Q,g as Qe,b0 as Ge,e2 as Ke}from"./index-_Ci2S7BU.js";import{c as Ye}from"./runDispatch-D18dLWtr.js";import{D as Je}from"./Drawer-DYyTHP-H.js";import{c as Xe,o as Ze,t as es,g as ss,r as ts,T as as,a as ns,R as rs,s as ls}from"./RunDetailView-JXUlOOIx.js";import{W as os,R as de,r as me,a as he}from"./WorkflowRunsWorkspace-CwrocMkL.js";import{L as xe}from"./layers-BxgLEag7.js";import"./serverWorkflowRun-CabnJYsl.js";import"./cronNext-CIXNkfgc.js";import"./runSummary-DyEksjly.js";import"./chatLaunchContext-DLaQcLXa.js";import"./FidgetMark-DQrAhRf7.js";import"./presentation-CxbZIyta.js";import"./WorkflowDeliveryProgress-MWFpUq5w.js";import"./clock-AOQfIQHm.js";import"./circle-DjktqpJb.js";import"./SourcingSlateChip-DRZ8iSok.js";import"./panel-right-BFB5jF4y.js";import"./calendar-clock-DHTkjPYG.js";import"./git-branch-CbCGzcmy.js";function P(t){return String(t.trigger||"").toLowerCase()==="cron"}function pe(t){const l=Q(t);if(!Number.isFinite(l))return"";const o=Date.now()-l,d=6e4,x=60*d,n=24*x;if(o<d)return"just now";if(o<x)return`${Math.round(o/d)}m ago`;if(o<n)return`${Math.round(o/x)}h ago`;if(o<7*n)return`${Math.round(o/n)}d ago`;try{return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(new Date(l))}catch{return""}}function fe(t,l=()=>null){return w(t)?t.name:Ke(t,l(t.workflow_id)?.name)}function V(t){return w(t)?t.title||t.name:me(t)}const is=t=>`agent:${t.definition_id||t.name}`,ue=t=>w(t?.runs?.[0]),cs={emerald:"bg-emerald-500",rose:"bg-rose-500",stone:"bg-stone-300",blue:"bg-blue-500",amber:"bg-amber-500"};function ds({runs:t}){const l=t.slice(0,14).reverse();return e.jsx("span",{className:"rn-spark",title:`Last ${l.length} runs`,"aria-hidden":"true",children:l.map((o,d)=>e.jsx("i",{className:cs[he(o).tone]||"bg-stone-200"},o.run_id||d))})}function us({group:t,onOpen:l,stale:o=!1}){const d=ls(t.runs).successRate,x=t.runs[0],n=d>=85?"text-emerald-600":d>=60?"text-amber-600":"text-rose-500",u=he(x,{stale:o}),m=u.badgeLabel,p=u.tone==="emerald"?"text-emerald-600":u.tone==="rose"?"text-rose-500":u.tone==="amber"?"text-amber-600":u.tone==="blue"?"text-blue-600":"text-stone-500";return e.jsxs(C,{as:"button",padding:"none",onClick:()=>l(t),className:"rn-card group grid w-full grid-cols-[1fr_auto] items-center gap-3 rounded-2xl px-4 py-4 sm:gap-5 sm:px-5 sm:py-5 text-left",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-stone-100 text-stone-500",children:e.jsx(xe,{size:14})}),e.jsx("span",{className:"line-clamp-2 break-words text-[16px] font-semibold tracking-[-0.01em] text-stone-900",children:t.name}),t.scheduled?e.jsx(Qe,{tone:"warning",children:"scheduled"}):null]}),t.aliases?.length?e.jsxs("p",{className:"mt-1.5 truncate pl-[38px] text-[11.5px] italic text-stone-400",children:["also ran as â",t.aliases.join("â, â"),"â"]}):null,e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 pl-[38px] text-[12.5px] text-stone-500",children:[m?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"last run"}),e.jsx("span",{className:F("font-medium",p),children:m}),e.jsx("span",{className:"text-stone-400",children:pe(x?.updated_at)}),e.jsx("span",{className:"text-stone-300",children:"·"})]}):null,e.jsxs("span",{className:F("font-mono font-medium",n),children:[d,"%"]}),e.jsx("span",{children:"success rate"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-6",children:[e.jsx("span",{className:"hidden sm:block",children:e.jsx(ds,{runs:t.runs})}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-mono text-[20px] font-medium leading-none tracking-tight text-stone-900",children:t.runCount}),e.jsx("div",{className:"mt-1 text-[10px] uppercase tracking-[0.1em] text-stone-400",children:"runs"})]}),e.jsx(Ge,{size:18,className:"text-stone-300 transition-colors group-hover:text-stone-600"})]})]})}const ms=t=>typeof t=="number"?t:"â",g="px-3 py-2.5 text-left font-mono text-[10.5px] font-normal uppercase tracking-[0.1em] text-stone-400";function hs({rows:t,selectedId:l,onOpen:o,stale:d=!1}){return e.jsx(C,{padding:"none",className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Task history table",tabIndex:0,children:e.jsxs("table",{className:"w-full border-collapse text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-stone-200",children:[e.jsx("th",{className:g,children:"Task"}),e.jsx("th",{className:`${g} hidden md:table-cell`,children:"Workflow"}),e.jsx("th",{className:`${g} hidden lg:table-cell`,children:"Type"}),e.jsx("th",{className:`${g} hidden md:table-cell`,children:"Status"}),e.jsx("th",{className:g,children:"Updated"}),e.jsx("th",{className:`${g} hidden text-right lg:table-cell`,children:"Duration"}),e.jsx("th",{className:`${g} hidden text-right lg:table-cell`,children:"Outputs"})]})}),e.jsx("tbody",{children:t.map(x=>{const n=Ue(x)||{},u=n.run_id===l,m=n.outputs_count??(Array.isArray(n.artifacts)?n.artifacts.length:void 0),p=w(n)?qe(n):"";return e.jsxs("tr",{onClick:()=>o(n.run_id),"aria-current":u?"true":void 0,className:F("cursor-pointer border-b border-stone-100 transition-colors last:border-0",u?"bg-paper-active":"hover:bg-paper-soft"),children:[e.jsxs("td",{className:"min-w-[200px] max-w-[320px] px-3 py-2.5 font-medium text-ink",children:[e.jsx(j,{unstyled:!0,className:"w-full text-left","aria-label":`Open task: ${V(n)}`,onClick:y=>{y.stopPropagation(),o(n.run_id)},children:e.jsx("span",{className:"line-clamp-2 break-words",title:V(n),children:V(n)})}),p?e.jsx("span",{className:"mt-0.5 block text-xs font-normal tabular-nums text-ink-mute",children:p}):null,e.jsx("span",{className:"mt-1 block md:hidden",children:e.jsx(de,{run:n,stale:d})}),e.jsx("span",{className:"mt-1 block text-xs font-normal text-ink-mute md:hidden",children:P(n)?"Scheduled":"Interactive"})]}),e.jsx("td",{className:"hidden max-w-[220px] truncate px-3 md:table-cell py-2.5 text-ink-soft",children:fe(n)}),e.jsx("td",{className:"hidden whitespace-nowrap px-3 py-2.5 text-ink-mute lg:table-cell",children:P(n)?"Scheduled":"Interactive"}),e.jsx("td",{className:"hidden px-3 py-2.5 md:table-cell",children:e.jsx(de,{run:n,stale:d})}),e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 text-ink-mute",children:pe(n.updated_at||n.created_at)||"â"}),e.jsx("td",{className:"hidden whitespace-nowrap px-3 py-2.5 text-right tabular-nums text-ink-mute lg:table-cell",children:ns(n)}),e.jsx("td",{className:"hidden whitespace-nowrap px-3 py-2.5 text-right tabular-nums text-ink-mute lg:table-cell",children:ms(m)})]},n.run_id)})})]})})})}function xs({runId:t,run:l=null,onClose:o}){return e.jsx(Je,{title:me(l||{}),onClose:o,className:"!max-w-[480px]",children:e.jsx(rs,{runId:t,run:l,embedded:!0},t)})}function Ms(){const t=Ae(),{mcpScopeLabel:l="this workspace",canRunAgentWorkflows:o,canOpenAgentWorkflows:d}=$e(),{rows:x,totalCount:n,loading:u,error:m,degraded:p,invalidate:y}=Me({anyStatus:!0,allPages:!0,intervalMs:9e3,includeDismissed:!0}),T=Fe({enabled:!!o}),G=i.useMemo(()=>T.rows.length?[...x,...T.rows.map(s=>({...s,_feedStale:T.stale}))]:x,[x,T]),[N,we]=i.useState("all"),[I,v]=Pe(),W=I.get("workflow")||I.get("view")==="workflow"?"workflow":"all",[D,ge]=i.useState(""),[B,ke]=i.useState("all"),[H,be]=i.useState(""),[_,je]=i.useState("all"),[L,ye]=i.useState("recent"),[Ne,ve]=i.useState(0);i.useEffect(()=>(De(),Be(()=>ve(s=>s+1))),[]);const A=i.useMemo(()=>He(),[Ne]),k=i.useMemo(()=>Xe(A),[A]),K=i.useMemo(()=>{const s=new Map;for(const a of A){const r=k(a.id);(!s.get(r)||a.id===r)&&s.set(r,a)}return s},[k,A]),Y=s=>K.get(k(s))||null,{all:f,scheduled:J,manual:X}=i.useMemo(()=>{const s=Ze(G);return{all:s,scheduled:s.filter(P),manual:s.filter(a=>!P(a))}},[G]),Z=(N==="scheduled"?J:N==="manual"?X:f).filter(s=>es(s,{query:D,status:B,registeredName:Y(s.workflow_id)?.name})),ee=f.filter(s=>le(s).group!=="finished").length,se=f.filter(w).length,Se=Math.max(n,f.length-se)+se,S=i.useMemo(()=>ss(f,{workflowIdOf:s=>w(s)?is(s):k(s.workflow_id),nameOf:s=>fe(s,Y),timeOf:s=>Q(s.updated_at)||Q(s.created_at)||0}),[f,k,K]),O=I.get("workflow")||"",Re=k(O),c=O&&S.find(s=>!ue(s)&&(s.workflowId===Re||s.key===O))||null,Ce=s=>{if(ue(s)){t(d?Ve(s.runs[0].definition_id):ce(s.runs[0]));return}v(a=>
1{const r=new URLSearchParams(a);return r.set("view","workflow"),r.set("workflow",s.workflowId||s.key),r.delete("run"),r})},Te=()=>v(s=>{const a=new URLSearchParams(s);return a.delete("workflow"),a.delete("run"),a}),b=I.get("run")||"",$=c?ts(c.runs,{requested:b}):{runId:"",requested:b,fallback:"none"},te=$.runId,R=W==="all"&&f.some(s=>s.run_id===b&&!w(s))?b:"",z=s=>v(a=>{const r=new URLSearchParams(a);return r.set("run",s),r}),E=()=>v(s=>{const a=new URLSearchParams(s);return a.delete("run"),a}),Ie=s=>{const a=f.find(r=>r.run_id===s);a&&w(a)?t(ce(a)):z(s)};i.useEffect(()=>{const s=a=>{const r=String(a.target?.tagName||"").toLowerCase();if(r==="input"||r==="textarea"||r==="select"||!a.target?.closest?.('[aria-label="Runs"]')||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const h=c?c.runs:[],ne=te;if(h.length<2||!ne)return;const M=h.findIndex(Le=>Le.run_id===ne);if(M<0)return;const re=a.key==="ArrowDown"?Math.min(h.length-1,M+1):Math.max(0,M-1);re!==M&&(a.preventDefault(),z(h[re].run_id))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[c,te]);const ae=i.useMemo(()=>{const s=H.trim().toLowerCase();let a=S.filter(r=>s&&!(r.name.toLowerCase().includes(s)||(r.aliases||[]).some(h=>h.toLowerCase().includes(s)))?!1:_==="failing"?r.runs.some(h=>le(h).finality.failed):_==="scheduled"?r.scheduled:!0);return a=a.slice().sort((r,h)=>L==="runs"?h.runCount-r.runCount:L==="name"?r.name.localeCompare(h.name):h.lastRunAt-r.lastRunAt),a},[S,H,_,L]),We=[{id:"all",label:`All tasks (${Se})`},{id:"workflow",label:`By workflow (${S.length})`,icon:xe}],_e=[{id:"all",label:`All (${f.length})`},{id:"scheduled",label:`Scheduled (${J.length})`},{id:"manual",label:`Manual (${X.length})`}];return e.jsx("div",{className:F("min-h-full",c?"agent-page-dotgrid":""),children:e.jsxs("div",{className:"mx-auto w-full max-w-[1200px] px-4 py-8 sm:px-8",children:[c?null:e.jsx(Oe,{title:"Task history",description:`Find saved tasks and results in ${l||"this workspace"}, including scheduled work.`,descriptionClassName:"max-w-[720px]",titleAfter:ee>0?e.jsxs("span",{className:"rounded-full bg-blue-50 px-2 py-0.5 text-[12px] font-semibold tabular-nums text-blue-600 ring-1 ring-inset ring-blue-100",children:[ee," unfinished"]}):null}),c?null:e.jsx("div",{className:"mb-4",children:e.jsx(oe,{variant:"underline",items:We,activeId:W,onChange:s=>v({view:s})})}),m&&!c?e.jsxs(U,{tone:"warning",className:"mb-4",role:"status",children:[f.length?"Task history could not be refreshed. Showing the last known state.":"Task history could not be loaded.",e.jsx(j,{variant:"ghost",size:"sm",onClick:y,children:"Retry"})]}):null,p?e.jsxs(U,{tone:"warning",className:"mb-4",children:["Full history is temporarily unavailable. Only recently tracked tasks are shown. ",e.jsx(j,{variant:"ghost",size:"sm",onClick:y,children:"Retry"})]}):null,b&&W==="all"&&!R&&!u&&!m?e.jsxs(U,{className:"mb-4",children:["That task is not in this workspaceâs history. It may have been deleted or belong to another workspace. ",e.jsx(j,{variant:"ghost",size:"sm",onClick:E,children:"Clear selection"})]}):null,W==="all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-3",children:e.jsx(oe,{items:_e,activeId:N,onChange:we,variant:"pill"})}),e.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[e.jsx(ie,{"aria-label":"Search tasks",placeholder:"Search tasks or status",value:D,onChange:s=>ge(s.target.value),className:"min-w-0 flex-1"}),e.jsxs(q,{"aria-label":"Task status",value:B,onChange:s=>ke(s.target.value),className:"w-48 max-w-full",children:[e.jsx("option",{value:"all",children:"All statuses"}),as.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key))]})]}),Z.length?e.jsx(hs,{rows:Z,selectedId:R,onOpen:Ie,stale:!!(m||p)}):e.jsx(C,{as:"div",padding:"none",className:"overflow-hidden shadow-none",children:e.jsx("p",{className:"px-4 py-10 text-center text-[13px] text-stone-400",children:u?"Loading tasksâ¦":m?"Retry to load task history.":D||B!=="all"?"No tasks match your search and status filter.":p?"No recently tracked tasks are available.":N==="scheduled"?`No scheduled runs in ${l}. Automations you schedule will show up here.`:N==="manual"?`No manual runs in ${l}.`:`No runs in ${l}.`})}),R?e.jsx(xs,{runId:R,run:f.find(s=>
1s.run_id===R)||null,onClose:E}):null]}):c?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"ghost",size:"sm",iconLeft:e.jsx(ze,{size:14}),onClick:Te,className:"-ml-2 mb-3",children:"Back to task history"}),e.jsx(os,{eyebrow:"Workflow",title:c.name,aliases:c.aliases,runs:c.runs,loading:u,error:m,stale:!!(m||p),onRetry:y,selectedRunId:$.runId,fallback:$.fallback,requestedRunId:$.requested,onSelectRun:z,onDismissFallback:b?E:void 0,workspaceLabel:l,actions:c.workflowId?e.jsx(j,{variant:"primary",iconLeft:e.jsx(Ee,{size:14}),onClick:()=>t(Ye(c.workflowId,{returnTo:"/runs"})),children:"Run now"}):null,detailFooter:e.jsx("div",{className:"pointer-events-none sticky bottom-0 -mt-6 h-6 bg-gradient-to-t from-white to-transparent","aria-hidden":"true"})})]}):S.length===0?e.jsx(C,{as:"div",padding:"none",className:"overflow-hidden shadow-none",children:e.jsx("p",{className:"px-4 py-10 text-center text-[13px] text-stone-400",children:u?"Loading all runsâ¦":m?"Retry to load task history.":p?"No recently tracked tasks are available.":`No runs in ${l} â switch workspace to see runs made elsewhere.`})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx(ie,{"aria-label":"Search workflows",placeholder:"Search workflows",value:H,onChange:s=>be(s.target.value),className:"min-w-[220px] flex-1"}),e.jsxs(q,{"aria-label":"Workflow status",value:_,onChange:s=>je(s.target.value),className:"w-48",children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"failing",children:"Has failing runs"}),e.jsx("option",{value:"scheduled",children:"Has scheduled runs"})]}),e.jsxs(q,{"aria-label":"Sort workflows",value:L,onChange:s=>ye(s.target.value),className:"w-44",children:[e.jsx("option",{value:"recent",children:"Sort: Last run"}),e.jsx("option",{value:"runs",children:"Sort: Most runs"}),e.jsx("option",{value:"name",children:"Sort: Name"})]})]}),ae.length?e.jsx("div",{className:"flex flex-col gap-2",children:ae.map(s=>e.jsx(us,{group:s,onOpen:Ce,stale:!!(m||p)},s.key))}):e.jsx(C,{as:"div",padding:"none",className:"overflow-hidden shadow-none",children:e.jsx("p",{className:"px-4 py-10 text-center text-[13px] text-stone-400",children:"No workflows match your search."})})]})]})})}export{hs as RunsTable,Ms as default};
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.