PageSourceSearch

https://closegen.ai/assets/Runs-B1j8C94a.js

js closegen.ai collected 2026-10-05 13:00:01 UTC 6,868 bytes, 1 lines download raw bytes

1import{r as o,u as F,h as x,j as t,L as C,a as u,g as n}from"./index-D6qNzN6M.js";import{S as E,s as A,f as D,i as _}from"./lib-CWelQdDg.js";const T=10*60*1e3;function p(i){if(i.status!=="running")return!1;const m=new Date(i.started_at).getTime();return Date.now()-m>T}function $(){var j,v,N;const[i,m]=o.useState([]),[y,S]=F(),r=y.get("run"),[h,f]=o.useState([]),[l,k]=o.useState("");async function d(){const e=x.from("signal_runs").select("*").order("started_at",{ascending:!1}).limit(100);l&&e.eq("step",l);const{data:a}=await e;m(a||[])}o.useEffect(()=>{d();const e=setInterval(d,8e3);return()=>clearInterval(e)},[l]),o.useEffect(()=>{if(!r){f([]);return}x.from("signal_run_logs").select("*").eq("run_id",r).order("ts").limit(500).then(({data:e})=>f(e||[]))},[r]);async function g(e){if(!r)return;const{error:a}=await _("signal-run-control",{run_id:r,action:e});a?n.error(a):(n.success(e),d())}async function w(e){if(!confirm("Mark this run as failed?"))return;const{error:a}=await x.from("signal_runs").update({status:"failed",error:"manually marked failed (stalled)",finished_at:new Date().toISOString()}).eq("id",e);a?n.error(a.message):(n.success("Marked failed"),d())}async function I(e){if(!confirm("Import posts from Apify for this run?"))return;n.loading("Fetching Apify dataset…",{id:"imp"});const{data:a,error:c}=await _("signal-step1-import-apify",{run_id:e});if(c){n.error(c,{id:"imp"});return}n.success(`Imported ${(a==null?void 0:a.inserted)??0} new posts (fetched ${(a==null?void 0:a.fetched)??0})`,{id:"imp"}),d()}const s=i.find(e=>e.id===r);return t.jsxs("div",{className:"flex gap-4 h-[calc(100vh-120px)]",children:[t.jsxs("div",{className:"w-1/2 flex flex-col",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("h1",{className:"text-xl font-semibold",children:"Runs"}),t.jsxs("select",{value:l,onChange:e=>k(e.target.value),className:"ml-auto bg-background border border-border/60 rounded px-2 py-1 text-xs",children:[t.jsx("option",{value:"",children:"All steps"}),E.map(e=>t.jsxs("option",{value:e.id,children:["Step ",e.display,": ",e.label]},e.id))]})]}),t.jsx("div",{className:"overflow-auto rounded border border-border/60",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40 text-xs text-muted-foreground sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left px-2 py-2",children:"Step"}),t.jsx("th",{className:"text-left",children:"Status"}),t.jsx("th",{children:"In→Out"}),t.jsx("th",{className:"text-left",children:"Started"}),t.jsx("th",{children:"Cost¢"})]})}),t.jsx("tbody",{children:i.map(e=>{var b;const a=p(e),c=a?"stalled":e.stop_requested&&e.status==="partial"?"stopped":e.status;return t.jsxs("tr",{onClick:()=>S({run:e.id}),className:`border-t border-border/40 cursor-pointer ${r===e.id?"bg-primary/10":"hover:bg-muted/30"}`,children:[t.jsx("td",{className:"px-2 py-1.5",children:A(e.step)}),t.jsxs("td",{className:e.status==="failed"?"text-destructive":a||e.status==="partial"||e.status==="paused"?"text-amber-400":e.status==="running"?"text-blue-400":"text-emerald-400",children:[/CREDITS_INSUFFICIENT|credits exhausted/i.test(e.error||"")?"out of credits":c,/CREDITS_INSUFFICIENT|credits exhausted/i.test(e.error||"")&&t.jsx("div",{className:"text-[10px] text-destructive",children:"Top up FullEnrich, then Resume on the Dashboard"})]}),t.jsxs("td",{className:"text-center",children:[e.count_in,"→",e.count_out,e.step==="5"&&((b=e.output)==null?void 0:b.processed)!=null&&t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[e.output.processed," processed · ",e.output.phonesFound||0," phones · ",e.output.emailsAdded||0," emails · ",e.output.noData||0," no data"]})]}),t.jsx("td",{className:"text-xs text-muted-foreground",children:D(e.started_at)}),t.jsx("td",{className:"text-center",children:e.cost_cents||0})]},e.id)})})]})})]}),t.jsxs("div",{className:"w-1/2 flex flex-col",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("h2",{className:"text-sm font-semibold",children:"Logs"}),s&&s.step==="1"&&t.jsx(C,{to:`/admin/signal/posts?run=${s.id}`,className:"text-xs text-primary",children:"View posts from this run →"}),s&&s.step==="1"&&(s.status==="failed"||s.status==="running"||p(s))&&(((j=s.input)==null?void 0:j.apify_run_id)||s.status!=="running")&&t.jsx(u,{size:"sm",variant:"outline",className:"ml-auto",onClick:()=>I(s.id),children:s.status==="running"?"Import now from Apify":"Import from Apify"}),(s==null?void 0:s.status)==="running"&&!p(s)&&t.jsxs("div",{className:"ml-auto flex gap-2",children:[t.jsx(u,{size:"sm",variant:"outline",onClick:()=>g(s.paused?"resume":"pause"),children:s.paused?"Resume":"Pause"}),t.jsx(u,{size:"sm",variant:"destructive",onClick:()=>g("stop"),children:"Stop"})]}),s&&p(s)&&t.jsx(u,{size:"sm",variant:"destructive",onClick:()=>w(s.id),children:"Mark failed"})]}),!s&&t.jsx("div",{className:"text-sm text-muted-foreground",children:"Select a run to view logs."}),s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:[s.error&&t.jsx("div",{className:"text-destructive mb-1",children:s.error}),((v=s.output)==null?void 0:v.step1_phase)&&t.jsxs("div",{className:"mb-1 text-foreground",children:["Apify: ",t.jsx("b",{children:s.output.step1_apify_status||s.output.step1_phase}),s.output.step1_apify_checks?` — ${s.output.step1_apify_checks} watchdog check(s)`:"",(N=s.input)!=null&&N.apify_run_id?t.jsxs(t.Fragment,{children:[" — run ",t.jsx("code",{className:"bg-muted/40 px-1 rounded",children:s.input.apify_run_id})]}):null]}),s.output&&(s.output.processed!==void 0||s.output.advanced!==void 0)&&t.jsxs("div",{className:"mb-1 text-foreground",children:["Progress: ",t.jsx("b",{children:s.output.processed||0})," processed",s.output.pending_at_start?` / ${s.output.pending_at_start}`:""," — ","advanced ",t.jsx("b",{className:"text-emerald-400",children:s.output.advanced||0}),", archived ",t.jsx("b",{children:s.output.archived||0}),", errors ",t.jsx("b",{className:"text-red-400",children:s.output.errors||0}),s.output.chunks?` (${s.output.chunks} chunks)`:""]}),"Input: ",t.jsx("code",{className:"bg-muted/40 px-1 rounded",children:JSON.stringify(s.input)})]}),t.jsxs("div",{className:"flex-1 overflow-auto rounded border border-border/60 font-mono text-xs bg-black/30 p-3 space-y-1",children:[h.map(e=>t.jsxs("div",{className:e.level==="error"?"text-red-400":e.level==="warn"?"text-amber-400":"text-muted-foreground",children:[t.jsx("span",{className:"opacity-50",children:new Date(e.ts).toLocaleTimeString()})," [",e.level,"] ",e.message,e.data&&t.jsxs("span",{className:"opacity-60",children:[" ",JSON.stringify(e.data)]})]},e.id)),h.length===0&&t.jsx("div",{className:"text-muted-foreground",children:"No log lines."})]})]})]})]})}export{$ 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.